guestcm.yaml
apiVersion: v1
data:username: guestpassword: "123456"
kind: ConfigMap
metadata:creationTimestamp: nullname: guestcm # configmap name
生成configmap
kubectl create -f guestcm.yaml
kubectl get configmap
kubectl get configmap guestcm -o yaml
guest-pod.yaml
apiVersion: v1
kind: Pod
metadata:name: cm-start-pod
spec:containers:- name: cm-start-containerimage: busyboxcommand: [ "/bin/sh", "-c", "echo $(EV_USERNAME) $(EV_PASSWORD)" ]env:- name: EV_USERNAMEvalueFrom:configMapKeyRef:name: guestcmkey: username- name: EV_PASSWORDvalueFrom:configMapKeyRef:name: guestcmkey: passwordrestartPolicy: Never
部署pod
kubectl create -f guest-pod.yaml
查看日志
kubectl logs -f cm-start-pod