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       
相关推荐
智想天开3 分钟前
13.组合模式:思考与解读
docker·设计模式·容器·组合模式
郝同学的测开笔记18 分钟前
云原生探索系列(十七):Go 语言sync.Cond
后端·云原生·go
Sirius Wu34 分钟前
TiDB 深度解析与 K8S 实战指南
容器·kubernetes·tidb
程序媛学姐1 小时前
Spring Cloud Kubernetes:在K8s环境中的服务发现与配置
spring cloud·kubernetes·服务发现
kill bert2 小时前
第33周JavaSpringCloud微服务 分布式综合应用
微服务·云原生·架构
AdaTina2 小时前
Docker的分解分析
运维·docker·容器
阿里云云原生2 小时前
通义灵码 CCF 算法大会首秀,解码研发智能落地「黄金三角」| 文末领取PPT
云原生
weisian1512 小时前
云原生--核心组件-容器篇-7-Docker私有镜像仓库--Harbor
docker·云原生·容器
Lowcode0022 小时前
云原生开发革命:iVX 如何实现 “资源即插即用” 的弹性架构?
云原生·架构
代码小学僧2 小时前
使用 Cloudflare workers 做一个定时发送消息的飞书机器人
前端·云原生·serverless