模拟题目:
设置配置环境: [candidate@node-1] $ kubectl config use-context hk8s
Task
创建名为 app-config 的 persistent volume,容量为 1Gi,访问模式为 ReadWriteMany。 volume 类型为 hostPath,位于 /srv/app-config
参考:
任务 --> 配置 Pods 和容器 --> 配置 Pod 以使用 PersistentVolume 作为存储 https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
解答:
考试的时候务必记住切换集群, 注意集群名称 kubectl config use-context k8s
vim pv.yaml
pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-config
# labels:
# type: local
spec:
# storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/srv/app-config"
应用文件
kubectl apply -f pv.yaml
检查:
kubectl get pv