728x90
Horizontal Pod Autoscaler
--------------------
kubectl create deployment hpa-hname-pods --image=sysnet4admin/echo-hname
kubectl expose deployment hpa-hname-pods --type=LoadBalancer --name=hpa-hname-svc --port=80
# metrics
kubectl create -f https://raw.githubusercontent.com/k8s-1pro/install/main/ground/k8s-1.27/metrics-server-0.6.3/metrics-server.yaml
# 성능에 대한 평가지표
kubectl top pods
ubuntu@ip-172-31-8-104:~$ kubectl top pods
NAME CPU(cores) MEMORY(bytes)
hpa-hname-pods-9ff99b65-m2vgj 1m 1Mi
ubuntu@ip-172-31-8-104:~$ k get services
NAME TYPE CLUSTER-IP EXTERNAL-IP
PORT(S) AGE
hpa-hname-svc LoadBalancer 10.100.49.248 a39396f7d5d92442c9ead5a063ed1893-1699881858.ap-northeast-2.elb.amazonaws.com 80:32713/TCP 2m44s
kubernetes ClusterIP 10.100.0.1 <none>
443/TCP 77m
# m -> milliunits -> 1000m이면 1개의 cpu
kubectl edit deployment hpa-hname-pods
resources:
limits:
cpu: 50m
requests:
cpu: 10m
저장하고 나온 뒤
# min은 최소 파드의 수, max는 최대 파드의 수
# cpu-percent는 cpu 사용량이 50% 넘으면 autoscale 해줘
kubectl autoscale deployment hpa-hname-pods --min=1 --max=30 --cpu-percent=50
watch -n 1 kubectl top pods
ubuntu@ip-172-31-8-104:~$ k get services
NAME TYPE CLUSTER-IP EXTERNAL-IP
PORT(S) AGE
hpa-hname-svc LoadBalancer 10.100.49.248 a39396f7d5d92442c9ead5a063ed1893-1699881858.ap-northeast-2.elb.amazonaws.com 80:32713/TCP 20m
kubernetes ClusterIP 10.100.0.1 <none>
443/TCP 95m
http://3.35.207.93:32713/
728x90
'Bootcamp' 카테고리의 다른 글
[Kubernetes] Ingress 2 (0) | 2024.02.07 |
---|---|
[Kubernetes] Ingress (0) | 2024.02.06 |
[Kubernetes] K8S nodeport (1) | 2024.02.06 |
[Kubernetes] Rolling Updte (0) | 2024.02.05 |
[AWS] kubectl 연습 (0) | 2024.02.05 |