通過storageClassName 將PV 和PVC 關(guān)聯(lián)起來。文章來源地址http://www.zghlxwxcb.cn/news/detail-682344.html
[root@k8-master home]# cat /home/npm-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: npm-repository-pvc
namespace: jenkins
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: npm-repository-pv
[root@k8-master yaml]# cat /home/npm-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: npm-repository-pv
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
storageClassName: "npm-repository-pv"
nfs:
server: 192.168.10.128
path: /data/repository/npm
[root@k8-master yaml]# cat nginx-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx-k8s-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
storageClassName: "nginx-k8s-pv"
nfs:
server: 192.168.10.128
path: /data/volumes
[root@k8-master yaml]# cat nginx-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-k8s-pvc
namespace: test
spec:
resources:
requests:
storage: 10Gi
accessModes:
- ReadWriteMany
storageClassName: "nginx-k8s-pv"
[root@k8-master yaml]# cat nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
namespace: test
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app : nginx
spec:
containers:
- image: nginx:1.21
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- name: nfs-volumes
mountPath: /usr/share/nginx/html
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
volumes:
- name: nfs-volumes
persistentVolumeClaim:
claimName: nginx-k8s-pvc
- name: nginx-config
configMap:
name: nginx-config
items:
- key: nginx.conf
path: nginx.conf
文章來源:http://www.zghlxwxcb.cn/news/detail-682344.html
到了這里,關(guān)于k8s里pv pvc configmap的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!