k8s pod通過volume掛載configmap


參考官網:https://kubernetes.io/zh/docs/tasks/configure-pod-container/configure-pod-configmap/

創建好configmap

 

 定義好deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        volumeMounts:
        - name: config-volume
          mountPath: /etc/config
      volumes:
        - name: config-volume
          configMap: 
            name: special-config

創建deployment 

kubectl create -f deployment.yaml

我把鏡像換成了nginx

 

 進到容器里面,查看/ect/config目錄,查看掛載的configmap數據

 

 查看configmap數據

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM