3

Is it possible to use PersistentVolume to mount entire "/" diirectory of a linux container on it.

i am trying to mount it, but it fails. i basically want a container, where i would be doing ,multiple changes througtout, and want those changes to persist across pod crashes/restart

   ubuntu@kops:/tmp$ cat pod.yaml
    kind: Deployment
    apiVersion: apps/v1beta2
    metadata:
      name: task-pod
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: testing
      template:
        metadata:
         labels:
          app: testing
        spec:
           containers:
           - name: nginx
             image: nginx:1.7.9
             ports:
             - containerPort: 80
             volumeMounts:
             - mountPath: "/"
               name: task-pv
           volumes:
           - name: task-pv
             persistentVolumeClaim:
                claimName: task-pvc

Error

   Events:
      Type     Reason                 Age               From                                                 Message
      ----     ------                 ----              ----                                                 -------
      Normal   Scheduled              40s               default-scheduler                                    Successfully assigned task-pod-5569b7b85f-8vkwh to ip-172-20-48-22.us-west-2.compute.internal
      Normal   SuccessfulMountVolume  39s               kubelet, ip-172-20-48-22.us-west-2.compute.internal  MountVolume.SetUp succeeded for volume "default-token-p4qnh"
      Normal   SuccessfulMountVolume  23s               kubelet, ip-172-20-48-22.us-west-2.compute.internal  MountVolume.SetUp succeeded for volume "pvc-c5d5e0d7-4c8a-11e8-8b60-065b35183c1c"
      Normal   Pulled                 9s (x3 over 22s)  kubelet, ip-172-20-48-22.us-west-2.compute.internal  Container image "nginx:1.7.9" already present on machine
      Warning  Failed                 9s (x3 over 22s)  kubelet, ip-172-20-48-22.us-west-2.compute.internal  Error: Error response from daemon: invalid bind mount spec "/var/lib/kubelet/pods/7f777534-4c8f-11e8-8b60-065b35183c1c/volumes/kubernetes.io~aws-ebs/pvc-c5d5e0d7-4c8a-11e8-8b60-065b35183c1c:/": invalid volume specification: '/var/lib/kubelet/pods/7f777534-4c8f-11e8-8b60-065b35183c1c/volumes/kubernetes.io~aws-ebs/pvc-c5d5e0d7-4c8a-11e8-8b60-065b35183c1c:/': invalid mount config for type "bind": invalid specification: destination can't be '/'
      Warning  FailedSync             9s (x3 over 22s)  kubelet, ip-172-20-48-22.us-west-2.compute.internal  Error syncing pod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.