k8s里pv pvc configmap

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

复制代码
[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       
相关推荐
小白的码BUG之路5 分钟前
Docker -- No space left on device
运维·docker·容器
EatFan11 分钟前
从云原生到AI原生:2026后端架构“三驾马车”(事件驱动、虚拟线程、AI Agent内嵌)演进解析
spring boot·云原生·架构·虚拟线程·ai-native·ai agent·spring ai
wzq11_66637 分钟前
Kubernetes集群——Service篇(详细讲解!!!)
云原生·容器·kubernetes
程序员老陆1 小时前
Docker 命令全景指南:从镜像构建到生产运维
运维·docker·容器
Henry-SAP16 小时前
SAP MRP失效根源业务角度解析
人工智能·云原生·sap·erp
江湖有缘21 小时前
3款开源绘图工具整理合集,可Docker一键部署!
docker·容器·开源
nhdh1 天前
Higress:AI时代云原生网关新选择
人工智能·云原生
小匠石钧知1 天前
06_在k8s集群中安装MetalLB实现LoadBalancer
云原生·容器·kubernetes·service·loadbalancer·metallb
troy1282 天前
阿里云 vs 谷歌云:Kubernetes 部署深度对比分析
阿里云·kubernetes·云计算
谢亮_vipxieliang2 天前
容器排障实战手册:从日志到内核的分层排障
docker·云原生·容器·eureka