🔧
쿠버네티스(Kubernetes) CKA - KillerKoda Q4. Application Misconfigured
May 21, 2022
Q4. 애플리케이션 설정 오류
application1
네임스페이스에 디플로이먼트가 있으나, 이슈가 있어 준비(Ready)상태가 되지 않은 듯하다.
다른 리소스가 아닌 디플로이먼트(Deployment)만을 수정해 이슈를 해결하자.
팁
k -n application1 get deploy
k -n application1 logs deploy/api
k -n application1 describe deploy api
k -n application1 get cm
해결 방법
describe
명령어로 장애가 발생한 디플로이먼트를 살펴보자.
controlplane $ k describe -n application1 deployments.apps api
Name: api
Namespace: application1
CreationTimestamp: Sat, 21 May 2022 00:04:16 +0000
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=api
Replicas: 3 desired | 3 updated | 3 total | 0 available | 3 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=api
Containers:
httpd:
Image: httpd:2.4.52-alpine
Port: <none>
Host Port: <none>
Environment:
CATEGORY: <set to the key 'category' of config map 'category'> Optional: false
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available False MinimumReplicasUnavailable
Progressing True ReplicaSetUpdated
OldReplicaSets: <none>
NewReplicaSet: api-8ff4546b4 (3/3 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 30s deployment-controller Scaled up replica set api-8ff4546b4 to 3
ConfigMap 에서 문제가 발생한 듯 하다. configmap 정보를 살펴보자.
controlplane $ k get configmaps -n application1
NAME DATA AGE
configmap-category 1 3m
kube-root-ca.crt 1 3m
틀린 ConfigMap 이름을 사용한 듯 하다. 설정을 바꿔주자.
k -n application edit deploy api
spec:
template:
spec:
containers:
- env:
- name: CATEGORY
valueFrom:
conficMapKeyRef:
key: category
name: configmap-category
조금 기다리면 모든 레플리카가 ready상태인 것을 볼 수 있다.
k -n application1 get deploy api