ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
์•Œ์•„๋‘๋ฉด ์“ธ๋ชจ์žˆ๋Š” Amazon EKS
๋„คํŠธ์›Œํ‚น ํŒ ๋ช‡ ๊ฐ€์ง€
Yongho Choi
Solutions Architect
AWS
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Amazon EKS๋ฅผ ์œ„ํ•œ
๋„คํŠธ์›Œํฌ ๊ตฌ์„ฑ์€?
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
์ž ๊น! IP ๊ธฐ๋ณธ ์ง€์‹
โ€ข ์‚ฌ์„ค IP (Private IP)๋ž€ ๋ฌด์—‡์ด๊ณ  ์™œ ์“ธ๊นŒ์š”?
A ์Šคํƒ€ํŠธ์—… (192.168.0.0/16)
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
(์ฐธ๊ณ ) ์ฃผ์†Œ ๋ฒ”์œ„ CIDR ์ดํ•ดํ•˜๊ธฐ
์˜ˆ) ์‚ฌ์„ค IP ๋Œ€์—ญ (RFC1918)
192.168.0.0/16
255.255.0.0
11111111.11111111.00000000.00000000
8 8
16
http://www.subnet-calculator.com/cidr.php
Subnet
Bits(CIDR)
# of hosts
/16 65,534
/17 32,766
/18 18,382
/19 8,190
/20 4,094
/21 2,046
/22 1,022
/23 510
/24 254
/25 128
/26 62
/27 30
/28 14
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Subnet Subnet
Subnet Subnet
VPC
Availability Zone
ap-northeast-2A
Availability Zone
ap-northeast-2B
VPC ์ƒ์„ฑ : ์„œ๋ธŒ๋„ท ์ •์˜ ๋ฐ IPv4 ์ฃผ์†Œ ๋Œ€์—ญ ํ• ๋‹น
172.31.0 172.31.1
172.31.128 172.31.129
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
๊ฐ€์šฉ์˜์—ญ ๋ ˆ๋ฒจ์˜ ๊ณ ๊ฐ€์šฉ์„ฑ ๊ตฌ์„ฑ
โ€ข ์ตœ์†Œ 2๊ฐœ ์ด์ƒ์˜ ๊ฐ€์šฉ ์˜์—ญ ์‚ฌ์šฉ ๊ถŒ์žฅ
AWS Cloud
Region
Availability Zone
Amazon VPC
์ธ์Šคํ„ด์Šค 1 ์ธ์Šคํ„ด์Šค 2
Availability Zone
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
โ€ข ์ธํ„ฐ๋„ท๊ณผ ์–‘๋ฐฉํ–ฅ ํ†ต์‹ ์ด ํ•„์š”ํ•œ๊ฐ€?
Amazon VPC
๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ
/16
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
/22
0.0.0.0/0 IGW
10.1.0.0/16 Local
Destination Target
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
โ€ข ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท๋„ ์ธํ„ฐ๋„ท๊ณผ ์•„์›ƒ๋ฐ”์šด๋“œ ํ†ต์‹ ์€ ํ•„์š”ํ•˜๋‹ค๋ฉด? โ€“ NAT
๊ฒŒ์ดํŠธ์›จ์ด
Amazon VPC
๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ
/16
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
/22
0.0.0.0/0 IGW
10.1.0.0/16 Local
Destination Target
NAT ๊ฒŒ์ดํŠธ์›จ์ด
EIP: 11.22.33.44
์ธ์Šคํ„ด์Šค B
NAT GW
0.0.0.0/0
10.1.0.0/16 Local
Destination Target
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
NAT ๊ฒŒ์ดํŠธ์›จ์ด
โ€ข NAT ๊ฒŒ์ดํŠธ์›จ์ด ์ด์ค‘ํ™” ๊ตฌ์„ฑ์„ ํ†ตํ•œ ๊ฐ€์šฉ ์˜์—ญ(AZ) ์ˆ˜์ค€์˜ ๊ฐ€์šฉ์„ฑ ํ™•๋ณด
Amazon VPC
๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ
/16
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท
ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท
/22
0.0.0.0/0 IGW
10.1.0.0/16 Local
Destination Target
NAT ๊ฒŒ์ดํŠธ์›จ์ด
EIP: 11.22.33.44
์ธ์Šคํ„ด์Šค B
NAT GW
0.0.0.0/0
10.1.0.0/16 Local
Destination Target
EIP: 11.33.44.55
ยฉ 2023, Amazon Web Services, Inc. or its affiliates. 10
๊ทธ๋Ÿผ Amazon EKS์—์„œ๋Š” ์–ด๋–ป๊ฒŒ ์„œ๋ธŒ๋„ท์„ ๊ตฌ์„ฑํ•ด์•ผ ํ• ๊นŒ์š”?
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
10.0.11.0/20 10.0.12.0/20 10.0.13.0/20
AZ 1A
Amazon EKS Networking
Customer VPC 10.0.0.0/16
Amazon Managed VPC
API Server
EKS Control Plane
Data Plane
10.0.1.0/28
AZ 1B AZ 1C
10.0.2.0/28
์›Œ์ปค ๋…ธ๋“œ๋“ค์€ ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท์— ์ƒ์„ฑ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates. 12
๊ทธ๋Ÿผ ์™ธ๋ถ€์—์„œ ๋“ค์–ด์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ์„
์–ด๋–ป๊ฒŒ ๋…ธ๋“œ ๋˜๋Š” Pod๋กœ ์ „๋‹ฌํ• ๊นŒ์š”?
ยฉ 2023, Amazon Web Services, Inc. or its affiliates. 13
Pod A
Pod B
Application Load Balancer
Service A -Target Group
(์ธ์Šคํ„ด์Šค๋ชจ๋“œ)
Service B -Target Group
(์ธ์Šคํ„ด์Šค๋ชจ๋“œ)
Service C-Target Group
(IP ๋ชจ๋“œ)
Network Load Balancer
Pod A
Pod B Pod C
Pod A
Pod D
ALB Ingress
Controller
Pod C
Pod D
NP-
B NP-
A NP-
B NP-
A
Pod C
NP-
A
https://github.com/kubernetes-sigs/aws-load-balancer-controller
์ƒํƒœ ์—…๋ฐ์ดํŠธ
Watch
๊ทœ์น™: /dog ๊ทœ์น™: /cat ๊ทœ์น™: /pets
API Server
๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ Pod๋กœ ๋ถ„๋ฐฐ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
์„œ๋ธŒ๋„ท ์ž๋™ ํƒ์ƒ‰
Private Subnet
Public Subnet
Tags:
kubernetes.io/role/elb: 1
kubernetes.io/cluster/${cluster-name}: shared*
Tags:
kubernetes.io/role/internal-elb: 1
kubernetes.io/cluster/${cluster-name}: shared*
๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋Š” ์„œ๋ธŒ๋„ท์— ํ• ๋‹น๋œ ํƒœ๊ทธ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์„œ๋ธŒ๋„ท์— ๋ฐฐ์น˜๋ฉ๋‹ˆ๋‹ค.
* Not needed in versions 1.19 or later
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹
kind: Service
apiVersion: v1
metadata:
name: nginx-service
namespace: ingress-nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'trueโ€™
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
spec:
type: LoadBalancer
externalTrafficPolicy: Cluster
selector:
app: nginx
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 80
in-tree service controller ์‚ฌ์šฉ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹
Customer VPC
Data Plane
Pod Pod
NodePort
kubectl apply โ€“f
Cloud Controller Manager
EKS VPC
Control Plane
Service Controller
CLB/NLB
provisioning
Listener
Target Group
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹
kubectl apply โ€“f
NodePort: 31245
ClusterIP: 172.20.84.55
Port: 80
Service
Pod
10.0.1.101:8080
Pod
10.0.1.102:8080
Node1
31245
Node2
31245
EKS VPC
Control Plane
Cloud Controller Manager
Service Controller
CLB/NLB
provisioning
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Network Load Balancer ํ”„๋กœ๋น„์ €๋‹ ์‹œ Target ์œ ํ˜• ์ง€์ •
kind: Service
apiVersion: v1
metadata:
name: nginx-service
namespace: ingress-nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: โ€œtrueโ€
service.beta.kubernetes.io/aws-load-balancer-type: "external"
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: โ€œinstance"
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 80
AWS Load Balancer controller ์‚ฌ์šฉ
version 2.2.0 ์ด์ƒ ํ•„์š”
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ •
kubectl apply โ€“f
EKS VPC
Control Plane
Cloud Controller Manager
Service Controller
Customer VPC
Data Plane
Listener
Target Group
Pod Pod
NodePort
AWS Load
Balancer
Controller
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance
NLB provisioning
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ •
kubectl apply โ€“f
EKS VPC
Control Plane
Cloud Controller Manager
Service Controller
Customer VPC
Data Plane
Listener
Target Group
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
AWS Load
Balancer
Controller
NLB provisioning
Pod Pod
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
AWS Load
Balancer
Controller
AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ •
kubectl apply โ€“f
EKS VPC
Control Plane
Cloud Controller Manager
Service Controller
Customer VPC
Data Plane
Pod1
10.0.1.101:8080
Pod2
10.0.1.102:8080
NLB provisioning
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
EKS์—์„œ Application Load Balancer ํ”„๋กœ๋น„์ €๋‹
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: echoserver-ingress
namespace: echoserver
annotations:
alb.ingress.kubernetes.io/security-groups: sg-010fc3455c73f0a58, sg-049e999c68a291976
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: web-services
kubernetes.io/ingress.class: alb
spec:
ingressClassName: alb-ingress-class
rules:
- host: echoserver.example.com
http:
paths:
- path: /*
backend:
serviceName: echoserver-svc
servicePort: 80
kubernetes-sigs/aws-load-balancer-controller
apiVersion: networking.k8s.io/v1beta1
kind: IngressClass
metadata:
name: alb-ingress-class
spec:
controller: ingress.k8s.aws/alb
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
AWS Load
Balancer
Controller
Ingress Rule์„ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€์ƒ ์„œ๋น„์Šค๋กœ ๋ผ์šฐํŒ…
kubectl apply โ€“f
EKS VPC
Control Plane
Customer VPC
Data Plane
Listener
Target Group
Echo Pod Echo Pod
ALB provisioning
Ingress Rules
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
AWS Load
Balancer
Controller
IngressGroup์œผ๋กœ ์—ฌ๋Ÿฌ Ingress ๋ฆฌ์†Œ์Šค๋ฅผ ๋‹จ์ผ ALB๋กœ ๊ฒฐํ•ฉ
kubectl apply โ€“f
Application
Load balancer
provisioning
EKS VPC
Control Plane
Customer VPC
Data Plane
Listener
Target Group 2
App1 Pod App1 Pod
App2 Pod App2 Pod
Target Group 1
alb.ingress.kubernetes.io/group.name: web-services
Ingress Rules
(App1)
Ingress Rules
(App2)
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
DNS ์„ฑ๋Šฅ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด?
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
How DNS Works in Kubernetes
VPC
10.0.0.0/16
Route 53
Resolver
10.0.0.2
Upstream DNS
Name Server
โ€ข CoreDNS add-on์€ EKS ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด์—์„œ
๋ฆฌ์†Œ์Šค๋“ค์˜ DNS๋ช…์„ ํ™•์ธ(resolve)ํ•จ
โ€ข VPC ์šฉ ๊ธฐ๋ณธ Route 53 Resolver๋Š” VPC
๋‚ด์—์„œ ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์— ์žˆ๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ
ํ™•์ธํ•จ
โ€ข VPC ๋‚ด๋ถ€์—์„œ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋ฉด ์™ธ๋ถ€
๋ฆฌ์†Œ์Šค๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์—…์ŠคํŠธ๋ฆผ DNS
name server๋กœ ์š”์ฒญ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
How CoreDNS Works
nameserver 10.100.0.10
search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal
options ndots:5
๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
Lookup DNS Name
Is this a FQDN?
CoreDNS
ClusterIP: 10.100.0.10
Yes
No
Query with FQDN
Query with each search domain as suffix
Upstream
Resolver
getaddrinfo
syscall
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
How CoreDNS Works
nameserver 10.100.0.10
search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal
options ndots:5
Lookup aws.com.
Is this a FQDN?
CoreDNS
ClusterIP: 10.100.0.10
Yes
Query with aws.com.
์ (.)์œผ๋กœ ๋๋‚ฌ๊ธฐ ๋•Œ๋ฌธ์— FQDN์œผ๋กœ ์ฒ˜๋ฆฌ๋จ
๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
How CoreDNS Works
nameserver 10.100.0.10
search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal
options ndots:5
Lookup ABC123.gr7.us-west-2.eks.amazonaws.com
Is this a FQDN?
CoreDNS
ClusterIP: 10.100.0.10
Yes
Query with ABC123.gr7.us-west-2.eks.amazonaws.com
5๊ฐœ์˜ ์ (.)์„ ํฌํ•จ
๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
app.nodejs.svc.default.svc.cluster.local.
app.nodejs.svc.svc.cluster.local.
app.nodejs.svc.cluster.local.
app.nodejs.svc.us-west-2.compute.internal.
app.nodejs.svc.
How CoreDNS Works
nameserver 10.100.0.10
search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal
options ndots:5
No
Lookup app.nodejs.svc
Is this a FQDN?
CoreDNS
ClusterIP: 10.100.0.10
Query
with
5๊ฐœ๋ณด๋‹ค ์ (.)์ด ๋ถ€์กฑ
๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Tuning CoreDNS
spec:
containers:
- name: node
image: nodeapp:v1.0.0
resources:
requests:
cpu: "128m"
memory: "128Miโ€
dnsConfig:
options:
- name: ndots
value: 2
โ€ข ndots๋Š” ์ฃผ์†Œ๊ฐ€ FQDN์ธ์ง€ ํ™•์ธํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ
โ€ข Kubernetes ๊ธฐ๋ณธ๊ฐ’์€ 5
โ€ข Pod ์‚ฌ์–‘์—์„œ dnsConfig๋กœ ์žฌ์ •์˜๋จ
โ€ข ์›Œํฌ๋กœ๋“œ๋ณ„๋กœ ๊ฐœ๋ณ„ ์ง€์ •
โ€ข ndots = 2๋กœ ์„ค์ •
โ€ข aws.amazon.com๊ณผ ๊ฐ™์ด dot์ด 2๊ฐœ ์ด์ƒ์ธ
๊ฒฝ์šฐ suffix๋ฅผ ๋ถ™์ด์ง€ ์•Š๊ณ  FQDN์œผ๋กœ ์ธ์‹
โ€ข CoreDNS๋กœ ์ฟผ๋ฆฌ๊ฐ€ ์ค„๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€ํ•˜ ๊ฐ์†Œ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Scaling CoreDNS
โ€ข ๊ธฐ๋ณธ์ ์œผ๋กœ CoreDNS๋Š” EKS ํด๋Ÿฌ์Šคํ„ฐ์— 2๊ฐœ์˜ ๋ณต์ œ๋ณธ์œผ๋กœ ๋ฐฐํฌ๋จ
โ€ข CoreDNS ๋ฐฐํฌ๋ฅผ ์ž๋™ ํ™•์žฅํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•
โ€ข CPA(Cluster Proportional Autoscaling) : ํด๋Ÿฌ์Šคํ„ฐ ๊ทœ๋ชจ์— ๋”ฐ๋ผ ํ™•์žฅ
โ€ข HPA(Horizontal Pod Autoscaling) : Pod ๋ฆฌ์†Œ์Šค ์ž„๊ณ„์น˜ ๊ธฐ๋ฐ˜์˜ ํ™•์žฅ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
CoreDNS ๋ชจ๋‹ˆํ„ฐ๋ง
linklocal_allowance_exceeded : PPS๊ฐ€ ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ตœ๋Œ€๊ฐ’์„ ์ดˆ๊ณผํ•˜์—ฌ ์‚ญ์ œ๋œ ํŒจํ‚ท์˜ ์ˆ˜
โ€ข Link local์€ ์ธํ„ฐ๋„ท์œผ๋กœ ๋‚˜๊ฐ€์ง€ ์•Š๋Š” ๋‚ด๋ถ€ ํŒจํ‚ท์„ ์˜๋ฏธ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Node Local DNS Cache ์‚ฌ์šฉ
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.
Thank you!
ยฉ 2023, Amazon Web Services, Inc. or its affiliates.

amazon eks network some of count help tip

  • 1.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ยฉ 2023, Amazon Web Services, Inc. or its affiliates. ์•Œ์•„๋‘๋ฉด ์“ธ๋ชจ์žˆ๋Š” Amazon EKS ๋„คํŠธ์›Œํ‚น ํŒ ๋ช‡ ๊ฐ€์ง€ Yongho Choi Solutions Architect AWS
  • 2.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ยฉ 2023, Amazon Web Services, Inc. or its affiliates. Amazon EKS๋ฅผ ์œ„ํ•œ ๋„คํŠธ์›Œํฌ ๊ตฌ์„ฑ์€?
  • 3.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ์ž ๊น! IP ๊ธฐ๋ณธ ์ง€์‹ โ€ข ์‚ฌ์„ค IP (Private IP)๋ž€ ๋ฌด์—‡์ด๊ณ  ์™œ ์“ธ๊นŒ์š”? A ์Šคํƒ€ํŠธ์—… (192.168.0.0/16)
  • 4.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. (์ฐธ๊ณ ) ์ฃผ์†Œ ๋ฒ”์œ„ CIDR ์ดํ•ดํ•˜๊ธฐ ์˜ˆ) ์‚ฌ์„ค IP ๋Œ€์—ญ (RFC1918) 192.168.0.0/16 255.255.0.0 11111111.11111111.00000000.00000000 8 8 16 http://www.subnet-calculator.com/cidr.php Subnet Bits(CIDR) # of hosts /16 65,534 /17 32,766 /18 18,382 /19 8,190 /20 4,094 /21 2,046 /22 1,022 /23 510 /24 254 /25 128 /26 62 /27 30 /28 14
  • 5.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Subnet Subnet Subnet Subnet VPC Availability Zone ap-northeast-2A Availability Zone ap-northeast-2B VPC ์ƒ์„ฑ : ์„œ๋ธŒ๋„ท ์ •์˜ ๋ฐ IPv4 ์ฃผ์†Œ ๋Œ€์—ญ ํ• ๋‹น 172.31.0 172.31.1 172.31.128 172.31.129
  • 6.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ๊ฐ€์šฉ์˜์—ญ ๋ ˆ๋ฒจ์˜ ๊ณ ๊ฐ€์šฉ์„ฑ ๊ตฌ์„ฑ โ€ข ์ตœ์†Œ 2๊ฐœ ์ด์ƒ์˜ ๊ฐ€์šฉ ์˜์—ญ ์‚ฌ์šฉ ๊ถŒ์žฅ AWS Cloud Region Availability Zone Amazon VPC ์ธ์Šคํ„ด์Šค 1 ์ธ์Šคํ„ด์Šค 2 Availability Zone
  • 7.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท โ€ข ์ธํ„ฐ๋„ท๊ณผ ์–‘๋ฐฉํ–ฅ ํ†ต์‹ ์ด ํ•„์š”ํ•œ๊ฐ€? Amazon VPC ๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ /16 ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท /22 0.0.0.0/0 IGW 10.1.0.0/16 Local Destination Target
  • 8.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท โ€ข ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท๋„ ์ธํ„ฐ๋„ท๊ณผ ์•„์›ƒ๋ฐ”์šด๋“œ ํ†ต์‹ ์€ ํ•„์š”ํ•˜๋‹ค๋ฉด? โ€“ NAT ๊ฒŒ์ดํŠธ์›จ์ด Amazon VPC ๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ /16 ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท /22 0.0.0.0/0 IGW 10.1.0.0/16 Local Destination Target NAT ๊ฒŒ์ดํŠธ์›จ์ด EIP: 11.22.33.44 ์ธ์Šคํ„ด์Šค B NAT GW 0.0.0.0/0 10.1.0.0/16 Local Destination Target
  • 9.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. NAT ๊ฒŒ์ดํŠธ์›จ์ด โ€ข NAT ๊ฒŒ์ดํŠธ์›จ์ด ์ด์ค‘ํ™” ๊ตฌ์„ฑ์„ ํ†ตํ•œ ๊ฐ€์šฉ ์˜์—ญ(AZ) ์ˆ˜์ค€์˜ ๊ฐ€์šฉ์„ฑ ํ™•๋ณด Amazon VPC ๊ฐ€์šฉ ์˜์—ญ ๊ฐ€์šฉ ์˜์—ญ /16 ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ํผ๋ธ”๋ฆญ ์„œ๋ธŒ๋„ท /22 0.0.0.0/0 IGW 10.1.0.0/16 Local Destination Target NAT ๊ฒŒ์ดํŠธ์›จ์ด EIP: 11.22.33.44 ์ธ์Šคํ„ด์Šค B NAT GW 0.0.0.0/0 10.1.0.0/16 Local Destination Target EIP: 11.33.44.55
  • 10.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. 10 ๊ทธ๋Ÿผ Amazon EKS์—์„œ๋Š” ์–ด๋–ป๊ฒŒ ์„œ๋ธŒ๋„ท์„ ๊ตฌ์„ฑํ•ด์•ผ ํ• ๊นŒ์š”?
  • 11.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. 10.0.11.0/20 10.0.12.0/20 10.0.13.0/20 AZ 1A Amazon EKS Networking Customer VPC 10.0.0.0/16 Amazon Managed VPC API Server EKS Control Plane Data Plane 10.0.1.0/28 AZ 1B AZ 1C 10.0.2.0/28 ์›Œ์ปค ๋…ธ๋“œ๋“ค์€ ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท์— ์ƒ์„ฑ
  • 12.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. 12 ๊ทธ๋Ÿผ ์™ธ๋ถ€์—์„œ ๋“ค์–ด์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ์„ ์–ด๋–ป๊ฒŒ ๋…ธ๋“œ ๋˜๋Š” Pod๋กœ ์ „๋‹ฌํ• ๊นŒ์š”?
  • 13.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. 13 Pod A Pod B Application Load Balancer Service A -Target Group (์ธ์Šคํ„ด์Šค๋ชจ๋“œ) Service B -Target Group (์ธ์Šคํ„ด์Šค๋ชจ๋“œ) Service C-Target Group (IP ๋ชจ๋“œ) Network Load Balancer Pod A Pod B Pod C Pod A Pod D ALB Ingress Controller Pod C Pod D NP- B NP- A NP- B NP- A Pod C NP- A https://github.com/kubernetes-sigs/aws-load-balancer-controller ์ƒํƒœ ์—…๋ฐ์ดํŠธ Watch ๊ทœ์น™: /dog ๊ทœ์น™: /cat ๊ทœ์น™: /pets API Server ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ Pod๋กœ ๋ถ„๋ฐฐ
  • 14.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ์„œ๋ธŒ๋„ท ์ž๋™ ํƒ์ƒ‰ Private Subnet Public Subnet Tags: kubernetes.io/role/elb: 1 kubernetes.io/cluster/${cluster-name}: shared* Tags: kubernetes.io/role/internal-elb: 1 kubernetes.io/cluster/${cluster-name}: shared* ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋Š” ์„œ๋ธŒ๋„ท์— ํ• ๋‹น๋œ ํƒœ๊ทธ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์„œ๋ธŒ๋„ท์— ๋ฐฐ์น˜๋ฉ๋‹ˆ๋‹ค. * Not needed in versions 1.19 or later
  • 15.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹ kind: Service apiVersion: v1 metadata: name: nginx-service namespace: ingress-nginx annotations: service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'trueโ€™ service.beta.kubernetes.io/aws-load-balancer-type: nlb service.beta.kubernetes.io/aws-load-balancer-internal: "true" spec: type: LoadBalancer externalTrafficPolicy: Cluster selector: app: nginx ports: - name: http protocol: TCP port: 8080 targetPort: 80 in-tree service controller ์‚ฌ์šฉ
  • 16.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹ Customer VPC Data Plane Pod Pod NodePort kubectl apply โ€“f Cloud Controller Manager EKS VPC Control Plane Service Controller CLB/NLB provisioning Listener Target Group
  • 17.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. EKS์—์„œ Network Load Balancer ํ”„๋กœ๋น„์ €๋‹ kubectl apply โ€“f NodePort: 31245 ClusterIP: 172.20.84.55 Port: 80 Service Pod 10.0.1.101:8080 Pod 10.0.1.102:8080 Node1 31245 Node2 31245 EKS VPC Control Plane Cloud Controller Manager Service Controller CLB/NLB provisioning
  • 18.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Network Load Balancer ํ”„๋กœ๋น„์ €๋‹ ์‹œ Target ์œ ํ˜• ์ง€์ • kind: Service apiVersion: v1 metadata: name: nginx-service namespace: ingress-nginx annotations: service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: โ€œtrueโ€ service.beta.kubernetes.io/aws-load-balancer-type: "external" service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: โ€œinstance" service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing spec: type: LoadBalancer selector: app: nginx ports: - name: http protocol: TCP port: 8080 targetPort: 80 AWS Load Balancer controller ์‚ฌ์šฉ version 2.2.0 ์ด์ƒ ํ•„์š”
  • 19.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ • kubectl apply โ€“f EKS VPC Control Plane Cloud Controller Manager Service Controller Customer VPC Data Plane Listener Target Group Pod Pod NodePort AWS Load Balancer Controller service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance NLB provisioning
  • 20.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ • kubectl apply โ€“f EKS VPC Control Plane Cloud Controller Manager Service Controller Customer VPC Data Plane Listener Target Group service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip AWS Load Balancer Controller NLB provisioning Pod Pod
  • 21.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. AWS Load Balancer Controller AWS Load Balancer Controller์— ์˜ํ•œ Target ์œ ํ˜• ์„ค์ • kubectl apply โ€“f EKS VPC Control Plane Cloud Controller Manager Service Controller Customer VPC Data Plane Pod1 10.0.1.101:8080 Pod2 10.0.1.102:8080 NLB provisioning service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
  • 22.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. EKS์—์„œ Application Load Balancer ํ”„๋กœ๋น„์ €๋‹ apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: echoserver-ingress namespace: echoserver annotations: alb.ingress.kubernetes.io/security-groups: sg-010fc3455c73f0a58, sg-049e999c68a291976 alb.ingress.kubernetes.io/target-type: ip alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/group.name: web-services kubernetes.io/ingress.class: alb spec: ingressClassName: alb-ingress-class rules: - host: echoserver.example.com http: paths: - path: /* backend: serviceName: echoserver-svc servicePort: 80 kubernetes-sigs/aws-load-balancer-controller apiVersion: networking.k8s.io/v1beta1 kind: IngressClass metadata: name: alb-ingress-class spec: controller: ingress.k8s.aws/alb
  • 23.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. AWS Load Balancer Controller Ingress Rule์„ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€์ƒ ์„œ๋น„์Šค๋กœ ๋ผ์šฐํŒ… kubectl apply โ€“f EKS VPC Control Plane Customer VPC Data Plane Listener Target Group Echo Pod Echo Pod ALB provisioning Ingress Rules
  • 24.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. AWS Load Balancer Controller IngressGroup์œผ๋กœ ์—ฌ๋Ÿฌ Ingress ๋ฆฌ์†Œ์Šค๋ฅผ ๋‹จ์ผ ALB๋กœ ๊ฒฐํ•ฉ kubectl apply โ€“f Application Load balancer provisioning EKS VPC Control Plane Customer VPC Data Plane Listener Target Group 2 App1 Pod App1 Pod App2 Pod App2 Pod Target Group 1 alb.ingress.kubernetes.io/group.name: web-services Ingress Rules (App1) Ingress Rules (App2)
  • 25.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. ยฉ 2023, Amazon Web Services, Inc. or its affiliates. DNS ์„ฑ๋Šฅ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด?
  • 26.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. How DNS Works in Kubernetes VPC 10.0.0.0/16 Route 53 Resolver 10.0.0.2 Upstream DNS Name Server โ€ข CoreDNS add-on์€ EKS ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด์—์„œ ๋ฆฌ์†Œ์Šค๋“ค์˜ DNS๋ช…์„ ํ™•์ธ(resolve)ํ•จ โ€ข VPC ์šฉ ๊ธฐ๋ณธ Route 53 Resolver๋Š” VPC ๋‚ด์—์„œ ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์— ์žˆ๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ํ™•์ธํ•จ โ€ข VPC ๋‚ด๋ถ€์—์„œ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋ฉด ์™ธ๋ถ€ ๋ฆฌ์†Œ์Šค๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์—…์ŠคํŠธ๋ฆผ DNS name server๋กœ ์š”์ฒญ
  • 27.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. How CoreDNS Works nameserver 10.100.0.10 search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal options ndots:5 ๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ Lookup DNS Name Is this a FQDN? CoreDNS ClusterIP: 10.100.0.10 Yes No Query with FQDN Query with each search domain as suffix Upstream Resolver getaddrinfo syscall
  • 28.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. How CoreDNS Works nameserver 10.100.0.10 search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal options ndots:5 Lookup aws.com. Is this a FQDN? CoreDNS ClusterIP: 10.100.0.10 Yes Query with aws.com. ์ (.)์œผ๋กœ ๋๋‚ฌ๊ธฐ ๋•Œ๋ฌธ์— FQDN์œผ๋กœ ์ฒ˜๋ฆฌ๋จ ๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
  • 29.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. How CoreDNS Works nameserver 10.100.0.10 search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal options ndots:5 Lookup ABC123.gr7.us-west-2.eks.amazonaws.com Is this a FQDN? CoreDNS ClusterIP: 10.100.0.10 Yes Query with ABC123.gr7.us-west-2.eks.amazonaws.com 5๊ฐœ์˜ ์ (.)์„ ํฌํ•จ ๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
  • 30.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. app.nodejs.svc.default.svc.cluster.local. app.nodejs.svc.svc.cluster.local. app.nodejs.svc.cluster.local. app.nodejs.svc.us-west-2.compute.internal. app.nodejs.svc. How CoreDNS Works nameserver 10.100.0.10 search default.svc.cluster.local svc.cluster.local cluster.local us-west-2.compute.internal options ndots:5 No Lookup app.nodejs.svc Is this a FQDN? CoreDNS ClusterIP: 10.100.0.10 Query with 5๊ฐœ๋ณด๋‹ค ์ (.)์ด ๋ถ€์กฑ ๊ฐ ์ปจํ…Œ์ด๋„ˆ๋“ค์€ Kubelet์— ์˜ํ•ด /etc/resolv.conf ๋ฅผ ์ƒ์† ๋ฐ›์Œ
  • 31.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Tuning CoreDNS spec: containers: - name: node image: nodeapp:v1.0.0 resources: requests: cpu: "128m" memory: "128Miโ€ dnsConfig: options: - name: ndots value: 2 โ€ข ndots๋Š” ์ฃผ์†Œ๊ฐ€ FQDN์ธ์ง€ ํ™•์ธํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ โ€ข Kubernetes ๊ธฐ๋ณธ๊ฐ’์€ 5 โ€ข Pod ์‚ฌ์–‘์—์„œ dnsConfig๋กœ ์žฌ์ •์˜๋จ โ€ข ์›Œํฌ๋กœ๋“œ๋ณ„๋กœ ๊ฐœ๋ณ„ ์ง€์ • โ€ข ndots = 2๋กœ ์„ค์ • โ€ข aws.amazon.com๊ณผ ๊ฐ™์ด dot์ด 2๊ฐœ ์ด์ƒ์ธ ๊ฒฝ์šฐ suffix๋ฅผ ๋ถ™์ด์ง€ ์•Š๊ณ  FQDN์œผ๋กœ ์ธ์‹ โ€ข CoreDNS๋กœ ์ฟผ๋ฆฌ๊ฐ€ ์ค„๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€ํ•˜ ๊ฐ์†Œ
  • 32.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Scaling CoreDNS โ€ข ๊ธฐ๋ณธ์ ์œผ๋กœ CoreDNS๋Š” EKS ํด๋Ÿฌ์Šคํ„ฐ์— 2๊ฐœ์˜ ๋ณต์ œ๋ณธ์œผ๋กœ ๋ฐฐํฌ๋จ โ€ข CoreDNS ๋ฐฐํฌ๋ฅผ ์ž๋™ ํ™•์žฅํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• โ€ข CPA(Cluster Proportional Autoscaling) : ํด๋Ÿฌ์Šคํ„ฐ ๊ทœ๋ชจ์— ๋”ฐ๋ผ ํ™•์žฅ โ€ข HPA(Horizontal Pod Autoscaling) : Pod ๋ฆฌ์†Œ์Šค ์ž„๊ณ„์น˜ ๊ธฐ๋ฐ˜์˜ ํ™•์žฅ
  • 33.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. CoreDNS ๋ชจ๋‹ˆํ„ฐ๋ง linklocal_allowance_exceeded : PPS๊ฐ€ ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ตœ๋Œ€๊ฐ’์„ ์ดˆ๊ณผํ•˜์—ฌ ์‚ญ์ œ๋œ ํŒจํ‚ท์˜ ์ˆ˜ โ€ข Link local์€ ์ธํ„ฐ๋„ท์œผ๋กœ ๋‚˜๊ฐ€์ง€ ์•Š๋Š” ๋‚ด๋ถ€ ํŒจํ‚ท์„ ์˜๋ฏธ
  • 34.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Node Local DNS Cache ์‚ฌ์šฉ
  • 35.
    ยฉ 2023, AmazonWeb Services, Inc. or its affiliates. Thank you! ยฉ 2023, Amazon Web Services, Inc. or its affiliates.