【发布时间】:2016-05-28 09:16:58
【问题描述】:
我正在尝试创建一个带有单个容器的 Kubernetes pod,该容器上安装了两个外部卷。我的 .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 和 Persisten Volume Claims,例如:
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
我最初使用以下命令创建了磁盘:
$ gcloud compute disks create --size 250GB pd-disk
第二个磁盘和第二个 PV 和 PVC 也是如此。当我创建 pod 时,一切似乎都正常,没有抛出任何错误。现在出现了奇怪的部分:其中一条路径被正确安装(并且因此是持久的),而每次我重新启动 pod 时,另一条路径被删除......
我尝试从头开始重新创建所有内容,但没有任何改变。此外,从 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
感谢任何帮助。谢谢。
【问题讨论】:
-
你用的是什么版本的kubernetes,你是怎么重启pod的?
-
我使用的是 Kubernetes v1,为了重新启动 pod,我使用的是
kubectl delete -f my-project.yml,然后是kubectl create -f my-project.yml -
kubectl version的输出是什么? -
Client Version: version.Info{Major:"1", Minor:"1", GitVersion:"v1.1.4", GitCommit:"a5949fea3a91d6a50f40a5684e05879080a4c61d", GitTreeState:"clean"} Server Version: version.Info{Major:"1", Minor:"1", GitVersion:"v1.1.7", GitCommit:"e4e6878293a339e4087dae684647c9e53f1cf9f0", GitTreeState:"clean"} -
如果您能够解决此问题,您可以在此处为可能遇到相同问题的其他社区成员发布自我回答。
标签: kubernetes persistent-storage