我正在使用以下卷声明:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: persistent-storage-claim
labels:
app: {{ include "api-chart.name" . }}
chart: {{ include "api-chart.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: managed-premium
volumeName: personal
在以下部署中:
...
...
spec:
imagePullSecrets:
- name: registrySecret
volumes:
- name: personal-volume
persistentVolumeClaim:
claimName: persistent-storage-claim
containers:
- name: container1
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.targetPort }}
protocol: TCP
volumeMounts:
- name: personal-volume
mountPath: "/workspace"
...
装载此卷似乎会导致部署挂起(它不会部署,但我在任何地方都看不到任何错误消息(。如果删除volumenMounts
部分,则部署成功。 我正在使用helm install
来部署应用程序。关于可能导致问题的原因的任何想法?或者至少如何调试它?
更新:kubectl get events
返回以下内容:
LAST SEEN TYPE REASON OBJECT MESSAGE
46s Warning FailedScheduling pod/storage-test-labd62r2 pod has unbound immediate PersistentVolumeClaims (repeated 3 times)
24m Normal SuccessfulCreate replicaset/test-storage-b65db5698 Created pod: storage-test-labd62r2
24m Normal ScalingReplicaSet deployment/test-storage Scaled up replica set test-storage-b65db5698 to 1
24m Normal CREATE ingress/test-storage Ingress default/test-storage
24m Normal CREATE ingress/test-storage Ingress default/test-storage
24m Normal UPDATE ingress/test-storage Ingress default/test-storage
24m Normal UPDATE ingress/test-storage Ingress default/test-storage
kubectl get pvc
给出:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistent-storage-claim Pending personal 0 managed-premium 33m
kubectl get pv
不显示任何内容
kubectl svc
:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
test-storage ClusterIP 10.0.244.147 <none> 80/TCP,8080/TCP 35m
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 16d
发生这种情况通常是因为没有手动预配的PersistentVolume
来满足PersistentVolumeClaim
,或者声明中提到的StorageClass
不存在或无法动态预配PersistentVolume
以满足PersistentVolumeClaim