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数据
Please call me JiangYouDang!