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       
相关推荐
AKAMAI3 小时前
跳过复杂环节:Akamai应用平台让Kubernetes生产就绪——现已正式发布
人工智能·云原生·云计算
阿里云云原生9 小时前
不重启、不重写、不停机:SLS 软删除如何实现真正的“无感数据急救”?
云原生
Serverless社区1 天前
函数计算的云上计费演进:从请求驱动到价值驱动,助力企业走向 AI 时代
阿里云·云原生·serverless
资源开发与学习2 天前
Kubernetes集群核心概念 Service
kubernetes
阿里云云原生2 天前
【云栖大会】AI原生、AI可观测、AI Serverless、AI中间件,4场论坛20+议题公布!
云原生
容器魔方2 天前
Bloomberg 正式加入 Karmada 用户组!
云原生·容器·云计算
muyun28003 天前
Docker 下部署 Elasticsearch 8 并集成 Kibana 和 IK 分词器
elasticsearch·docker·容器
Nazi63 天前
k8s的dashboard
云原生·容器·kubernetes
傻傻虎虎3 天前
【Docker】常用帮忙、镜像、容器、其他命令合集(2)
运维·docker·容器
是小崔啊3 天前
叩丁狼K8s - 概念篇
云原生·容器·kubernetes