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       
相关推荐
Connie14516 分钟前
K8s修改Kubelet过程(命令版本)
容器·kubernetes·kubelet
single-life29 分钟前
不借助docker desktop 本地windows安装nabula
windows·docker·容器·nebula
lin张34 分钟前
Kubernetes 核心网络方案与资源管理(一)
网络·容器·kubernetes
叽里咕噜怪42 分钟前
(二)k8s——kubeadm 部署 K8S 1.20.11 详细版
云原生·容器·kubernetes
沫离痕1 小时前
docker部署安装使用
云原生·eureka
迷茫运维路1 小时前
【K8S集群漏洞扫描】kube-proxy进程所监听的443端口证书过期问题分析与解决
linux·容器·kubernetes·漏洞处理
派大鑫wink1 小时前
DevOps与AIOps融合:智能化运维体系构建与实战
docker·容器·kubernetes
叫致寒吧1 小时前
K8s 组网方案
云原生·容器·kubernetes
帅猛的Shic1 小时前
Kubernetes五大核心控制器深度解析:从原理到实践
云原生·kubernetes
mr_orange_klj1 小时前
关于k8s PV的AI问答(豆包)
人工智能·容器·kubernetes