pires/kubernetes-nats-cluster

Deprecate environment variables in favor of ConfigMap

pires opened this issue · 5 comments

This would come in handy in downstream nats-operator, especially given the fact that one can send a SIGHUP to gnatsd to force a configuration reload.

I think the most useful way is to store the full NATS configuration in a ConfigMap and then use it to populate a volume:

apiVersion: v1
kind: ConfigMap
data:
  nats.conf: |
    debug: true

    authorization {
      user: nats_user
      password: $WE_CAN_READ_THIS_FROM_AN_ENVVAR_CONTAINING_A_SECRET
    }

    cluster {
      host: '0.0.0.0'
      port: 6222

      routes = [
        nats://nats:6222
      ]
    }

We can then start NATS with gnatsd -c /path/to/nats.conf and be done with it. The only downside I can think of ATM is that this forces users to understand and deal with the NATS config syntax—but maybe that's not terrible? WDYT @pires?

pires commented

Sure. Go ahead and do it ;)

I am waiting for an answer on this issue before submitting a PR — most of the work is done, but ATM pods keep crashing because nats doesn't immediately resolve.

Seems like a fix is on the works @ nats-io/nats-server#578 💯

@brunomcustodio seems that the issue is fixed. Any chance you've had a chance to work on a PR? :)