3

The following is my kubernetes/openshift deployment, pv and pvc-yaml template:

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"

Here after the deployment when I exec inside the container(using oc exec or kubectl exec command) and check the folder /pythonApp/configs, it is found to be empty. Actually it is supposed to be having some configuration files from image that is used.

Is this issue due to /pythonApp/configs is mounted to the persistent nfs volume mount path /mnt/k8sMount/configs which will be initially empty?. How this could be solved?

Kubernetes version: 1.11 Openshift version: 3.11

Rakesh Kotian
  • 115
  • 11

0 Answers0