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       
相关推荐
Sweety丶╮7941 小时前
【Ansible】的介绍
云原生·ansible
眠りたいです6 小时前
基于脚手架微服务的视频点播系统-播放控制部分
c++·qt·ui·微服务·云原生·架构·播放器
Ribou6 小时前
Ubuntu 24.04.2安装k8s 1.33.4 配置cilium
linux·ubuntu·kubernetes
Mr. Cao code8 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
Dontla8 小时前
Docker多共享网络配置策略(Docker多网络、Docker networks、Docker Compose网络、Docker网络、Docker共享网络)
网络·docker·容器
Jayin_chan9 小时前
paddlex3.0.1-ocr服务化安装部署(docker)
docker·容器·ocr
ifanatic9 小时前
[每周一更]-(第159期):Go 工程师视角:容器化技术(Docker/Kubernetes)与CI/CD流程的应用场景
docker·golang·kubernetes
程序猿阿伟10 小时前
《云原生微服务治理进阶:隐性风险根除与全链路能力构建》
微服务·云原生·架构
LuiChun13 小时前
docker desktop更新到【4.45.0 】后,旧容器镜像都丢失了
docker·容器·dubbo
Sweety丶╮79413 小时前
【Ansible】实施 Ansible Playbook知识点
服务器·云原生·ansible