使用Kubernetes进行多个卷安装:一个工作,一个不工作

问题描述 投票:5回答:2

我正在尝试使用单个容器创建一个Kubernetes容器,该容器上安装了两个外部卷。我的.yml pod文件是:

apiVersion: v1
kind: Pod
metadata:
  name: my-project
  labels:
    name: my-project
spec:
  containers:
    - image: my-username/my-project
      name: my-project
      ports:
        - containerPort: 80
          name: nginx-http
        - containerPort: 443
          name: nginx-ssl-https
      imagePullPolicy: Always
      volumeMounts:
        - mountPath: /home/projects/my-project/media/upload
          name: pd-data
        - mountPath: /home/projects/my-project/backups
          name: pd2-data
  imagePullSecrets:
    - name: vpregistrykey
  volumes:
    - name: pd-data
      persistentVolumeClaim:
        claimName: pd-claim
    - name: pd2-data
      persistentVolumeClaim:
        claimName: pd2-claim

我正在使用Persistent Volumes和Persistent Volume Claims,因此:qazxsw poi

PV

apiVersion: v1 kind: PersistentVolume metadata: name: pd-disk labels: name: pd-disk spec: capacity: storage: 250Gi accessModes: - ReadWriteOnce gcePersistentDisk: pdName: "pd-disk" fsType: "ext4"

PVC

我最初使用以下命令创建了我的磁盘:kind: PersistentVolumeClaim apiVersion: v1 metadata: name: pd-claim spec: accessModes: - ReadWriteOnce resources: requests: storage: 250Gi 第二个磁盘和第二个PV和PVC也是如此。当我创建pod时,一切似乎都能正常工作,不会抛出任何错误。现在出现了一个奇怪的部分:其中一条路径正确安装(并且因此是持久性的),而另一条路径正在每次重新启动时删除...

我尝试过从头开始重新创建所有内容,但没有任何变化。此外,从pod描述中,两个卷似乎都正确安装:

$ gcloud compute disks create --size 250GB pd-disk

任何帮助表示赞赏。谢谢。

kubernetes persistent-storage
2个回答
0
投票

我没有看到任何直接的问题,如上所述的这种行为已经发生!但我宁愿让你尝试的是使用“部署”而不是像建议的“Pod”,但许多$ kubectl describe pod my-project Name: my-project ... Volumes: pd-data: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: pd-claim ReadOnly: false pd2-data: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: pd2-claim ReadOnly: false ,尤其是使用PV和PVC时。 here负责维护“渴望的国家”的许多事情。我已经在下面添加了我的代码供您参考,但是即使在删除/终止/重新启动之后这两个卷都是持久的,因为这是由部署所需的状态管理的。

您在我的代码中找到的两个区别是:

  1. 我有一个部署对象而不是pod
  2. 我正在使用GlusterFs作为我的音量。

部署yml。

Deployment

我的一个PV

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx namespace: platform labels: component: nginx spec: replicas: 2 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 1 template: metadata: labels: component: nginx spec: nodeSelector: role: app-1 containers: - name: nginx image: vip-intOAM:5001/nginx:1.15.3 imagePullPolicy: IfNotPresent volumeMounts: - mountPath: "/etc/nginx/conf.d/" name: nginx-confd - mountPath: "/var/www/" name: nginx-web-content volumes: - name: nginx-confd persistentVolumeClaim: claimName: glusterfsvol-nginx-confd-pvc - name: nginx-web-content persistentVolumeClaim: claimName: glusterfsvol-nginx-web-content-pvc

PVC为上述

apiVersion: v1 kind: PersistentVolume metadata: name: glusterfsvol-nginx-confd-pv spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce glusterfs: endpoints: gluster-cluster path: nginx-confd readOnly: false persistentVolumeReclaimPolicy: Retain claimRef: name: glusterfsvol-nginx-confd-pvc namespace: platform


0
投票

Kubernetes kind: PersistentVolumeClaim apiVersion: v1 metadata: name: glusterfsvol-nginx-confd-pvc namespace: platform spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi 说:

卷无法装入其他卷或具有到其他卷的硬链接

我有同样的问题,在我的情况下,问题是两个卷安装都有重叠的mountPaths,即两者都以/ var /开头。

修好之后,他们没有问题。

© www.soinside.com 2019 - 2024. All rights reserved.