Pod/Container directory used to mount nfs path gets empty after deployment

6/18/2020

The following is my kubernetes/openshift deployment configuration template, along with its persistent volumes and persistent volume claims:

<!--language: lang-yaml -->
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: pythonApp
  creationTimestamp: null
  annotations:
    openshift.io/image.insecureRepository: "true"
spec:
  replicas: 1
  strategy:
    type: Recreate
  revisionHistoryLimit: 2
  template:
    metadata:
      labels:
        app: pythonApp
      creationTimestamp: null
    spec:
      hostAliases:
        - ip: "127.0.0.1"
          hostnames:
            - "backend"
      containers:
        - name: backend
          imagePullPolicy: IfNotPresent
          image: <img-name>
          command: ["sh", "-c"]
          args: ['python manage.py runserver']
          resources: {}
          volumeMounts:
          - mountPath: /pythonApp/configs
            name: configs
      restartPolicy: Always
      volumes:
      - name: configs
        persistentVolumeClaim:
          claimName: "configs-volume"
status: {}

---------------------------------------------------------------

apiVersion: v1
kind: PersistentVolume
metadata:
  name: "configs-volume"
  storageClassName: manual
  capacity:
    storage: 1Gi
  persistentVolumeReclaimPolicy: Retain
  accessModes:
  - ReadWriteMany
  nfs:
    path: /mnt/k8sMount/configs
    server: <server-ip>

---------------------------------------------------------------

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: "configs-volume-claim"
  creationTimestamp: null
spec:
  storageClassName: manual
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  volumeName: "configs-volume"

After the deployment, when I exec inside the container (using oc exec or kubectl exec) and check the /pythonApp/configs folder, it is found to be empty, when really it's supposed to have some configuration files from the used image.

Is this issue caused due to the fact that /pythonApp/configs is mounted to the persistent nfs volume mount path /mnt/k8sMount/configs, which will be initially empty?

How could this be solved?


Environment

  • Kubernetes version: 1.11
  • Openshift version: 3.11
-- Rakesh Kotian
kubernetes
nfs
okd
openshift
persistent-storage

0 Answers