k8s

CKA 준비 (6) Deployment & Pod Scale

Joon0464 2022. 5. 30. 20:38

이 게시물은 아래 강의를 참고 하였습니다.
참고 강의 https://www.youtube.com/watch?v=KdATmTulf7s&list=PLApuRlvrZKojqx9-wIvWP3MPtgy2B372f&index=1 

 

 

 

 

문제 1) Pod scale out

 

작업 클러스터 : k8s

  • Expand the number of running Pods in "eshop-order" to 5
    • namespace : devops
    • deployment : eshop-order

답안) 

$ kubectl config use-context k8s

 

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#scale 에서 Scale 명령어 확인

 

$ sudo kubectl scale deployment eshop-order -n devops --replicas=5

Scale 결과 확인

 

문제 2) Deployment 생성하고 Scailing 하기

  • Create a deployment as follows:
  • Task:
    • name : webserver
    • 2 replicas
    • label : app_env_stage=dev
    • container name : webserver
    • container image : nginx:1.14
  • Scale Out Depolyment
    • Scale the deployment webserver to 3 pods

답안)

1) deployment 생성

$ sudo kubectl create deployment webserver --image=nginx:1.14 --replicas=2 --dry-run=client -o yaml > webserver.yaml
$ sudo vi webserver.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webserver
spec:
  replicas: 2
  selector:
    matchLabels:
      app_env_stage: dev
  template:
    metadata:
      labels:
        app_env_stage: dev
    spec:
      containers:
      - image: nginx:1.14
        name: webserver
$ sudo kubectl apply -f webserver.yaml

결과 확인

2) Scale out

$ sudo kubectl scale deployment webserver --replicas=3

Scale out 된 결과 확인