configmap示例
apiVersion: v1
kind: ConfigMap
metadata:
name: test-configmap
data:
username: "zhangsan"
password: "password"
test.conf: |
host 127.0.0.1
user root
password 123
configmap日常用法
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test
image: centos
command:
- /bin/bash
args:
- '-c'
- while true; do echo hello; sleep 1; done
env:
- name: USERNAME
valueFrom:
configMapKeyRef:
name: test-configmap
key: username
volumeMounts:
- name: config
mountPath: /config
readOnly: true
volumes:
- name: config
configMap:
name: test-configmap
items:
- key: "test.conf"
path: "test.conf"