你好 Kubernetes 冠军,我们最近转移到卷的“保留”模式。一切正常,不幸的是操作系统崩溃了。重新启动后,除了使用 PVC 和 PV 的 Pod 之外,所有 Pod 都可以成功运行。我检查了PV,它们似乎很好
pvc-df5b3877-762e-4ce1-b45f-7f98cba4a4ab 1Gi RWO Retain Bound default/pvc-svcmaps example-nfs 21d
PVC看起来也不错
pvc-svcmaps Bound pvc-df5b3877-762e-4ce1-b45f-7f98cba4a4ab 1Gi RWO example-nfs 21d
但是吊舱卡住了,没有重新启动
svcmaps-949f87f58-jg5wz 0/1 Init:Unknown 0 6h48m
以下是我运行 cmd 时 pod 内的错误(k describe po svcmaps-949f87f58-jg5wz)
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedMount 3m24s (x194 over 6h39m) kubelet, site Unable to mount volumes for pod "svcmaps-949f87f58-jg5wz_default(cf9ebf48-43cc-4f21-bcd6-480732c5fa43)": timeout expired waiting for volumes to attach or mount for pod "default"/"svcmaps-949f87f58-jg5wz". list of unmounted volumes=[svcmaps-storage]. list of unattached volumes=[svcmaps-storage default-token-ppqgg]````
当我们使用 "reclaimPolicy: Retain" 时,有什么我们应该遗漏的吗?
下面是我们使用的存储yaml
kind: ServiceAccount
metadata:
name: nfs-provisioner
---
kind: Service
apiVersion: v1
metadata:
name: nfs-provisioner
labels:
app: nfs-provisioner
spec:
ports:
- name: nfs
port: 2049
- name: mountd
port: 20048
- name: rpcbind
port: 111
- name: rpcbind-udp
port: 111
protocol: UDP
selector:
app: nfs-provisioner
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: nfs-provisioner
spec:
selector:
matchLabels:
app: nfs-provisioner
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-provisioner
spec:
serviceAccount: nfs-provisioner
containers:
- name: nfs-provisioner
image: quay.io/kubernetes_incubator/nfs-provisioner:v2.2.2
ports:
- name: nfs
containerPort: 2049
- name: mountd
containerPort: 20048
- name: rpcbind
containerPort: 111
- name: rpcbind-udp
containerPort: 111
protocol: UDP
securityContext:
capabilities:
add:
- DAC_READ_SEARCH
- SYS_RESOURCE
args:
- "-provisioner=example.com/nfs"
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: SERVICE_NAME
value: nfs-provisioner
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: export-volume
mountPath: /export
volumes:
- name: export-volume
hostPath:
path: /srv
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
annotations:
storageclass.beta.kubernetes.io/is-default-class: "true"
name: example-nfs
reclaimPolicy: Retain
provisioner: example.com/nfs
mountOptions:
- vers=4.1
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: cluster-admin-0
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: nfs-provisioner
namespace: default