nats-operator
nats-operator copied to clipboard
Add environment variable to nats-cluster pods
We are trying to access the pod name in the annotations by using the downward API in the environment variables section. Given the current state of the CRD, we are unable to do this in the yaml config. Can someone suggest a way to either access the pod name in the annotations given the current state of the CRD, or suggest what to add to the config to allow access to this info?
apiVersion: "nats.io/v1alpha2" kind: "NatsCluster" metadata: name: "nats-cluster" spec: size: 3 version: "2.0.0" serverImage: "nats" pod: antiAffinity: true enableMetrics: true metricsImage: "synadia/prometheus-nats-exporter" metricsImageTag: "0.3.0" labels: app: test annotations: ad.datadoghq.com/nats.check_names: '["openmetrics"]' ad.datadoghq.com/nats.init_configs: '[{}]' ad.datadoghq.com/nats.instances: '[{"prometheus_url": "http://%%host%%:7777/metrics","namespace":"nats","metrics": ["gnatsd_varz_slow_consumers","gnatsd_varz_subscriptions","gnatsd_varz_connections","gnatsd_varz_out_msgs","gnatsd_varz_out_bytes","gnatsd_varz_in_msgs","gnatsd_varz_in_bytes","gnatsd_varz_mem","gnatsd_varz_cpu"]}]' template: spec: containers: - name: nats image: nats:2.0.0 env: - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name