12、持久化存储卷PersistentVolume
1. 考题内容:
2. 答题思路:
按题目要求检查各个参数,我就是第一次没看清楚,把ReadWriteOnce写成ReadWriteMany了,幸亏做完检查了一遍
这个参数可有可无,加上也不影响
storageClassName: manual
3. 官网地址:
4. 考题答案:
切换环境
kubectl config use-tontext hk8s
# 1).编写pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-config
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/srv/app-config"
# 2).创建pv.yaml
kubectl apply -f pv.yaml
5. 验证:
# 1).查看创建的pv
kubectl get pv app-config