CKA 41

CKA 예제 리마인더 - 11. Static PODs

클러스터에 있는 모든 네임스페이스에 존재하는 고정 파드 갯수를 찾으세요 나의 답안 ) cd /etc/kubernetes/manifest 에 가서 yaml 파일 갯수 확인 ( 모든 static pod가 같은 노드에 있을 때만 사용해야함 )Solution ) kubectl get po  -n= -o yaml 을 했을 때 ownerreference를 참조한다   ownerReferences:   - apiVersion: v1     controller: true     kind: Node     name: controlplane 이렇게 onwer의 kind가 Node라면 static Pod로 분류된다 새로운 고정 파드를 생성하세요 Name: static-busybox Image: busybox command:..

DevOps 2024.10.31

CKA 예제 리마인더 - 10. DaemonSets

실행되고 있는 DaemonSets 갯수를 찾으세요 나의 답안 ) kubectl get daemonset -A --no-headers | wc -l Solution ) 나의 답안과 같음 다른 네임스페이스에 있는 특정 DaemonSet가 생성한 파드가 몇 개 인지 찾으세요 나의 답안 ) kubectl describe daemonset  -n= Solution ) kubectl describe daemonset  -n= 도 가능하지만 사실 kubectl get daemonset  만으로 파드의 desire 값, current, ready등등 지표가 출력된다 DaemonSet을 생성하세요Name: elasticsearch Namespace: kube-system Image: registry.k8s.io/flue..

DevOps 2024.10.30

CKA 예제 리마인더 - 9. Resource Limits

파드의 메모리 limits를 재설정해서 실행하세요 나의 답안 ) 실행중인 파드의 Manifest를 가져옴 kubectl get po  -o yaml > ./.yaml kubectl delete po  spec 아래의 메모리 limit를 수정한 후 kubectl apply -f .yaml 혹은 kubectl edit po  로도 수정을 시도 했는데, error: pods is invalid A copy of your changes has been stored to "/tmp/kubectl-edit-1295947630.yaml" error: Edit cancelled, no valid changes were saved. 라는 에러메세지가 반환되었다. 파드를 삭제하고 알려준 경로의 yaml파일을 apply하..

DevOps 2024.10.30

CKA 예제 리마인더 - 8. Node Affinity

node01 노드에 color=blue 라벨을 추가하세요 나의 답안 ) kubectl label nodes node01 color=blue Solution )  나의 답안과 같음blue라는 이름의 nginx이미지를 사용하는 레플리카 3개의 디플로이를 생성하세요 나의 답안 ) blue-deploy.yaml 생성 apiVersion: apps/v1kind: Deploymentmetadata: name: blue labels: app: nginxspec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: ..

DevOps 2024.10.29

CKA 예제 리마인더 - 7. Taints and Tolerations

node01 노드에 key=spray value=mortein taint-effect=NoSchedule 테인트를 만드세요 나의 답안 ) kubectl taint nodes node01 spray=mortein:NoSchedule kubectl describe node node01 | grep Taint Solution ) 나의 답안과 같음 Taint가 적용된 파드를 만드세요 Image name: nginx Key: spray Value: mortein Effect: NoSchedule Status: Running 나의 답안 ) kubectl run bee --image=nginx --dry-run=client -o yaml > ./bee.yaml vi bee.yaml spec 아래에 toleration..

DevOps 2024.10.28

CKA 예제 리마인더 - 6. Labels and Selectors

business 라벨이 finance인 파드의 갯수를 찾으세요 나의 답안 ) kubectl get po --selector business=finance default ns에서 조회되는 파드가 없음 -> kubectl get po -A --selector business=finance 했으나 조회되는 파드가 없음 파드 하나를 집어서 라벨을 조회해보기로 함 kubectl describe po  확인해보니 라벨이 business가 아닌 bu= 로 되어있음 갯수를 찾아 정답을 찾음 kubectl get po -A --selector bu=finance | wc -l Solution ) 나의 답안과 같음 Optional ) kubectl get po -A --selector bu=finance --no-head..

DevOps 2024.10.28

CKA 예제 리마인더 - 5. Manual Scheduling

pod의 status가 pending 상태일 때, pending인 이유를 찾으세요 나의 답안 ) kubectl describe po 를 했을 때 정보가 출력되었지만 pending인 이유까지 유추하지 못함 Solution ) kubectl describe po 를 했을 때 Node 필드가 임. 이로 미루어보아 스케쥴러가 적합한 노드에 파드를 스케쥴링하지 못함 kubectl get po -n=kube-system 출력된 kube-system 네임스페이스의 파드 중, 스케쥴러가 없는것을 확인함 즉, pending이 되는 이유는 스케쥴러가 없기때문이다. nginx Pod를 node01에 스케쥴링 하세요 나의 답안 ) nginx Pod Manifest에서 spec.nodeName 필드 추가, nodeName: n..

DevOps 2024.10.27

CKA 예제 리마인더 - 4. Imperative Commands

Pod를 만드세요name = redisimage = redis:alpinelabels = "tier=db"나의 답안) kubectl run redis --image=redis:alpine --dry-run=client -o yaml > ./redis.yaml vim redis.yaml 후 labels 아래에 tier=db 추가 kubectl apply -f redis.yaml Solution ) kubectl run redis --image=redis-alpine --labels="tier=db" svc를 만드세요name = redis-serviceport = 6379나의 답안) kubectl create svc redis-service --tcp=6379:6379 --dry-run=client -o y..

DevOps 2024.10.27

CKA 예제 리마인더 - 3. NameSpace

여러 네임스페이스 중, "blue"라는 이름을 가진 파드가 있는 네임스페이스를 찾으세요 나의 답안)kubectl get po --selector name=blue --all-namespaces -o wide Solution )나의 답안과 거의 일치, 그러나 --all-namespaces 옵션은 -A (대문자)로 바꿀 수 있다kubectl get po -A 다른 네임스페이스의 svc에 접근 시 DNS ex) dev 네임스페이스의 svc db-service에 연결할 때의 도메인은 db-service.svc.cluster.local 이 된다.

DevOps 2024.10.26