본문 바로가기

⭐ Kubernetes & EKS/오토스케일링 (HPA, CA)

쿠버네티스 애플리케이션 동작구조와 HTTP 서버 스케일링 테스트

# 쿠버네티스 애플리케이션과 서비스 동작 구조

- pod는 컨테이너를 패키징하고있는 컨테이너 바구니같은 개념이다.

- pod은 ip를 할당받으며, pod 서로가 통신이 가능하다.

# pod 정보확인

kubectl get pod

# HTTP 서버 스케일링과 테스트

# replicas 수를 늘려 스케일 아웃 실행

kubectl scale deploy http-go --replicas=3

kubectl get pod

- 해당 pod이 3개로 증가한것을 확인 할 수 있다.

# 로드밸런싱 통신 확인하기

kubectl get svc

# 내부ip인 CLUSTER-IP를 활용하여 요청

kubectl get pod 를 실행하여 NAME을 확인

kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s

위에 명령어를 연속으로 실행하면 로드밸런싱이 잘 동작 하는지 확인 할 수 있다.

may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-lnlfq
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-lnlfq
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-cgw5m
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-lnlfq
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-cgw5m
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-lnlfq
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-cgw5m
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-cgw5m
may9noy@cloudshell:~ (may9noy-gke-test-20210904)$ kubectl exec http-go-587945f5c4-cgw5m -- curl 10.112.8.131:8080 -s
Welcome! http-go-587945f5c4-lnlfq

- 실행되는 노드의 위치가 뀌어 출력되므로 실행이 될때마다 LB가 되고 있다고 생각하면 된다.

# pod의 배치 노드를 확인하기

kubectl get pod -o wide

- 노드를 보면 서로 다른 노드에 배치된 것을 확인 할 수 있다.

- 노드 기준으로 로드밸런싱 된다.

# pod의 자세한 정보를 확인하기

kubectl describe pod [NAME] 

kubectl describe pod http-go-587945f5c4-cgw5m

- events 는 describe 명령에서만 확인이 가능하다.