我指定:
这是部署:
apiVersion: apps/v1beta1
kind: Deployment
...
volumeMounts:
- name: volumepath
mountPath: /data
ports:
- containerPort: 9200
name: http
protocol: TCP
volumes:
- name: volumepath
persistentVolumeClaim:
claimName: pv-delay-bind
这是持久卷:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-delay-bind
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 10Gi
hostPath:
path: /data/
type: DirectoryOrCreate
storageClassName: default1a
持久卷不同于持久卷声明。通常,使用永久性卷声明时,使用的是动态预配。
因此,您需要先定义持久卷声明,并且应自动创建卷。
首先,如果不需要,请删除卷。
$ kubectl delete volume pv-delay-bind
然后创建声明:
$ echo '
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-delay-bind
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 10Gi
storageClassName: default1a' | kubectl apply -f -