파드의 Env를 변경하세요
kubectl get po webapp-color -o yaml > ./webapp-color.yaml
로 yaml 파일을 내려받고 Env 수정 후 kubectl replace --force -f webapp-color.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-10-31T16:25:14Z"
labels:
name: webapp-color
name: webapp-color
namespace: default
resourceVersion: "827"
uid: 50395f87-2ce8-4f41-9f1c-6a4179059fbd
spec:
containers:
- env:
- name: APP_COLOR
value: pink
image: kodekloud/webapp-color
imagePullPolicy: Always
name: webapp-color
spec.containers.env 수정
or
kubectl set env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N [options]
명령어를 사용해서
kubectl set env po/webapp-color APP_COLOR=green
Solution )
kubectl edit po <pod> 명령어로 수정 후 저장된 tmp 파일을 사용해서 replace
현재 네임스페이스에 존재하는 configmap 갯수를 찾으세요
kubectl get configmap
특정 configmap을 inspect 하세요
kubectl describe configmap <configmap>
새로운 컨피그맵을 만드세요
ConfigMap Name: webapp-config-map
Data: APP_COLOR=darkblue
Data: APP_OTHER=disregard
kubectl create configmap webapp-config-map \
> --from-literal=APP_COLOR=darkblue \
> --from-literal=APP_OTHER=disregard \
> --dry-run=client -o yaml > ./webapp-config-map.yaml
생성된 yaml
apiVersion: v1
data:
APP_COLOR: darkblue
APP_OTHER: disregard
kind: ConfigMap
metadata:
creationTimestamp: null
name: webapp-config-map
kubectl apply -f webapp-config-map.yaml
파드에 새로 생성한 컨피그맵을 적용하세요
Pod Name: webapp-color
ConfigMap Name: webapp-config-map
yaml 파일 수정 후 replace
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-10-31T16:25:14Z"
labels:
name: webapp-color
name: webapp-color
namespace: default
resourceVersion: "827"
uid: 50395f87-2ce8-4f41-9f1c-6a4179059fbd
spec:
containers:
#- env:
# - name: APP_COLOR
# value: green
- env:
- name: webapp-config-map
valueFrom:
configMapKeyRef:
name: webapp-config-map
key: APP_COLOR
image: kodekloud/webapp-color
imagePullPolicy: Always
name: webapp-color
Solution )
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-10-31T16:25:14Z"
labels:
name: webapp-color
name: webapp-color
namespace: default
resourceVersion: "827"
uid: 50395f87-2ce8-4f41-9f1c-6a4179059fbd
spec:
containers:
- envFrom:
configMapRef:
name: webapp-config-map
image: kodekloud/webapp-color
imagePullPolicy: Always
name: webapp-color