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

创建好configmap

k8s pod通过volume挂载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

k8s pod通过volume挂载configmap

 

 进到容器里面,查看/ect/config目录,查看挂载的configmap数据

k8s pod通过volume挂载configmap

 

 查看configmap数据

k8s pod通过volume挂载configmap

 

相关文章:

  • 2021-10-12
  • 2022-01-27
  • 2021-10-14
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-10-27
  • 2021-10-18
猜你喜欢
  • 2022-01-31
  • 2022-12-23
  • 2021-04-26
  • 2022-12-23
  • 2021-12-20
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案