# Problems with running container on a Kubernetes Persistent Volume

**URL:** <https://forum.inductiveautomation.com/t/problems-with-running-container-on-a-kubernetes-persistent-volume/60344>\
**Category:** Ignition\
**Created:** [June 3, 2022, 1:11pm UTC](https://forum.inductiveautomation.com/t/problems-with-running-container-on-a-kubernetes-persistent-volume/60344 "2022-06-03T13:11:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![declan.mccarthy](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@declan.mccarthy](https://forum.inductiveautomation.com/u/declan.mccarthy)\
**Post date:** [June 3, 2022, 1:11pm UTC](https://forum.inductiveautomation.com/t/problems-with-running-container-on-a-kubernetes-persistent-volume/60344/1 "2022-06-03T13:11:14Z")

</div>

When I use a mount path of /usr/local/bin/ignition/data in my kubernetes deployment yaml, the container won’t start (it works fine in docker-compose on podman & docker). Ignition gateway log reports an error of  
init | 2022/05/24 15:00:27 | Creating init.properties file  
init | 2022/05/24 15:00:27 | Creating gateway.xml  
cp: cannot stat ‘/usr/local/bin/ignition/data/gateway.xml\_clean’: No such file or directory

and kubectl get pod shows the container as CrashLoopBackOff

If I change the mount path to /data then the container starts but the volume mounts as /data within the container and not /usr/local/bin/ignition/data so that the data directory is located in temporary storage and is lost on pod restart.  
To get around this, I entered into the command line of the container and copied the contents of /usr/local/bin/ignition/data to /data, killed the pod, set my mount path back to /usr/local/bin/ignition/data and restarted the pod. The container started up fine and can now read & write files within the persistent volume  
Yaml contents:

```
apiVersion: v1
kind: PersistentVolume
metadata:
  name: foo-data-pv
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 200Mi
  hostPath:
    path: /data/containerData/foo-data
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-path
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: foo-data-pvc
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 200Mi
  storageClassName: local-path
  volumeName: foo-data-pv
status:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 200Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ignition-foo-pilot
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ignition-foo-pilot
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: ignition-foo-pilot
    spec:
      containers:
      - env:
        - name: GATEWAY_SYSTEM_NAME
          value: ignition-foo
        - name: GATEWAY_ADMIN_USERNAME
          value: admin
        - name: GATEWAY_ADMIN_PASSWORD
          value: password
        - name: IGNITION_EDITION
          value: standard
        image: inductiveautomation/ignition:8.1.16
        imagePullPolicy: IfNotPresent
        name: ignition-foo
        ports:
        - containerPort: 8088
          protocol: TCP
        - containerPort: 8060
          protocol: TCP
        volumeMounts:
        - mountPath: /usr/local/bin/ignition/data
          name: foo-data
      restartPolicy: Always
      volumes:
      - name: foo-data
        persistentVolumeClaim:
          claimName: foo-data-pvc
```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 3, 2022, 1:37pm UTC](https://forum.inductiveautomation.com/t/problems-with-running-container-on-a-kubernetes-persistent-volume/60344/2 "2022-06-03T13:37:05Z")

</div>

Have you looked through this thread?

> [@Kubernetes PersistentVolume - Backup /data](https://forum.inductiveautomation.com/t/kubernetes-persistentvolume-backup-data/41306/11):
>
> Just augmenting this thread for those that find it (since I had a couple questions on this topic, recently)… In K8s, you can leverage [initContainers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) to seed the data volume prior to initial launch of the Gateway container [in the pod]. Here is an example deployment that leverages an init container to seed the data volume with files from the image: # Ignition K8s Example Deployment --- # Deployment apiVersion: apps/v1 kind: Deployment metadata: name: ignition-deployment spec: selector: …
