如何在 AWS k8s 中的持久卷上挂载 Linux 容器的整个“/”目录

如何在 AWS k8s 中的持久卷上挂载 Linux 容器的整个“/”目录

是否可以使用 PersistentVolume 在其上挂载 Linux 容器的整个“/”目录。

我正在尝试安装它,但失败了。我基本上想要一个容器,我将在其中进行多次更改,并希望这些更改在 Pod 崩溃/重新启动时持续存在

   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

错误

   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

相关内容