In this article we’re going to:
- Install NATS and STAN using Helm into Kubernetes
- Follow along in a NATS minimal setup tutorial
- Create an administrative pod for NATS and STAN
- Confirm NATS sub/pub is working
- Confirm STAN sub/pub is working
This installs NATS so that clients can use it without authenticating!
At the time of this writing I’m not aware of a good way to install STAN supporting authentication. For example, like referencing a Config Map to get an account and Secret to get a password. Therefore, so I opted out of requiring client authentication for NATS so that I can do minimal testing.
I will follow-up in Github and in NATS documentation and circle back here to add the missing authentication settings.
1 - Install NATS and STAN# install NATS helm repo add bitnami https://charts.bitnami.com/bitnami helm install nats bitnami/nats --set replicaCount=3 \ --set auth.enabled=false \ --set clusterAuth.enabled=true,clusterAuth.user=admin,clusterAuth.password=$password # install STAN (notice how no creds are NOT needed!) helm repo add nats https://nats-io.github.io/k8s/helm/charts/ helm install stan nats/stan \ --set store.type=file --set store.file.storageSize=1Gi \ --set stan.nats.url=nats://nats-client.default.svc.cluster.local:4222 \ --set store.cluster.enabled=true \ --set store.cluster.logPath=/data/stan/store/log
Now let’s follow along in the tutorial.
2.1 - Create an Administrative Podkubectl run -i --rm --tty nats-box --image=synadia/nats-box --restart=Never
2.2 - Test NATS sub/pubnats-sub -s nats-client.default.svc.cluster.local -t test & nats-pub -s nats-client.default.svc.cluster.local -t test "this is a test"
Which should yield:
2020/05/03 23:20:11 [#1] Received on [test]: 'this is a test'
2.3 - Test STAN sub/pubstan-sub -c stan -s nats-client.default.svc.cluster.local test & stan-pub -c stan -s nats-client.default.svc.cluster.local test "this is a test"
Which should yield:
[#1] Received: sequence:1 subject:"test" data:"this is a test" timestamp:1588550818187067125