본문 바로가기
CKA

CKA - kodekloud Practice Test - PODs & ReplicaSets & Deployments & Namespaces

by 2won2 2025. 6. 22.

PODs

  • Pod 갯수
    • kubectl get pods
  • nginx 이미지를 사용해 pod(pod name = nginx) 생성
    • kubectl run niginx --image=nginx
  • pod 상세 내용
    • kubectl describe pod name
  • pod 펼쳐보기
    • kubectl get pods -o wide
  • pod 삭제
    • kubectl delete pod name
  • yaml 파일로 pod 생성
    • kubectl run redis --image=redis123 --dry-run=client -o yaml > redis123.yaml
    • kubectl create -f redis123.yaml
  • yaml 파일 수정 후 적용
    • kubectl edit pod redis OR vi redis.yaml
    • kubectl apply -f redis123.yaml



ReplicaSets

  • replicaset 갯수 확인
    • kubectl get rs
  • root 디렉토리에 yaml파일 생성
    • yaml파일이 정확한지 확인 (v1 X , apps/v1 O)
    • kubectl create -f /root/yamlfile.yaml
  • rs 삭제
    • kubectl delete rs name
  • pod 전체 삭제
    • kubectl delete pods --all
  • scale up
    • kubectl edit rs name
    • kubectl scale rs name --replicas=5

 

 

Deployments

  • deployment 조회
    • kubectl get deploy
  • deployment 생성
    • kubectl create deploy httpd-frontend --image=httpd:2.4-alpine --replicas=3 --dry-run=client -o yaml > deploy.yaml
    • kubectl create -f deploy.yaml



Namespaces

  • namespace 조회
    • kubectl get ns
    • kubectl get namespace(s)
  • namespace에 존재하는 pod 갯수
    • kubectl get pods --namespace=namespacename
    • kubectl get pods --namespace namespacename
    • kubectl get pods -n research
  • 특정 namespace에 pod 생성
    • kubectl run redis --image=redis -n=finance
  • 특정 pod의 namespace 검색
    • kubectl get pods --all-namespaces | grep blue
    • kubectl get pods --all-namespaces
  • dev 네임스페이스에 있는 db-service 라는 서비스에 접근하려면, 어떤 DNS 주소를 써야 하는가?
    • db-service.dev.svc.cluster.local