1 개요[ | ]
- k8s configMapKeyRef.optional
- k8s env configMapKeyRef.optional
a.yaml
yaml
Copy
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: nginx
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_LEVEL
- name: SPECIAL_TYPE_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_TYPE
---
apiVersion: v1
kind: ConfigMap
metadata:
name: special-config
namespace: default
data:
SPECIAL_LEVEL: very
#SPECIAL_TYPE: charm
Console
Copy
$ kubectl apply -f a.yaml
pod/dapi-test-pod created
configmap/special-config created
$ kubectl get pod dapi-test-pod
NAME READY STATUS RESTARTS AGE
dapi-test-pod 0/1 CreateContainerConfigError 0 11s
a.yaml
yaml
Copy
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: nginx
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_LEVEL
- name: SPECIAL_TYPE_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_TYPE
optional: true
---
apiVersion: v1
kind: ConfigMap
metadata:
name: special-config
namespace: default
data:
SPECIAL_LEVEL: very
#SPECIAL_TYPE: charm
Console
Copy
$ kubectl delete -f a.yaml; kubectl apply -f a.yaml
pod "dapi-test-pod" deleted
configmap "special-config" deleted
pod/dapi-test-pod created
configmap/special-config created
$ kubectl get pod dapi-test-pod
NAME READY STATUS RESTARTS AGE
dapi-test-pod 1/1 Running 0 46s
$ kubectl exec dapi-test-pod -- env | grep SPECIAL
SPECIAL_LEVEL_KEY=very
2 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.