Changing configuration in running Kubernetes Pod Changing configuration in running Kubernetes Pod kubernetes kubernetes

Changing configuration in running Kubernetes Pod


There are two problems with the above setup:

To workaround the second issue you can simply mount the configmap item as a separate file (nifi.properties.tmp) and copy it to the destination by wrapping the container entry point with a custom command.

...containers:- name: 'myName'  image: 'apache/nifi:latest'  ports:    - name: http      containerPort: 8080      protocol: TCP    - name: http-2      containerPort: 1337      protocol: TCP  volumeMounts:    - name: 'nifi-config'      mountPath: /opt/nifi/nifi-1.6.0/conf/nifi.properties.tmp      subPath: nifi.properties  command:  - bash  - -c  - |    cat "${NIFI_HOME}/conf/nifi.properties.tmp" > "${NIFI_HOME}/conf/nifi.properties"    exec "${NIFI_BASE_DIR}/scripts/start.sh    # or you can do the property edits yourself and skip the helper script:    # exec bin/nifi.sh runvolumes:- name: 'nifi-config'  configMap:    name: 'nifi-config'...


I solved this with the help of this helm file, but changed it a bit. Actually it is nearly the same as the answer that pepov has given, but as stated in my comment, I got a CrashLoopBackOff. This also had nothing to do with the image version, because I used my own image that is based on NiFi 1.6.0 also containing some custom processors.

So my solution is to use the postStart handler of Kubernetes. Problem is that it is not guaranteed that this handler is called before the ENTRYPOINT (see). But in this case the pod would crash and restart, eventually getting it right; right now I haven't had this problem, so it seems to be good for now.
I copy the content of the configMap into a dedicated folder and copy them in the associated NiFi folder in the postStart handler.

So here is the statefulset.yaml:

...containers:- name: 'myName'  image: 'apache/nifi:latest'  ports:    - name: http      containerPort: 8080      protocol: TCP    - name: http-2      containerPort: 1337      protocol: TCP  volumeMounts:    - name: 'nifi-config'      mountPath: /opt/nifi/nifi-1.6.0/kubeconfig  lifecycle:    postStart:      exec:        command:          - bash          - -c          - |            cp -a /opt/nifi/nifi-1.6.0/kubeconfig/. /opt/nifi/nifi-1.6.0/confvolumes:- name: 'nifi-config'  configMap:    name: 'nifi-config'...