nats-io / nats-streaming-operator

NATS Streaming Operator
Apache License 2.0
174 stars 44 forks source link

Does not handle spec updates other than size #74

Closed renier closed 3 years ago

renier commented 3 years ago

The operator doesn't handle any updates to the NatsStreamingCluster spec other than the size setting. So if you update the server version, that won't get passed down to the managed pods. Same with annotations.

The operator does seem to pass down these properties when creating new pods, but if the pods are already running, updates don't take effect. This is a serious lack since it prevents you from managing the streaming server version being run, but it is also important if you are providing the configuration file via a configmap like below, where you want to make sure that the pods are restarted if there are configmap changes upon deploy as recommended here:

---
apiVersion: "streaming.nats.io/v1alpha1"
kind: "NatsStreamingCluster"
metadata:
  name: "stan-cluster"
  namespace: {{ .Values.namespace }}
spec:
  natsSvc: {{ .Values.cluster.name }}
  version: "{{ .Values.stan_version }}"

  size: 3
  configFile: "/etc/stan/config/stan.conf"
  config:
    storeDir: "/pv/stan"
    ftGroup: "stan"

  template:
    metadata:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "{{ .Values.metrics_port }}"
        checksum/config: {{ include (print $.Template.BasePath "/configs.yaml") . | sha256sum }}

    spec:
      volumes:
      - name: {{ .Values.config_name }}
        configMap:
          name: {{ .Values.config_name }}
      - name: stan-store-dir
        persistentVolumeClaim:
          claimName: {{ .Values.pvc_name }}
      containers:
      - name: nats-streaming
        volumeMounts:
        - mountPath: /etc/stan/config
          name: {{ .Values.config_name }}
          readOnly: true
        - mountPath: /pv
          name: stan-store-dir

      - name: metrics
        image: synadia/prometheus-nats-exporter:0.2.0
        args: ["-connz", "-routez", "-subz", "-varz", "-channelz", "-serverz", "-DV", "http://localhost:8222/"]
        ports:
        - name: metrics
          containerPort: {{ .Values.metrics_port }}
          protocol: TCP

In the case of the version, not even deleting the pods will get them restarted with the updated streaming server version. This works however with the nats operator.