检查的你的pvc创建后,是否能正常创建出pv:
首先创建Pvc
# kubectl apply -f - <<EOF
> kind: PersistentVolumeClaim
> apiVersion: v1
> metadata:
> name: pvc-sample
> spec:
> accessModes:
> - ReadWriteOnce
> resources:
> requests:
> storage: 10Gi
> EOF
persistentvolumeclaim/pvc-sample created
检查PVC状态:
# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-sample Pending openebs-hostpath 15s
挂载pvc
# kubectl apply -f - <<EOF
> apiVersion: apps/v1
> kind: Deployment
> metadata:
> creationTimestamp: null
> labels:
> run: container
> name: container
> spec:
> replicas: 1
> selector:
> matchLabels:
> run: container
> strategy: {}
> template:
> metadata:
> creationTimestamp: null
> labels:
> run: container
> spec:
> volumes:
> - name: xx
> persistentVolumeClaim:
> claimName: pvc-sample
> containers:
> - args:
> - sleep
> - "1000"
> image: alpine
> name: container
> resources: {}
> status: {}
> EOF
deployment.apps/container created
再次检查Pvc状态:
# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-sample Bound pvc-47a49be3-1650-4474-b341-98302be17e69 10Gi RWO openebs-hostpath 98s
确认pv能正常创建:
# kubectl get pv | grep pvc-sample
pvc-47a49be3-1650-4474-b341-98302be17e69 10Gi RWO Delete Bound default/pvc-sample openebs-hostpath 29s