测试lcoal StorageClass
vi local-path.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-path-pvc
spec:
storageClassName: nfs # <=== 使用哪个SC
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:1.21.1
imagePullPolicy: IfNotPresent
name: nginx-container
ports:
- containerPort: 80
name: http
protocol: TCP
volumeMounts:
- mountPath: /usr/share/nginx/html
name: local-path-volume
restartPolicy: Always
volumes:
- name: local-path-volume
persistentVolumeClaim:
claimName: local-path-pvc
kubectl apply -f local-path.yaml
~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-179-6498fb8cd9-mhhlk 1/1 Running 0 3m22s
# 注意pv和pvc的状态
~]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
local-path-pvc Bound pvc-6b5f4ec5-a0ed-4b47-9531-b0ed2d10e139 10Gi RWO nfs 3m32s
~]# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-6b5f4ec5-a0ed-4b47-9531-b0ed2d10e139 10Gi RWO Delete Bound default/local-path-pvc nfs 3m38s
标签:lcoal,PVC,StorageClass,path,K8S,local
From: https://www.cnblogs.com/gshelldon/p/18034060