Cluster Authorization from Secret #833
-
I am trying to deploy NATS on multiple k8s clusters, which I have done successfully. I want to add authorization config to each cluster, however I cant find a way to specify a username and password in the config.cluster.authorization value securely i.e. from a Secret. Does this functionality not exists or have i missed something? Is the only way to specify these values in plain text when deploying using helm? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It involves some templating. In NATS config, user/pass route auth has to be specified as part of the URL for
I don't think NATS config can do string interpolation with variables to build those URLs. So they'd have to be built in Environment Variables. Try this: config:
cluster:
enabled: true
routeURLs:
user: foo
password: << $CLUSTER_AUTH >>
merge:
routes:
$tplYaml: |
{{- range $i, $_ := until (int $.Values.config.cluster.replicas) }}
- << $ROUTE_{{ $i }} >>
{{- end }}
container:
env:
CLUSTER_AUTH:
valueFrom:
secretKeyRef:
name: secret-name
key: secret-key
ROUTES:
$tplYamlSpread: |
{{- range $i, $_ := until (int $.Values.config.cluster.replicas) }}
ROUTE_{{ $i }}: {{ printf "nats://%s:$(CLUSTER_AUTH)@%s-%d.%s:%d" $.Values.config.cluster.routeURLs.user $.Values.statefulSet.name $i $.Values.headlessService.name (int $.Values.config.cluster.port) }}
{{- end }}
|
Beta Was this translation helpful? Give feedback.
It involves some templating. In NATS config, user/pass route auth has to be specified as part of the URL for
cluster.routes
:I don't think NATS config can do string interpolation with variables to build those URLs. So they'd have to be built in Environment Variables. Try this: