728x90
반응형
# 쿠버네티스 애플리케이션과 서비스 동작 구조
- pod는 컨테이너를 패키징하고있는 컨테이너 바구니같은 개념이다.
- pod은 ip를 할당받으며, pod 서로가 통신이 가능하다.
# pod 정보확인
kubectl get pod
# 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
# EKS
kubectl exec http-go-5bb9c4b5-4gczx -- curl acccca471d55b411c856821970f7e81a-1523375836.ap-northeast-2.elb.amazonaws.com:8080 -s
# 연속으로 명령어를 실행해보면 노드명이 바뀌면서 실행되는것을 확인할 수 있다. 로드밸런싱이 정상적으로 되고 있다는 뜻이다.
ec2-user:~/environment $ kubectl exec http-go-5bb9c4b5-4gczx -- curl acccca471d55b411c856821970f7e81a-1523375836.ap-northeast-2.elb.amazonaws.com:8080 -s
Welcome! http-go-5bb9c4b5-b2f77
ec2-user:~/environment $ kubectl exec http-go-5bb9c4b5-4gczx -- curl acccca471d55b411c856821970f7e81a-1523375836.ap-northeast-2.elb.amazonaws.com:8080 -s
Welcome! http-go-5bb9c4b5-4gczx
ec2-user:~/environment $ kubectl exec http-go-5bb9c4b5-4gczx -- curl acccca471d55b411c856821970f7e81a-1523375836.ap-northeast-2.elb.amazonaws.com:8080 -s
Welcome! http-go-5bb9c4b5-b8lxf
ec2-user:~/environment $
# pod의 배치 노드를 확인하기
kubectl get pod -o wide
- 노드를 보면 서로 다른 노드에 배치된 것을 확인 할 수 있다.
ec2-user:~/environment $ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
http-go-5bb9c4b5-4gczx 1/1 Running 0 74m 192.168.11.203 ip-192-168-19-0.ap-northeast-2.compute.internal <none> <none>
http-go-5bb9c4b5-b2f77 1/1 Running 0 7m35s 192.168.36.233 ip-192-168-39-178.ap-northeast-2.compute.internal <none> <none>
http-go-5bb9c4b5-b8lxf 1/1 Running 0 7m35s 192.168.6.116 ip-192-168-19-0.ap-northeast-2.compute.internal <none> <none>
ec2-user:~/environment $ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-192-168-19-0.ap-northeast-2.compute.internal Ready <none> 16m v1.17.17-eks-ac51f2
ip-192-168-39-178.ap-northeast-2.compute.internal Ready <none> 16m v1.17.17-eks-ac51f2
ec2-user:~/environment $
- 노드 기준으로 로드밸런싱 된다.
# pod의 자세한 정보를 확인하기
kubectl describe pod [NAME]
kubectl describe pod http-go-587945f5c4-cgw5m
- events 는 describe 명령에서만 확인이 가능하다.
ec2-user:~/environment $ kubectl describe pod http-go-5bb9c4b5-4gczx
Name: http-go-5bb9c4b5-4gczx
Namespace: default
Priority: 0
Node: ip-192-168-19-0.ap-northeast-2.compute.internal/192.168.19.0
Start Time: Tue, 05 Oct 2021 11:13:16 +0000
Labels: app=http-go
pod-template-hash=5bb9c4b5
Annotations: kubernetes.io/psp: eks.privileged
Status: Running
IP: 192.168.11.203
IPs:
IP: 192.168.11.203
Controlled By: ReplicaSet/http-go-5bb9c4b5
Containers:
http-go:
Container ID: docker://e7d0e00aee6dde22a46e017d617a452772295be2929d297179c1f027485cfe46
Image: may9noy/http-go
Image ID: docker-pullable://may9noy/http-go@sha256:ad12c63bcd5e1ceae4d896767079a65c6e34521a7f8740480068eb9a9ca9f527
Port: <none>
Host Port: <none>
State: Running
Started: Tue, 05 Oct 2021 11:13:35 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-czdll (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-czdll:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-czdll
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 20m (x37 over 72m) default-scheduler no nodes available to schedule pods
Normal Pulling 16m kubelet, ip-192-168-19-0.ap-northeast-2.compute.internal Pulling image "may9noy/http-go"
Normal Pulled 16m kubelet, ip-192-168-19-0.ap-northeast-2.compute.internal Successfully pulled image "may9noy/http-go"
Normal Created 16m kubelet, ip-192-168-19-0.ap-northeast-2.compute.internal Created container http-go
Normal Started 16m kubelet, ip-192-168-19-0.ap-northeast-2.compute.internal Started container http-go
ec2-user:~/environment $
# 스케일 아웃한 pod를 스케일 인 하여 줄여보자
ec2-user:~/environment $ kubectl scale deploy http-go --replicas=1
deployment.apps/http-go scaled
ec2-user:~/environment $ kubectl get pod
NAME READY STATUS RESTARTS AGE
http-go-5bb9c4b5-4gczx 0/1 Terminating 0 77m
http-go-5bb9c4b5-b2f77 1/1 Running 0 9m59s
http-go-5bb9c4b5-b8lxf 0/1 Terminating 0 9m59s
- 1개의 pod 만 실행중인것을 확인 할 수 있다.
ec2-user:~/environment $ kubectl get pod
NAME READY STATUS RESTARTS AGE
http-go-5bb9c4b5-b2f77 1/1 Running 0 10m
ec2-user:~/environment $
- 번외로, replicas를 0개로 하면 어떻게 될까? pod 정보가 조회가 안되는것을 확인 할 수 있다.|
ec2-user:~/environment $ kubectl scale deploy http-go --replicas=0
deployment.apps/http-go scaled
ec2-user:~/environment $ kubectl get pod
No resources found in default namespace.
ec2-user:~/environment $
- 다시 3개로 늘려보자 > 정상적으로 늘어난것을 확인 할 수 있다.
ec2-user:~/environment $ kubectl get pod
NAME READY STATUS RESTARTS AGE
http-go-5bb9c4b5-2dnn4 1/1 Running 0 6s
http-go-5bb9c4b5-7qll5 1/1 Running 0 6s
http-go-5bb9c4b5-qc268 1/1 Running 0 6s
ec2-user:~/environment $
- 여기까지 EKS 를 이용하여 pod의 스케일 아웃과 스케일 인에 대해서 알아보았다.
728x90
반응형
'⭐ Kubernetes & EKS > EKS' 카테고리의 다른 글
EKS Pod 디스크립터 작성 (0) | 2021.10.05 |
---|---|
EKS에서 Jenkins 을 실행하기 (feat.스케일 인 아웃) (0) | 2021.10.05 |
Docker 컨테이너를 EKS 에서 실행하기 (0) | 2021.10.05 |
EKS 버전 업데이트 (0) | 2021.10.05 |
EKS 오토 스케일링 시 타입설정 (0) | 2021.10.04 |