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       
相关推荐
正经教主5 小时前
【docker基础】第一课、从零开始理解容器技术
docker·云原生·容器·eureka
正经教主8 小时前
【docker基础】0、系统学习docker之总计划
学习·docker·容器
Yang三少喜欢撸铁9 小时前
【Centos7通过kubeadm方式部署kubernetes1.30版本【一主两从】】
docker·kubernetes·container
@土豆12 小时前
基于Docker部署Squid正向代理文档
运维·docker·容器
Cyber4K12 小时前
【Kubernetes专项】K8s 包工具- Helm 入门到企业实战
云原生·容器·kubernetes
观无13 小时前
微服务下的跨域问题
微服务·云原生·架构
Chuncheng's blog14 小时前
K8S二进制部署exec unable to upgrade connection: Unauthorized异常解决方案
云原生·容器·kubernetes
FJW02081414 小时前
HAProxy+Keepalived实现Kubernetes高可用集群部署
云原生·容器·kubernetes
正经教主14 小时前
【docker基础】第二课:安装、配置与基础命令
docker·容器·eureka
倔强的胖蚂蚁15 小时前
云原生服务器存储规划与磁盘选型实施
运维·服务器·云原生