PVC的使用
PVC的挂载是通过volumes字段进行配置的,使用PVC进行挂载时,只需填写PVC的名字即可,不需要再关心任何的存储细节。
比如我们将之前创建的 hostPath 类型的PVC挂载到Pod中,只需要配置一个 persistentVolumeClaim 类型的 volumes,claimName配置为PVC的名称即可:
apiVersion: v1
kind: Pod
metadata:
name: task-pv
labels:
name: task-pv
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: pvc-hostPath
containers:
- name: task-pv
image: nginx:1.25.3
volumeMounts:
- name: task-pv-storage
mountPath: /usr/share/nginx/html
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
最后更新于
这有帮助吗?