Persisting 3rd Party Modules in Kubernetes

Hello All,

Just wanted to add this here for consideration and hopefully for the benefit of others. As noted, without some trickery, getting gateway data to persist requires a slight workaround. I noted this condition also exists for the modules directory which is /usr/local/bin/ignition/user-lib/modules/

I'm testing the following configuration which expands upon the concept of using an init container that seeds initial data which kcollins1 designed. The difference here is that I'm overwriting the stock modules by default every time the pod starts. Thus, if the base image changes, the stock modules are always overwritten and refreshed to the PersistentVolume. Any 3rd party module uploaded by the user should remain intact and untouched.

Things are testing favorably thus far with the CirrusLink MQTT module, so hopefully others find this useful.

Relevant Snippets Here;

spec:
  volumes:
    - name: ignition-pv-mqtt-volume
      persistentVolumeClaim:
        claimName: ignition-pv-mqtt-claim
    - name: ignition-pv-modules-volume
      persistentVolumeClaim:
        claimName: ignition-pv-modules-claim
  initContainers:
    - name: seed-volume
      image: inductiveautomation/ignition:8.1.24
      command:
        - sh
        - '-c'
        - |
          if [ ! -f /data/.ignition-seed-complete ]; then
            touch /data/.ignition-seed-complete ;
            cp -dpR /usr/local/bin/ignition/data/* /data/ ;
          fi
          cp -dpR /usr/local/bin/ignition/user-lib/modules/* /modules/ ;
      resources:
        limits:
          cpu: '1'
          memory: 256Mi
        requests:
          cpu: '1'
          memory: 256Mi
      volumeMounts:
        - name: ignition-pv-mqtt-volume
          mountPath: /data
        - name: ignition-pv-modules-volume
          mountPath: /modules

Two PersistentVolumeClaims above, one for the gateway data and another for the modules directory.

  containers:
    - name: ignition
      image: inductiveautomation/ignition:8.1.24
      args:
        - '-m'
        - '4096'
        - '-n'
        - Ignition-MQTT-Server
      ports:
        - name: ignition-http
          containerPort: 8088
          protocol: TCP
        - name: ignition-https
          containerPort: 8043
          protocol: TCP
      env:
        - name: ACCEPT_IGNITION_EULA
          value: 'Y'
        - name: TZ
          value: America/Chicago
        - name: IGNITION_EDITION
          value: standard
        - name: GATEWAY_MODULES_ENABLED
          value: >-
            allen-bradley-drivers,bacnet-driver,dnp3-driver,enterprise-administration,logix-driver,modbus-driver-v2,omron-driver,opc-ua,siemens-drivers,udp-tcp-drivers
      resources:
        limits:
          cpu: '1'
          memory: 4Gi
        requests:
          cpu: '1'
          memory: 4Gi
      volumeMounts:
        - name: ignition-pv-mqtt-volume
          mountPath: /usr/local/bin/ignition/data
        - name: ignition-pv-modules-volume
          mountPath: /usr/local/bin/ignition/user-lib/modules/

And, as shown above, in the primary container, the mount for /usr/local/bin/ignition/user-lib/modules.

2 Likes