k8s里pv pvc configmap

 

通过storageClassName 将PV 和PVC 关联起来。

1
2
3
4
5
6
7
8
9
10
11
12
13
[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       
复制代码

 

posted @   beawh  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示