"K8s env configMapKeyRef.optional"의 두 판 사이의 차이

(새 문서: ==개요== ;k8s configMapKeyRef.optional {{소스헤더|a.yaml}} <syntaxhighlight lang='yaml'> apiVersion: v1 kind: Pod metadata: name: dapi-test-pod spec: containers: - name:...)
 
 
(같은 사용자의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
{{소문자}}
;k8s configMapKeyRef.optional
;k8s configMapKeyRef.optional
;k8s env configMapKeyRef.optional


{{소스헤더|a.yaml}}
{{소스헤더|a.yaml}}
<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml' line>
apiVersion: v1
apiVersion: v1
kind: Pod
kind: Pod
11번째 줄: 13번째 줄:
   containers:
   containers:
   - name: test-container
   - name: test-container
     image: k8s.gcr.io/busybox
     image: nginx
    command: [ "/bin/sh", "-c", "env" ]
     env:
     env:
     - name: SPECIAL_LEVEL_KEY
     - name: SPECIAL_LEVEL_KEY
40번째 줄: 41번째 줄:
$ kubectl get pod dapi-test-pod
$ kubectl get pod dapi-test-pod
NAME            READY  STATUS                      RESTARTS  AGE
NAME            READY  STATUS                      RESTARTS  AGE
dapi-test-pod  0/1    CreateContainerConfigError  0          97s
dapi-test-pod  0/1    CreateContainerConfigError  0          11s
</syntaxhighlight>
 
{{소스헤더|a.yaml}}
<syntaxhighlight lang='yaml' line highlight='20'>
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
</syntaxhighlight>
<syntaxhighlight lang='console'>
$ 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
</syntaxhighlight>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[k8s env]]
* [[k8s optional]]
* [[k8s optional]]
* [[k8s configMapKeyRef]]
* [[CreateContainerConfigError]]
* [[CreateContainerConfigError]]


[[분류: k8s]]
[[분류: k8s]]

2022년 1월 3일 (월) 20:26 기준 최신판

1 개요[ | ]

k8s configMapKeyRef.optional
k8s env configMapKeyRef.optional
a.yaml
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
$ 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
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
$ 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 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}