[AEWS] #7์ฃผ์ฐจ Fargate ๋ฐฐํฌ ์‹ค์Šต

25๋…„๋„ AWS EKS Hands-on Study ์Šคํ„ฐ๋”” ์ •๋ฆฌ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

 

Fargate๋ž€

AWS Fargate๋Š” ์ปจํ…Œ์ด๋„ˆ ๊ธฐ๋ฐ˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์„œ๋ฒ„๋ฆฌ์Šค ์ปดํ“จํŒ… ์—”์ง„์œผ๋กœ ์‚ฌ์šฉ์ž๋Š” ์„œ๋ฒ„๋‚˜ ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์ง์ ‘ ํ”„๋กœ๋น„์ €๋‹ํ•˜๊ฑฐ๋‚˜ ๊ด€๋ฆฌํ•  ํ•„์š” ์—†์ด ์ปจํ…Œ์ด๋„ˆ๋งŒ ์ •์˜ํ•˜๊ณ  ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•œ๋‹ค.

๊ธฐ์กด Amazon ECS ๋˜๋Š” Amazon EKS์—์„œ ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์šด์˜ํ•˜๊ธฐ ์œ„ํ•ด EC2 ์ธ์Šคํ„ด์Šค๋ฅผ ์ง์ ‘ ๊ตฌ์„ฑํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋˜ ๋ฐฉ์‹๊ณผ ๋‹ฌ๋ฆฌ Fargate๋Š” ์ด๋Ÿฌํ•œ ์ธํ”„๋ผ๋ฅผ ์™„์ „ํžˆ ์ถ”์ƒํ™”ํ•˜๊ณ  ์ปจํ…Œ์ด๋„ˆ ๋‹จ์œ„์˜ ๋ฆฌ์†Œ์Šค ํ• ๋‹น๊ณผ ์‹คํ–‰์„ ์ œ๊ณตํ•œ๋‹ค.

 

Fargate๋Š” ์ปจํ…Œ์ด๋„ˆ ํ•˜๋‚˜ํ•˜๋‚˜๋ฅผ ๋…๋ฆฝ๋œ ๊ฒฝ๋Ÿ‰ ๊ฐ€์ƒ ๋จธ์‹ ์—์„œ ์‹คํ–‰๋˜๋„๋ก ์„ค๊ณ„๋˜์–ด ์žˆ๋Š”๋ฐ AWS์—์„œ "Firecracker"๋ผ๋Š” ์ž์ฒด ํ•˜์ดํผ๋ฐ”์ด์ € ๊ธฐ์ˆ ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€์œผ๋ฉฐ ์ด ๊ธฐ์ˆ  ๋•๋ถ„์— ๊ฐ Fargate ์ž‘์—…(Pod ๋˜๋Š” Task)์€ ์™„์ „ํžˆ ๋ถ„๋ฆฌ๋œ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋œ๋‹ค.

์ด๋Ÿฌํ•œ ๊ตฌ์กฐ๋Š” ๋ฉ€ํ‹ฐ ํ…Œ๋„Œ์‹œ ํ™˜๊ฒฝ์—์„œ๋„ ๋ณด์•ˆ ๋ฆฌ์Šคํฌ๋ฅผ ์ค„์ด๋Š” ๋ฐ ์œ ๋ฆฌํ•˜๋ฉฐ ๋™์‹œ์— ๋ฆฌ์†Œ์Šค๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ ๋ถ€ํŠธ ํƒ€์ž„ ์ธก๋ฉด์—์„œ๋„ ๋›ฐ์–ด๋‚œ ์„ฑ๋Šฅ์„ ํ™•๋ณดํ•  ์ˆ˜ ์žˆ๋‹ค.

Fargate์˜ ์žฅ์ 

Fargate๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๊ฐ€์žฅ ํฐ ์ด์  ์ค‘ ํ•˜๋‚˜๋Š” ์˜คํ† ์Šค์ผ€์ผ๋ง๊ณผ ๋น„์šฉ ์ตœ์ ํ™” ์ธก๋ฉด์ด๋‹ค.

์‚ฌ์šฉ์ž๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ํ•„์š”ํ•œ ๋ฆฌ์†Œ์Šค(cpu, memory)๋งŒ ์ •์˜ํ•˜๋ฉด ๋˜๊ณ  ์‹ค์ œ ์ปดํ“จํŒ… ์ž์›์€ Fargate๊ฐ€ ๊ทธ์— ๋งž๊ฒŒ ํ• ๋‹นํ•œ๋‹ค. ์ •ํ•ด์ง„ ๋ฆฌ์†Œ์Šค๋ฅผ ์ดˆ๊ณผํ•˜๊ฑฐ๋‚˜ ์œ ํœด ์ธ์Šคํ„ด์Šค์— ๋Œ€ํ•œ ๋น„์šฉ์„ ๊ณ ๋ฏผํ•  ํ•„์š”๊ฐ€ ์—†์œผ๋ฉฐ ์‚ฌ์šฉํ•œ ๋งŒํผ๋งŒ ๊ณผ๊ธˆ๋˜๋Š” ๊ตฌ์กฐ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ŠคํŒŸ ์ธ์Šคํ„ด์Šค๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋”๋ผ๋„ ๋น„์šฉ ์˜ˆ์ธก์ด ์šฉ์ดํ•˜๋‹ค. ํŠนํžˆ, ์›Œํฌ๋กœ๋“œ๊ฐ€ ์ผ์ •ํ•˜์ง€ ์•Š๊ณ  ์ผ์‹œ์ ์œผ๋กœ ํญ์ฆํ•˜๊ฑฐ๋‚˜ ๊ฐ‘์ž‘์Šค๋Ÿฝ๊ฒŒ ๊ฐ์†Œํ•˜๋Š” ํ™˜๊ฒฝ์—์„œ Fargate๊ฐ€ ์ ํ•ฉํ•œ ์•„ํ‚คํ…์ฒ˜๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

EKS์—์„œ Fargate๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ์ผ๋ถ€ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋‚˜ ํŠน์ • ๋ ˆ์ด๋ธ” ์กฐ๊ฑด์— ๋งž๋Š” ํŒŒ๋“œ๋“ค๋งŒ Fargate์—์„œ ์‹คํ–‰๋˜๋„๋ก ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด Fargate Profile์„ ์ •์˜ํ•˜๋ฉฐ ์ด ์•ˆ์—์„œ ์–ด๋–ค ๋„ค์ž„์ŠคํŽ˜์ด์Šค์™€ ์–ด๋–ค ๋ ˆ์ด๋ธ” ์…€๋ ‰ํ„ฐ๋ฅผ ๊ฐ€์ง„ ํŒŒ๋“œ๊ฐ€ Fargate์—์„œ ์‹คํ–‰๋ ์ง€๋ฅผ ๋ช…์‹œํ•œ๋‹ค.

Fargate ํŒŒ๋“œ๋Š” ์ผ๋ฐ˜ EC2 ๋…ธ๋“œ์—์„œ ๋™์ž‘ํ•˜๋Š” ํŒŒ๋“œ์™€ ๋‹ฌ๋ฆฌ Pod๋‹น 1๊ฐœ์˜ ๊ฒฝ๋Ÿ‰ VM์ด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜๊ณ , ๊ณ ์œ ํ•œ ENI(Elastic Network Interface)๊ฐ€ ํ• ๋‹น๋œ๋‹ค. ์ด ๊ตฌ์กฐ๋Š” Pod ๊ฐ„ ๋„คํŠธ์›Œํฌ ๊ฒฉ๋ฆฌ๋ฅผ ๊ฐ•ํ™”ํ•˜๋ฉฐ IP ์ถฉ๋Œ ์—†์ด ๋Œ€๊ทœ๋ชจ ๋ถ„์‚ฐ ํ™˜๊ฒฝ์—์„œ ์•ˆ์ •์ ์ธ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•ด์ค€๋‹ค.

 

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ฃผ์š” ์›Œํฌ๋กœ๋“œ๋ฅผ ์„œ๋ฒ„๋ฆฌ์Šค ํ™˜๊ฒฝ์œผ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜๊ณ ์ž ํ•  ๋•Œ Fargate๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. AWS Fargate๋Š” ์ธํ”„๋ผ์˜ ๋ณต์žก์„ฑ์„ ์ค„์ด๊ณ  ์ปจํ…Œ์ด๋„ˆ ์ค‘์‹ฌ์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์šด์˜์„ ๋‹จ์ˆœํ™”ํ•˜๋Š” ๋ฐ ์ตœ์ ํ™”๋œ ์„œ๋น„์Šค๋‹ค.

๋ณด์•ˆ, ์ž๋™ํ™”, ํ™•์žฅ์„ฑ, ๊ทธ๋ฆฌ๊ณ  ๋น„์šฉ ํšจ์œจ์„ฑ ์ธก๋ฉด์—์„œ ๋›ฐ์–ด๋‚œ ์ด์ ์„ ์ œ๊ณตํ•˜๋ฉฐ ํŠนํžˆ DevOps๋‚˜ MLOps ํ™˜๊ฒฝ์ฒ˜๋Ÿผ ๋น ๋ฅธ ๋ฐฐํฌ์™€ ๋ฏผ์ฒฉ์„ฑ์ด ์ค‘์š”ํ•œ ๊ฒฝ์šฐ ํ™œ์šฉ๋„๊ฐ€ ๋”์šฑ ๋†’์•„์ง„๋‹ค.

 

Fargate ์‚ฌ์šฉ ์‹œ ์ฃผ์˜ ์‚ฌํ•ญ

ํŒŒ๋“œ๋Š” ๋ฐ˜๋“œ์‹œ ์ง€์ •๋œ ๋ฆฌ์†Œ์Šค(cpu, memory)๋ฅผ ๋ช…ํ™•ํžˆ ์„ ์–ธํ•ด์•ผ ํ•˜๋ฉฐ ๋ณผ๋ฅจ ๋งˆ์šดํŠธ ๋ฐฉ์‹์— ์ œํ•œ์ด ์žˆ์–ด EFS ์™ธ์˜ ํผ์‹œ์Šคํ„ดํŠธ ๋ณผ๋ฅจ ์‚ฌ์šฉ์ด ์–ด๋ ค์šธ ์ˆ˜ ์žˆ๋‹ค.

๋…ธ๋“œ๋ณ„๋กœ ํ•˜๋‚˜์”ฉ ์‹คํ–‰๋˜์–ด์•ผ ํ•˜๋Š” ๋กœ๊ทธ ์ˆ˜์ง‘ ์—์ด์ „ํŠธ์™€ ๊ฐ™์€ ๋ฐ๋ชฌ์…‹์€ Fargate์—์„œ ์ง์ ‘ ์‹คํ–‰ํ•  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฌํ•œ ์›Œํฌ๋กœ๋“œ๋Š” EC2 ๋…ธ๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ณ‘ํ–‰ ์šด์˜ํ•ด์•ผ ํ•œ๋‹ค.  

 

Fargate ๋ฐฐํฌ ์‹ค์Šต

terraform state list
data.aws_availability_zones.available
module.vpc.aws_default_network_acl.this[0]
module.vpc.aws_default_route_table.default[0]
module.vpc.aws_default_security_group.this[0]
module.vpc.aws_eip.nat[0]
module.vpc.aws_internet_gateway.this[0]
module.vpc.aws_nat_gateway.this[0]
module.vpc.aws_route.private_nat_gateway[0]
module.vpc.aws_route.public_internet_gateway[0]
module.vpc.aws_route_table.private[0]
module.vpc.aws_route_table.public[0]
module.vpc.aws_route_table_association.private[0]
module.vpc.aws_route_table_association.private[1]
module.vpc.aws_route_table_association.private[2]
module.vpc.aws_route_table_association.public[0]
module.vpc.aws_route_table_association.public[1]
module.vpc.aws_route_table_association.public[2]
module.vpc.aws_subnet.private[0]
module.vpc.aws_subnet.private[1]
module.vpc.aws_subnet.private[2]
module.vpc.aws_subnet.public[0]
module.vpc.aws_subnet.public[1]
module.vpc.aws_subnet.public[2]
module.vpc.aws_vpc.this[0]

 

AWS EKS Fargate ๊ธฐ๋ฐ˜ ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋™์ž‘ ๋ฐฉ์‹

 

aws ec2 describe-vpcs --filter 'Name=isDefault,Values=false' --output yaml

 

k get nodes
NAME                                                      STATUS   ROLES    AGE     VERSION
fargate-ip-10-10-13-33.ap-northeast-2.compute.internal    Ready    <none>   7m34s   v1.30.8-eks-2d5f260
fargate-ip-10-10-23-214.ap-northeast-2.compute.internal   Ready    <none>   7m33s   v1.30.8-eks-2d5f260
fargate-ip-10-10-28-33.ap-northeast-2.compute.internal    Ready    <none>   7m43s   v1.30.8-eks-2d5f260
fargate-ip-10-10-32-126.ap-northeast-2.compute.internal   Ready    <none>   7m34s   v1.30.8-eks-2d5f260

 

 

4๊ฐœ์˜ ๋…ธ๋“œ๋“ค์€ Fargate ๊ธฐ๋ฐ˜ Pod๊ฐ€ ์‹คํ–‰๋  ๋•Œ ๋งˆ๋‹ค ์ƒ์„ฑ๋œ Micro VM์ด๋‹ค.

INTERNAL-IP๊ฐ€ Pod IP์™€ 1:1๋กœ ๊ฐ™์€๋ฐ Fargate์—์„œ๋Š” ํŒŒ๋“œ๋‹น 1๊ฐœ์˜ ENI๋ฅผ ํ• ๋‹นํ•˜๋ฏ€๋กœ, Pod = Node = ENI 1๊ฐœ๋กœ ๋งคํ•‘๋œ๋‹ค.

 

k get po -A -o wide
NAMESPACE     NAME                                            READY   STATUS    RESTARTS   AGE    IP             NODE                                                      NOMINATED NODE   READINESS GATES
kube-system   aws-load-balancer-controller-849b7f6bbf-5q2wv   1/1     Running   0          8m7s   10.10.13.33    fargate-ip-10-10-13-33.ap-northeast-2.compute.internal    <none>           <none>
kube-system   aws-load-balancer-controller-849b7f6bbf-zrl9f   1/1     Running   0          8m7s   10.10.28.33    fargate-ip-10-10-28-33.ap-northeast-2.compute.internal    <none>           <none>
kube-system   coredns-64696d8b7f-4dxzj                        1/1     Running   0          8m9s   10.10.23.214   fargate-ip-10-10-23-214.ap-northeast-2.compute.internal   <none>           <none>
kube-system   coredns-64696d8b7f-7nczc                        1/1     Running   0          8m9s   10.10.32.126   fargate-ip-10-10-32-126.ap-northeast-2.compute.internal   <none>           <none>

 

 

aws-load-balancer-controller ํŒŒ๋“œ์ธ๋ฐ ํŒŒ๋“œ์˜ ip๊ฐ€ ๋…ธ๋“œ์™€ ๋™์ผํ•œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

Fargate๋Š” ํŒŒ๋“œ ๋‹จ์œ„๋กœ ๊ฒฉ๋ฆฌ๋œ ๊ฒฝ๋Ÿ‰ VM์„ ์ƒ์„ฑํ•˜๋Š”๋ฐ ๊ทธ VM์ด ๋…ธ๋“œ๋กœ ๋“ฑ๋ก๋˜๋ฉฐ, ํŒŒ๋“œ IP = ๋…ธ๋“œ IP = ENI IP ๋กœ ๊ฐ™๋‹ค.

 

 

K8s API Service - Endpoints

kubectl get svc,ep
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   172.20.0.1   <none>        443/TCP   28m

NAME                   ENDPOINTS                       AGE
endpoints/kubernetes   10.0.44.211:443,10.0.7.38:443   28m

 

 

IP๋“ค์€ EKS์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ENI (Elastic Network Interface) ์— ๋ถ™์–ด์žˆ๋Š”๊ฒƒ์ด๊ณ , EKS control plane์ด ์‚ฌ์šฉํ•˜๋Š” IP์ด๋ฉฐ

Fargate ๋…ธ๋“œ๋“ค์ด๋ž‘์€ ๋ณ„๋„์˜ ๊ฒƒ์ด๋‹ค.

 

k get csr
NAME        AGE     SIGNERNAME                      REQUESTOR                                                             REQUESTEDDURATION   CONDITION
csr-54dhq   7m52s   kubernetes.io/kubelet-serving   system:node:fargate-ip-10-10-32-126.ap-northeast-2.compute.internal   <none>              Approved,Issued
csr-9596h   8m1s    kubernetes.io/kubelet-serving   system:node:fargate-ip-10-10-28-33.ap-northeast-2.compute.internal    <none>              Approved,Issued
csr-kp54q   7m53s   kubernetes.io/kubelet-serving   system:node:fargate-ip-10-10-13-33.ap-northeast-2.compute.internal    <none>              Approved,Issued
csr-zwr9v   7m51s   kubernetes.io/kubelet-serving   system:node:fargate-ip-10-10-23-214.ap-northeast-2.compute.internal   <none>              Approved,Issued

 

kubectl describe node | grep eks.amazonaws.com/compute-type
                    eks.amazonaws.com/compute-type=fargate
Taints:             eks.amazonaws.com/compute-type=fargate:NoSchedule
                    eks.amazonaws.com/compute-type=fargate
Taints:             eks.amazonaws.com/compute-type=fargate:NoSchedule
                    eks.amazonaws.com/compute-type=fargate
Taints:             eks.amazonaws.com/compute-type=fargate:NoSchedule
                    eks.amazonaws.com/compute-type=fargate
Taints:             eks.amazonaws.com/compute-type=fargate:NoSchedule

 

kubectl get pdb -n kube-system
NAME                           MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE
aws-load-balancer-controller   N/A             1                 1                     72m
coredns                        N/A             1                 1                     79m

 

kubectl get apiservices.apiregistration.k8s.io | grep eks
v1.metrics.eks.amazonaws.com           kube-system/eks-extension-metrics-api   True        80m

 

 

EKS๊ฐ€ ์ž์ฒด์ ์œผ๋กœ ์„ค์น˜ํ•œ metrics.eks.amazonaws.com API๋ฅผ ํ†ตํ•ด ํŒŒ๋“œ์™€ ๋…ธ๋“œ์˜ ๋ฉ”ํŠธ๋ฆญ์„ ์ˆ˜์ง‘ํ•œ๋‹ค.

ํ‘œ์ค€ metrics-server์™€ ๋น„์Šทํ•œ ์—ญํ• ์„ ํ•˜๋ฉฐ, kubectl top pod, kubectl top node ๊ฐ™์€ ๋ช…๋ น์–ด๊ฐ€ ๋™์ž‘ํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•˜๋‹ค.

 

EKS ํ™•์žฅ ๋ฉ”ํŠธ๋ฆญ API์˜ ๋ฆฌ์†Œ์Šค ์ •๋ณด

 

kubectl get --raw "/apis/metrics.eks.amazonaws.com/v1" | jq
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "metrics.eks.amazonaws.com/v1",
  "resources": [
    {
      "name": "kcm",
      "singularName": "kcm",
      "namespaced": false,
      "kind": "KCM",
      "verbs": []
    },
    {
      "name": "kcm/metrics",
      "singularName": "",
      "namespaced": false,
      "kind": "KCM",
      "verbs": [
        "get"
      ]
    },
    {
      "name": "ksh",
      "singularName": "ksh",
      "namespaced": false,
      "kind": "KSH",
      "verbs": []
    },
    {
      "name": "ksh/metrics",
      "singularName": "",
      "namespaced": false,
      "kind": "KSH",
      "verbs": [
        "get"
      ]
    }
  ]
}

 

์ด API๋Š” EKS ๊ด€๋ฆฌํ˜• ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ(KCM, Scheduler)์˜ ๋‚ด๋ถ€ ๋ฉ”ํŠธ๋ฆญ์„ ๋…ธ์ถœํ•˜๋Š” AWS EKS ์ „์šฉ ํ™•์žฅ ๊ธฐ๋Šฅ์ด๋‹ค.

Kube Controller Manager์˜ ์ปจํŠธ๋กค๋Ÿฌ ํ ์ง€์—ฐ, ๋ฆฌ์†Œ์Šค ๋ฆฌ์ปจ์‚ฌ์ผ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฉ”ํŠธ๋ฆญ๊ณผ, Kube Scheduler ์Šค์ผ€์ค„๋ง ์‹œ๊ฐ„, ์‹คํŒจ์œจ ๋งคํŠธ๋ฆญ์„ ์˜๋ฏธํ•œ๋‹ค.

EKS์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ด€๋ฆฌํ˜• ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ์˜ ์„ฑ๋Šฅ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ Prometheus/CloudWatch ๋“ฑ์—์„œ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ๋‹ค.

kube-system ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋‚ด ConfigMap ๋ชฉ๋ก

kubectl get cm -n kube-system
NAME                                                   DATA   AGE
amazon-vpc-cni                                         7      80m
aws-auth                                               1      76m
aws-load-balancer-controller-leader                    0      72m
coredns                                                1      80m
extension-apiserver-authentication                     6      81m
kube-apiserver-legacy-service-account-token-tracking   1      81m
kube-proxy                                             1      80m
kube-proxy-config                                      1      80m
kube-root-ca.crt                                       1      81m

kubectl get cm -n kube-system aws-auth -o yaml
data:
  mapRoles: |
    - rolearn: arn:aws:iam::<๊ณ„์ •๋ฒˆํ˜ธ>:role/app_wildcard-<๋žœ๋ค๊ฐ’>
      username: system:node:{{SessionName}}
      groups:
        - system:bootstrappers
        - system:nodes
        - system:node-proxier

    - rolearn: arn:aws:iam::<๊ณ„์ •๋ฒˆํ˜ธ>:role/kube-system-<๋žœ๋ค๊ฐ’>
      username: system:node:{{SessionName}}
      groups:
        - system:bootstrappers
        - system:nodes
        - system:node-proxier

 

 

aws-auth ConfigMap์€ EKS์˜ ํ•ต์‹ฌ ์„ค์ •์œผ๋กœ, IAM Role โ†’ K8s ์‚ฌ์šฉ์ž/๊ทธ๋ฃน ๋งคํ•‘์„ ์ •์˜ํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ ๋“ฑ๋ก๋œ IAM Role๋“ค์€ EKS Fargate Profile์— ์˜ํ•ด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋œ ๊ฒƒ์ด๊ณ  system:node, system:node-proxier ๊ถŒํ•œ์ด ์žˆ์–ด์•ผ ๋…ธ๋“œ ์—ญํ• ์„ ํ•˜๊ณ  ์„œ๋น„์Šค/์—”๋“œํฌ์ธํŠธ ๋“ฑ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

 

kubectl rbac-tool lookup system:node-proxier
  SUBJECT             | SUBJECT TYPE | SCOPE       | NAMESPACE | ROLE                | BINDING
----------------------+--------------+-------------+-----------+---------------------+-------------------------
  system:node-proxier | Group        | ClusterRole |           | system:node-proxier | eks:kube-proxy-fargate

 

 

EKS Fargate์—์„œ๋Š” kube-proxy๋Š” ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ์—์„œ ๊ด€๋ฆฌ๋˜๋Š” ํ˜•ํƒœ๋ผ ์ง์ ‘ ํŒŒ๋“œ๋กœ ๋„์šฐ์ง€ ์•Š๊ณ  ์‹ค์ œ ํŠธ๋ž˜ํ”ฝ ๋ผ์šฐํŒ…์€ AWS VPC CNI์— ์˜ํ•ด ENI ๋‹จ์—์„œ ์ฒ˜๋ฆฌ๋œ๋‹ค.

 

netshoot ๋””ํ”Œ๋กœ์ด๋จผํŠธ

kubectl create ns study-aews

 

 

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: netshoot
  namespace: study-aews
spec:
  replicas: 1
  selector:
    matchLabels:
      app: netshoot
  template:
    metadata:
      labels:
        app: netshoot
    spec:
      containers:
      - name: netshoot
        image: nicolaka/netshoot
        command: ["tail"]
        args: ["-f", "/dev/null"]
        resources: 
          requests:
            cpu: 500m
            memory: 500Mi
          limits:
            cpu: 2
            memory: 2Gi
      terminationGracePeriodSeconds: 0
EOF

 

study-aews    netshoot-84558cd8d9-l5k7d                       1/1     Running   0          72s

 

ํŒŒ๋“œ๊ฐ€ ๋œจ๊ธฐ๊นŒ์ง€ 1๋ถ„ 10์ดˆ ์ •๋„ ์†Œ์š”๋˜์—ˆ๋‹ค.

 

 netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ ip -c a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
4: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc noqueue state UP group default qlen 1000
    link/ether 6e:fe:81:61:4a:54 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.21.243/20 brd 10.10.31.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::6cfe:81ff:fe61:4a54/64 scope link
       valid_lft forever preferred_lft forever

 

AWS EKS์—์„œ Fargate ๊ธฐ๋ฐ˜์œผ๋กœ ์ƒ์„ฑ๋œ netshoot ํŒŒ๋“œ๋Š” AWS๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ฒฝ๋Ÿ‰ ๊ฐ€์ƒ๋จธ์‹ (๋งˆ์ดํฌ๋กœVM) ์œ„์—์„œ ์‹คํ–‰๋œ๋‹ค.

๋จผ์ € ๋„คํŠธ์›Œํฌ ๊ตฌ์„ฑ์„ ๋ณด๋ฉด, ip a ๋ช…๋ น ๊ฒฐ๊ณผ๋ฅผ ํ†ตํ•ด ํŒŒ๋“œ๋Š” eth0@if6 ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด 10.10.21.243/20์ด๋ผ๋Š” IP๋ฅผ ํ• ๋‹น๋ฐ›๊ณ  ์žˆ๋‹ค.

 

์ด๋Š” AWS VPC CNI ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ํ†ตํ•ด ์ž๋™์œผ๋กœ VPC ์„œ๋ธŒ๋„ท์˜ ํ”„๋ผ์ด๋น— IP ์ฃผ์†Œ๊ฐ€ ํ• ๋‹น๋œ ๊ฒƒ์œผ๋กœ, Fargate๋Š” ํŒŒ๋“œ๋‹น ENI(Elastic Network Interface)๋ฅผ ํ•˜๋‚˜์”ฉ ๋ถ€์—ฌํ•œ๋‹ค. ์ด๋กœ ์ธํ•ด ํŒŒ๋“œ๋Š” EC2 ์ธ์Šคํ„ด์Šค ์—†์ด๋„ ๊ณ ์œ ํ•œ VPC ๋„คํŠธ์›Œํฌ ์ƒ์˜ IP๋ฅผ ๊ฐ–๊ณ  ์žˆ์œผ๋ฉฐ, ๋‹ค๋ฅธ ๋ฆฌ์†Œ์Šค๋“ค๊ณผ ๋™์ผํ•œ ๋„คํŠธ์›Œํฌ ๋‚ด์—์„œ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋‹ค

 

netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ cat /etc/resolv.conf
search study-aews.svc.cluster.local svc.cluster.local cluster.local ap-northeast-2.compute.internal
nameserver 172.20.0.10
options ndots:5

 

์ด ํŒŒ๋“œ๋Š” /etc/resolv.conf ํŒŒ์ผ์„ ํ†ตํ•ด DNS ์„ค์ •์„ 172.20.0.10์œผ๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค. ์ด๋Š” ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด CoreDNS์˜ ClusterIP์ด๋ฉฐ, search ๋„๋ฉ”์ธ์œผ๋กœ study-aews.svc.cluster.local, cluster.local, ap-northeast-2.compute.internal ๋“ฑ์ด ์„ค์ •๋˜์–ด ์žˆ์–ด ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋‚ด๋ถ€ ์„œ๋น„์Šค ๋””์Šค์ปค๋ฒ„๋ฆฌ๋ฅผ ์ง€์›ํ•œ๋‹ค.

 

 netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ curl ipinfo.io/ip
15.164.5.221#

 

์‹ค์ œ๋กœ curl ipinfo.io/ip ๋ช…๋ น์„ ํ†ตํ•ด ์™ธ๋ถ€์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋Š” ํผ๋ธ”๋ฆญ IP๋Š” 15.164.5.221์ด๋ฉฐ ์ด๋Š” NAT Gateway๋ฅผ ํ†ตํ•ด ์ธํ„ฐ๋„ท์œผ๋กœ ๋‚˜๊ฐ€๋Š” ์ถœ๊ตฌ IP๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

 netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ ping -c 1 10.10.32.126
PING 10.10.32.126 (10.10.32.126) 56(84) bytes of data.
64 bytes from 10.10.32.126: icmp_seq=1 ttl=125 time=1.26 ms

--- 10.10.32.126 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.264/1.264/1.264/0.000 ms

 

๋‹ค๋ฅธ ํŒŒ๋“œ๋กœ์˜ ํ•‘ ๋˜ํ•œ ์ •์ƒ์ ์œผ๋กœ ํ†ต์‹  ํ™•์ธ์ด ๋œ๋‹ค.

 netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ df -Th
Filesystem           Type            Size      Used Available Use% Mounted on
overlay              overlay        29.4G     11.8G     16.0G  43% /
tmpfs                tmpfs          64.0M         0     64.0M   0% /dev
tmpfs                tmpfs           1.9G         0      1.9G   0% /sys/fs/cgroup
overlay              overlay        29.4G     11.8G     16.0G  43% /etc/hosts
overlay              overlay        29.4G     11.8G     16.0G  43% /dev/termination-log
/dev/nvme1n1         ext4           29.4G     11.8G     16.0G  43% /etc/hostname
/dev/nvme1n1         ext4           29.4G     11.8G     16.0G  43% /etc/resolv.conf
shm                  tmpfs          64.0M         0     64.0M   0% /dev/shm
tmpfs                tmpfs           2.0G     12.0K      2.0G   0% /run/secrets/kubernetes.io/serviceaccount
tmpfs                tmpfs           1.9G         0      1.9G   0% /proc/acpi
tmpfs                tmpfs          64.0M         0     64.0M   0% /proc/kcore
tmpfs                tmpfs          64.0M         0     64.0M   0% /proc/keys
tmpfs                tmpfs          64.0M         0     64.0M   0% /proc/latency_stats
tmpfs                tmpfs          64.0M         0     64.0M   0% /proc/timer_list
tmpfs                tmpfs          64.0M         0     64.0M   0% /proc/sched_debug
tmpfs                tmpfs           1.9G         0      1.9G   0% /sys/firmware

 netshoot-84558cd8d9-l5k7d ๎‚ฐ ~ ๎‚ฐ cat /etc/fstab
/dev/cdrom	/media/cdrom	iso9660	noauto,ro 0 0
/dev/usbdisk	/media/usb	vfat	noauto,ro 0 0

 

๋””์Šคํฌ ์ •๋ณด๋ฅผ ๋ณด๋ฉด lsblk ๋ฐ df -Th ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด / ๋ฃจํŠธ ํŒŒ์ผ ์‹œ์Šคํ…œ๊ณผ ์—ฌ๋Ÿฌ overlay ๋งˆ์šดํŠธ ํฌ์ธํŠธ๊ฐ€ ํ™•์ธ๋œ๋‹ค. Fargate์—์„œ๋Š” ๊ฐ ํŒŒ๋“œ๋ฅผ ์‹คํ–‰ํ•  ๋•Œ ๋…๋ฆฝ๋œ ephemeral storage๊ฐ€ ์ œ๊ณต๋œ๋‹ค.

 

/dev/nvme1n1 ๋””๋ฐ”์ด์Šค๊ฐ€ ๋งˆ์šดํŠธ๋˜์–ด ext4 ํฌ๋งท์œผ๋กœ ํฌ๋งท๋œ ์ƒํƒœ๋‹ค. ๋ฃจํŠธ ํŒŒ์ผ ์‹œ์Šคํ…œ ๋ฐ /etc/hostname, /etc/resolv.conf ๊ฐ™์€ ์ฃผ์š” ์„ค์ • ํŒŒ์ผ๋„ ์ด ๋””์Šคํฌ ์ƒ์— overlay ํŒŒ์ผ์‹œ์Šคํ…œ ํ˜•ํƒœ๋กœ ๋งˆ์šดํŠธ๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ด๋Š” ํŒŒ๋“œ ๊ฐ„ ๊ฒฉ๋ฆฌ์™€ ๋ณด์•ˆ ์œ ์ง€๋ฅผ ์œ„ํ•œ ๊ตฌ์กฐ๋‹ค.

 

Fargate๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ตœ๋Œ€ 20GiB์˜ ephemeral storage๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์‚ฌ์šฉ๋Ÿ‰์€ df ๋ช…๋ น์„ ํ†ตํ•ด 43%๋กœ ํ™•์ธ๋˜๋ฉฐ 11.8GiB๋ฅผ ์‚ฌ์šฉ ์ค‘์ž„์„ ๋ณด์—ฌ์ค€๋‹ค. /etc/fstab์—๋Š” cdrom, usb ๊ด€๋ จ ๋งˆ์šดํŠธ ์„ค์ •๋งŒ ์กด์žฌํ•˜๋ฉฐ ์ด๋Š” ์ปจํ…Œ์ด๋„ˆ ๊ธฐ๋ฐ˜ ์ด๋ฏธ์ง€์— ํฌํ•จ๋œ ๋””ํดํŠธ ํ•ญ๋ชฉ์ผ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค.

 

ํŒŒ๋“œ ๊ถŒํ•œ ํƒˆ์ทจ ์‹œ๋„

kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: root-shell
  namespace: study-aews
spec:
  containers:
  - command:
    - /bin/cat
    image: alpine:3
    name: root-shell
    securityContext:
      privileged: true
    tty: true
    stdin: true
    volumeMounts:
    - mountPath: /host
      name: hostroot
  hostNetwork: true
  hostPID: true
  hostIPC: true
  tolerations:
  - effect: NoSchedule
    operator: Exists
  - effect: NoExecute
    operator: Exists
  volumes:
  - hostPath:
      path: /
    name: hostroot
EOF
pod/root-shell created

 

ํŒŒ๋“œ์˜ SecurityContext ์„ค์ •์„ ์•…์šฉํ•˜์—ฌ ํ˜ธ์ŠคํŠธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋ฅผ ํƒˆ์ทจํ•  ์ˆ˜ ์žˆ๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค์ด๋‹ค.

kubectl get pod -n study-aews root-shell
NAME         READY   STATUS    RESTARTS   AGE
root-shell   0/1     Pending   0          7s

kubectl describe pod -n study-aews root-shell | grep Events: -A 10
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  12s   fargate-scheduler  Pod not supported on Fargate: fields not supported: HostNetwork, HostPID, HostIPC, volumes not supported: hostroot is of an unsupported volume Type, invalid SecurityContext fields: Privileged

 

AWS Fargate์˜ ๋ณด์•ˆ ๋ชจ๋ธ ์ƒ์˜ ์ œ์•ฝ์‚ฌํ•ญ์ด ์ž‘๋™ํ•˜์—ฌ ์œ„์™€ ๊ฐ™์€ ํŒŒ๋“œ ์‹คํ–‰์„ ์›์ฒœ์ ์œผ๋กœ ์ฐจ๋‹จํ•œ๋‹ค:

Fargate๋Š” ์ปจํ…Œ์ด๋„ˆ ๋‹จ์œ„๋กœ microVM์„ ์ƒ์„ฑํ•˜๋ฏ€๋กœ ํ˜ธ์ŠคํŠธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๊ณต์œ  ์ž์ฒด๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋ฉฐ, hostPath ํƒ€์ž…์˜ ๋ณผ๋ฅจ์€ Fargate์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

privileged: true ๊ฐ™์€ ๋ณด์•ˆ ์œ„ํ—˜ ์„ค์ •์€ Fargate์—์„œ ๊ธˆ์ง€๋œ ํ•„๋“œ๋กœ ๊ฐ„์ฃผ๋˜์–ด ์‹คํ–‰๋˜์ง€ ์•Š์œผ๋ฉฐ Fargate๋Š” ์™„์ „ํ•œ ๊ฒฉ๋ฆฌ ํ™˜๊ฒฝ์„ ์ „์ œ๋กœ ์„ค๊ณ„๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์—, ์ด๋Ÿฐ ์„ค์ •์€ ์ง€์›๋˜์ง€ ์•Š๋Š” ํ•„๋“œ๋กœ ์ฒ˜๋ฆฌ๋˜์–ด ์Šค์ผ€์ค„๋Ÿฌ ๋‹จ๊ณ„์—์„œ ๊ฑฐ๋ถ€๋œ๋‹ค.

 

AWS ALB๋กœ ๊ฒŒ์ž„ ๋””ํ”Œ๋กœ์ด๋จผํŠธ ๋ฐฐํฌ

public.ecr.aws/l6m2t8p7/docker-2048:latest ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ 2048 ๊ฒŒ์ž„์„ ์‹คํ–‰ํ•˜๋Š” ํŒŒ๋“œ 2๊ฐœ๋ฅผ ์ƒ์„ฑํ•ด๋ณธ๋‹ค.

Service ๋ฆฌ์†Œ์Šค๋Š” ์ƒ์„ฑ๋œ ํŒŒ๋“œ๋“ค์„ ๋‚ด๋ถ€์ ์œผ๋กœ ํ•˜๋‚˜์˜ ๋…ผ๋ฆฌ์  ์—”๋“œํฌ์ธํŠธ๋กœ ์—ฐ๊ฒฐ ํ›„ ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด๋ถ€์—์„œ๋Š” service-2048์ด๋ผ๋Š” ์ด๋ฆ„์„ ํ†ตํ•ด ํฌํŠธ 80์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ์ „๋‹ฌ๋ฐ›๊ฒŒ ํ•˜๊ณ , Ingress ๋ฆฌ์†Œ์Šค๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€์—์„œ 2048 ๊ฒŒ์ž„์— ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: study-aews
  name: deployment-2048
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: app-2048
  replicas: 2
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app-2048
    spec:
      containers:
      - image: public.ecr.aws/l6m2t8p7/docker-2048:latest
        imagePullPolicy: Always
        name: app-2048
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  namespace: study-aews
  name: service-2048
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: ClusterIP
  selector:
    app.kubernetes.io/name: app-2048
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: study-aews
  name: ingress-2048
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  ingressClassName: alb
  rules:
    - http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: service-2048
              port:
                number: 80
EOF

 

 

 

kubectl get ingress,svc,ep,pod -n study-aews
NAME                                     CLASS   HOSTS   ADDRESS                                                                       PORTS   AGE
ingress.networking.k8s.io/ingress-2048   alb     *       k8s-studyaew-ingress2-08c53ee834-445593286.ap-northeast-2.elb.amazonaws.com   80      56s

NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
service/service-2048   ClusterIP   172.20.222.46   <none>        80/TCP    56s

NAME                     ENDPOINTS                         AGE
endpoints/service-2048   10.10.29.119:80,10.10.37.110:80   56s

NAME                                  READY   STATUS    RESTARTS   AGE
pod/deployment-2048-85f8c7d69-hjpcb   1/1     Running   0          56s
pod/deployment-2048-85f8c7d69-k26dp   1/1     Running   0          56s
pod/netshoot-84558cd8d9-l5k7d         1/1     Running   0          13m

kubectl get targetgroupbindings -n study-aews
NAME                               SERVICE-NAME   SERVICE-PORT   TARGET-TYPE   AGE
k8s-studyaew-service2-0f181eccc6   service-2048   80             ip            72s

 

kubectl describe ingress -n study-aews ingress-2048
Name:             ingress-2048
Labels:           <none>
Namespace:        study-aews
Address:          k8s-studyaew-ingress2-08c53ee834-445593286.ap-northeast-2.elb.amazonaws.com
Ingress Class:    alb
Default backend:  <default>
Rules:
  Host        Path  Backends
  ----        ----  --------
  *
              /   service-2048:80 (10.10.37.110:80,10.10.29.119:80)
Annotations:  alb.ingress.kubernetes.io/scheme: internet-facing
              alb.ingress.kubernetes.io/target-type: ip
Events:
  Type    Reason                  Age   From     Message
  ----    ------                  ----  ----     -------
  Normal  SuccessfullyReconciled  92s   ingress  Successfully reconciled

 

kubectl get ingress -n study-aews ingress-2048 -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' | awk '{ print "Game URL = http://"$1 }'

Game URL = http://k8s-studyaew-ingress2~~.com

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2025-03-23 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 4.18.54.png

 

EKS Ingress๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ๋œ AWS ALB ํ™•์ธ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2025-03-23 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 4.23.44.png

 

์‚ฌ์šฉ์ž๊ฐ€ ALB DNS์— ์ ‘์†ํ•˜๊ฒŒ ๋˜๋ฉด ALB์˜ ๋ฆฌ์Šค๋„ˆ๊ฐ€ / ๊ฒฝ๋กœ ํŒจํ„ด ๊ทœ์น™์— ๋”ฐ๋ผ ํŠธ๋ž˜ํ”ฝ์„ ์„œ๋น„์Šค๋กœ ์ „๋‹ฌํ•œ๋‹ค.

์„œ๋น„์Šค๋Š” ๋Œ€์ƒ ๊ทธ๋ฃน์ธ ํŒŒ๋“œ๋“ค๋กœ ํŠธ๋ž˜ํ”ฝ์„ ํฌ์›Œ๋”ฉํ•˜๋ฉฐ ๋‘ ํŒŒ๋“œ๋Š” ๊ฐ๊ฐ ํฌํŠธ 80์—์„œ ์‘๋‹ตํ•˜๊ณ  ALB๋Š” ์š”์ฒญ์„ ๋ถ„์‚ฐ ์ฒ˜๋ฆฌํ•˜์—ฌ ๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋œ๋‹ค.

 

๋ฆฌ์†Œ์Šค ์‚ญ์ œ

kubectl delete ingress ingress-2048 -n study-aews
kubectl delete svc service-2048 -n study-aews && kubectl delete deploy deployment-2048 -n study-aews

 

 

 

Fargate job

cat <<EOF | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
  name: busybox1
  namespace: study-aews
spec:
  template:
    spec:
      containers:
      - name: busybox
        image: busybox
        command: ["/bin/sh", "-c", "sleep 10"]
      restartPolicy: Never
  ttlSecondsAfterFinished: 60 # <-- TTL controller
---
apiVersion: batch/v1
kind: Job
metadata:
  name: busybox2
  namespace: study-aews
spec:
  template:
    spec:
      containers:
      - name: busybox
        image: busybox
        command: ["/bin/sh", "-c", "sleep 10"]
      restartPolicy: Never
EOF
kubectl get job,pod -n study-aews
NAME                 STATUS    COMPLETIONS   DURATION   AGE
job.batch/busybox1   Running   0/1           25s        25s
job.batch/busybox2   Running   0/1           25s        25s

NAME                            READY   STATUS    RESTARTS   AGE
pod/busybox1-b86hr              0/1     Pending   0          25s
pod/busybox2-d2lpt              0/1     Pending   0          25s
pod/netshoot-84558cd8d9-l5k7d   1/1     Running   0          23m

kubectl get job,pod -n study-aews
NAME                 STATUS     COMPLETIONS   DURATION   AGE
job.batch/busybox1   Complete   1/1           58s        60s
job.batch/busybox2   Complete   1/1           56s        60s

NAME                            READY   STATUS      RESTARTS   AGE
pod/busybox1-b86hr              0/1     Completed   0          60s
pod/busybox2-d2lpt              0/1     Completed   0          60s
pod/netshoot-84558cd8d9-l5k7d   1/1     Running     0          24m

kubectl get job,pod -n study-aews
NAME                 STATUS     COMPLETIONS   DURATION   AGE
job.batch/busybox2   Complete   1/1           56s        2m48s

NAME                            READY   STATUS      RESTARTS   AGE
pod/busybox2-d2lpt              0/1     Completed   0          2m49s
pod/netshoot-84558cd8d9-l5k7d   1/1     Running     0          26m

 

 

ํŒŒ๋“œ๋ฅผ ๋ฐฐํฌํ•˜๋ฉด 60์ดˆ ์ „๊นŒ์ง€๋Š” Pending์ด์˜€๋‹ค๊ฐ€ 60์ดˆ ์ดํ›„๋ถ€ํ„ฐ๋Š” ํŒŒ๋“œ๊ฐ€ ์‹คํ–‰๋˜๋ฉฐ ์™„๋ฃŒ๋œ ์‹œ์ ๋ถ€ํ„ฐ๋Š” ์‚ญ์ œ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Fargate Logging

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sample-app
  namespace: study-aews
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:latest
        name: nginx
        ports:
        - containerPort: 80
          name: http
        resources:
          requests:
            cpu: 500m
            memory: 500Mi
          limits:
            cpu: 2
            memory: 2Gi
---
apiVersion: v1
kind: Service
metadata:
  name: sample-app
  namespace: study-aews
spec:
  selector:
    app: nginx
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  type: ClusterIP
EOF

 

kubectl get pod -n study-aews -l app=nginx
NAME                          READY   STATUS    RESTARTS   AGE
sample-app-7596c66778-7j6mb   1/1     Running   0          74s
sample-app-7596c66778-msd9z   1/1     Running   0          74s

 

kubectl exec -it deploy/netshoot -n study-aews -- curl sample-app | grep title
while true; do kubectl exec -it deploy/netshoot -n study-aews -- curl sample-app | grep title; sleep 1; echo ; date; done;
<title>Welcome to nginx!</title>
<title>Welcome to nginx!</title>

2025๋…„ 3์›” 23์ผ ์ผ์š”์ผ 04์‹œ 33๋ถ„ 42์ดˆ KST
<title>Welcome to nginx!</title>

2025๋…„ 3์›” 23์ผ ์ผ์š”์ผ 04์‹œ 33๋ถ„ 44์ดˆ KST
<title>Welcome to nginx!</title>

2025๋…„ 3์›” 23์ผ ์ผ์š”์ผ 04์‹œ 33๋ถ„ 45์ดˆ KST
<title>Welcome to nginx!</title>

 

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2025-03-23 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 4.37.08.png

 

curl ์š”์ฒญ์— ๋Œ€ํ•œ nginx ์‘๋‹ต ๋กœ๊ทธ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์‹ค์Šต ๋ฆฌ์†Œ์Šค ์ •๋ฆฌ

terraform destroy -auto-approve

 

 

+)๋งŒ์•ฝ ์„ค์ •์ด ๊ผฌ์—ฌ์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋ฉด..

 

โ•ท
โ”‚ Error: Get "http://localhost/api/v1/namespaces/app-2048": dial tcp 127.0.0.1:80: connect: connection refused
โ”‚ 
โ”‚ 
โ•ต
โ•ท
โ”‚ Error: Get "http://localhost/api/v1/namespaces/app-2048/services/app-2048": dial tcp 127.0.0.1:80: connect: connection refused
โ”‚ 
โ”‚ 
โ•ต
โ•ท
โ”‚ Error: Get "http://localhost/apis/apps/v1/namespaces/app-2048/deployments/app-2048": dial tcp 127.0.0.1:80: connect: connection refused
โ”‚ 
โ”‚ 
โ•ต
โ•ท
โ”‚ Error: Get "http://localhost/api/v1/namespaces/aws-observability": dial tcp 127.0.0.1:80: connect: connection refused
โ”‚ 
โ”‚   with module.eks_blueprints_addons.kubernetes_namespace_v1.aws_observability[0],
โ”‚   on .terraform/modules/eks_blueprints_addons/main.tf line 2569, in resource "kubernetes_namespace_v1" "aws_observability":
โ”‚ 2569: resource "kubernetes_namespace_v1" "aws_observability" {
โ”‚

 

๋‚˜์˜ ๊ฒฝ์šฐ์—๋Š” northeast-2๋กœ ์•ˆ๋˜๊ณ  west2๋กœ ์ž˜๋ชป ์ƒ์„ฑ์ด ๋˜์—ˆ์–ด์„œ kube config๊ฐ€ ๊ผฌ์—ฌ์„œ ์ด๋ ‡๊ฒŒ ์‚ญ์ œ๊ฐ€ ์ œ๋Œ€๋กœ ์•ˆ๋๋Š”๋ฐ

๋Œ€์‹œ๋ณด๋“œ์— ๋“ค์–ด๊ฐ€์„œ fargate eks ํ”„๋กœํ•„ ๋ชจ๋‘ ์‚ญ์ œํ•˜๊ณ  ํด๋Ÿฌ์Šคํ„ฐ ์‚ญ์ œ์™€ vpc ์‚ญ์ œ๋ฅผ ์ˆ˜๋™์œผ๋กœ ์ง„ํ–‰ํ•ด์ฃผ์—ˆ๋”๋‹ˆ ์ œ๋Œ€๋กœ ์‚ญ์ œ๋˜์—ˆ๋‹ค. ใ…œ_ใ…œ

๋งŒ์•ฝ ํ…Œ๋ผํผ ํŒŒ์ผ์ด ๊ผฌ์˜€์œผ๋ฉด ๋‹ค์‹œ ํด๋ก  ๋ฐ›์•„์„œ ๊นจ๋—ํ•˜๊ฒŒ ์ง„ํ–‰ํ•˜๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.