[AEWS] # 2์ฃผ์ฐจ eks vpc cni ์ดํดํ๊ธฐ (1)
25๋ ๋ AWS EKS Hands-on Study ์คํฐ๋ ์ ๋ฆฌ ๋ด์ฉ์ ๋๋ค.
์ค์ต ํ๊ฒฝ ๊ตฌ์ฑ
CloudFormation
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/myeks-2week.yaml
aws cloudformation deploy --template-file ~/Downloads/myeks-2week.yaml \
--stack-name myeks --parameter-overrides KeyName=[my key] \
SgIngressSshCidr=$(curl -s ipinfo.io/ip)/32 --region ap-northeast-2
# ec2 ip ์ถ๋ ฅ
aws cloudformation describe-stacks --stack-name myeks \
--query 'Stacks[*].Outputs[*].OutputValue' --output text
# ssh ์ ์ ํ์ธ
ssh ec2-user@$(aws cloudformation describe-stacks --stack-name myeks --query 'Stacks[*].Outputs[0].OutputValue' --output text)
eksctl
export CLUSTER_NAME=myeks # eks cluster name
export VPCID=$(aws ec2 describe-vpcs --filters "Name=tag:Name,Values=$CLUSTER_NAME-VPC" --query 'Vpcs[*].VpcId' --output text)
echo $VPCID
# ํผ๋ธ๋ฆญ ์๋ธ๋ท ํ์ธ
export PubSubnet1=$(aws ec2 describe-subnets --filters Name=tag:Name,Values="$CLUSTER_NAME-Vpc1PublicSubnet1" --query "Subnets[0].[SubnetId]" --output text)
export PubSubnet2=$(aws ec2 describe-subnets --filters Name=tag:Name,Values="$CLUSTER_NAME-Vpc1PublicSubnet2" --query "Subnets[0].[SubnetId]" --output text)
export PubSubnet3=$(aws ec2 describe-subnets --filters Name=tag:Name,Values="$CLUSTER_NAME-Vpc1PublicSubnet3" --query "Subnets[0].[SubnetId]" --output text)
echo $PubSubnet1 $PubSubnet2 $PubSubnet3
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: myeks
region: ap-northeast-2
version: "1.31"
kubernetesNetworkConfig:
ipFamily: IPv4
iam:
vpcResourceControllerPolicy: true
withOIDC: true
accessConfig:
authenticationMode: API_AND_CONFIG_MAP
vpc:
autoAllocateIPv6: false
cidr: 192.168.0.0/16
clusterEndpoints:
privateAccess: true # if you only want to allow private access to the cluster
publicAccess: true # if you want to allow public access to the cluster
id: vpc-0ab40d2acbda845d8 # ๊ฐ์ ํ๊ฒฝ ์ ๋ณด๋ก ์์
manageSharedNodeSecurityGroupRules: true # if you want to manage the rules of the shared node security group
nat:
gateway: Disable
subnets:
public:
ap-northeast-2a:
az: ap-northeast-2a
cidr: 192.168.1.0/24
id: [ํผ๋ธ๋ฆญ ์๋ธ๋ท]
ap-northeast-2b:
az: ap-northeast-2b
cidr: 192.168.2.0/24
id: [ํผ๋ธ๋ฆญ ์๋ธ๋ท]
ap-northeast-2c:
az: ap-northeast-2c
cidr: 192.168.3.0/24
id: [ํผ๋ธ๋ฆญ ์๋ธ๋ท]
addons:
- name: vpc-cni # no version is specified so it deploys the default version
version: latest # auto discovers the latest available
attachPolicyARNs: # attach IAM policies to the add-on's service account
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
configurationValues: |-
enableNetworkPolicy: "true"
- name: kube-proxy
version: latest
- name: coredns
version: latest
- name: metrics-server
version: latest
privateCluster:
enabled: false
skipEndpointCreation: false
managedNodeGroups:
- amiFamily: AmazonLinux2023
desiredCapacity: 3
disableIMDSv1: true
disablePodIMDS: false
iam:
withAddonPolicies:
albIngress: false # Disable ALB Ingress Controller
appMesh: false
appMeshPreview: false
autoScaler: false
awsLoadBalancerController: true # Enable AWS Load Balancer Controller
certManager: true # Enable cert-manager
cloudWatch: false
ebs: false
efs: false
externalDNS: true # Enable ExternalDNS
fsx: false
imageBuilder: true
xRay: false
instanceSelector: {}
instanceType: t3.medium
preBootstrapCommands:
# install additional packages
- "dnf install nvme-cli links tree tcpdump sysstat ipvsadm ipset bind-utils htop -y"
# disable hyperthreading
- "for n in $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | cut -s -d, -f2- | tr ',' '\n' | sort -un); do echo 0 > /sys/devices/system/cpu/cpu${n}/online; done"
labels:
alpha.eksctl.io/cluster-name: myeks
alpha.eksctl.io/nodegroup-name: ng1
maxSize: 3
minSize: 3
name: ng1
privateNetworking: false
releaseVersion: ""
securityGroups:
withLocal: null
withShared: null
ssh:
allow: true
publicKeyName: [key pair]
tags:
alpha.eksctl.io/nodegroup-name: ng1
alpha.eksctl.io/nodegroup-type: managed
volumeIOPS: 3000
volumeSize: 30
volumeThroughput: 125
volumeType: gp3
eksctl๋ก ํด๋ฌ์คํฐ๋ฅผ ๋ฐฐํฌํ ๊ตฌ์ฑ ํ์ผ์ด๋ค. ๊ตฌ์ฑ๋ ๋ด์ฉ์ ์๋์ ๊ฐ๋ค.
- myeks๋ผ๋ ์ด๋ฆ์ผ๋ก ์์ธ ๋ฆฌ์ ์ 1.31๋ก ๋ฐฐํฌ๋ ํด๋ฌ์คํฐ์ด๋ค.
- vpc ๋ฆฌ์ํธ ์ปจํธ๋กค๋ฌ ์ ์ฑ ์ ํ์ฑํํ์ฌ AWS VPC ๋คํธ์ํฌ ๋ฆฌ์๋ฅผ ์ ์ดํ ์ ์๊ฒ ์ค์ ํ๋ค.
- OIDC ID ๊ณต๊ธ์ ์ค์ ์ ํ์ฑํํ์ฌ IAM, ์ฟ ๋ฒ๋คํฐ์ค ์๋น์ค ๊ณ์ ๊ฐ์ ์ฐ๊ฒฐ ์ง์์ ์ค์ ํ๋ค.
- ํด๋ฌ์คํฐ ์ ๊ทผ ์ธ์ฆ์ ๊ฒฝ์ฐ AWS IAM ๊ธฐ๋ฐ ์ธ์ฆ๊ณผ ์ฟ ๋ฒ๋คํฐ์ค์ RBAC์ ์ฌ์ฉํ๋ค.
- VPC CIDR์ ๊ฒฝ์ฐ 192.168.0.0/16์ ์ฌ์ฉํ๊ณ , ํด๋ฌ์คํฐ ์๋ํฌ์ธํธ์ ๊ฒฝ์ฐ public, private ์ก์ธ์ค๊ฐ ๋ชจ๋ ์ค์ ๋์ด ํด๋ฌ์คํฐ API ์๋ฒ ์ ๊ทผ์ด ์ธ๋ถ ๋ด๋ถ ๋ชจ๋ ๊ฐ๋ฅํ๋ค.
- ์ ๋์จ์ ๊ฒฝ์ฐ VPC CNI, kube proxy, coreDNS, Metrics Server 4๊ฐ์ง ๊ธฐ๋ฅ์ ์ถ๊ฐํ๋ค.
- EKS ๋ ธ๋ ๊ทธ๋ฃน์ ํตํด ์ฟ ๋ฒ๋คํฐ์ค ์์ปค ๋ ธ๋๋ฅผ ์๋์ผ๋ก ๊ด๋ฆฌํ๋ค.
eksctl create cluster -f myeks.yaml --verbose 4
๋ฐฐํฌ๋ eks ํด๋ฌ์คํฐ ํ์ธ
kubectl get node --label-columns=node.kubernetes.io/instance-type,eks.amazonaws.com/capacityType,topology.kubernetes.io/zone
kubectl get node -v=6
NAME STATUS ROLES AGE VERSION
ip-192-168-1-112.ap-northeast-2.compute.internal Ready <none> 6m25s v1.31.5-eks-5d632ec
ip-192-168-2-169.ap-northeast-2.compute.internal Ready <none> 6m17s v1.31.5-eks-5d632ec
ip-192-168-3-231.ap-northeast-2.compute.internal Ready <none> 6m22s v1.31.5-eks-5d632ec
๋ ธ๋ ๊ทธ๋ฃน ์ธ๋ฐ์ด๋ ๋ฃฐ ์ถ๊ฐ
aws ec2 describe-instances --query "Reservations[*].Instances[*].{InstanceID:InstanceId, PublicIPAdd:PublicIpAddress, PrivateIPAdd:PrivateIpAddress, InstanceName:Tags[?Key=='Name']|[0].Value, Status:State.Name}" --filters Name=instance-state-name,Values=running --output table
----------------------------------------------------------------------------------------
| DescribeInstances |
+----------------------+-----------------+----------------+----------------+-----------+
| InstanceID | InstanceName | PrivateIPAdd | PublicIPAdd | Status |
+----------------------+-----------------+----------------+----------------+-----------+
| i-04332dffb3235a12f | myeks-ng1-Node | 192.168.3.x | 54.x.x.x | running |
| i-0c9a528984351cadb | operator-host | 172.20.1.x | 43.x.x.x | running |
| i-0377ada6c8218a6b8 | myeks-ng1-Node | 192.168.1.x | 43.x.x.x | running |
| i-0681ecb761cc83614 | myeks-ng1-Node | 192.168.2.x | 43.x.x.x. | running |
+----------------------+-----------------+----------------+----------------+-----------+
export MNSGID=[๊ด๋ฆฌํ ๋
ธ๋ ๊ทธ๋ฃน ๋ณด์๊ทธ๋ฃน]
# ๋ณธ์ธ ์ง ๊ณต์ธ ip ์ถ๊ฐ
aws ec2 authorize-security-group-ingress --group-id $MNSGID --protocol '-1' --cidr $(curl -s ipinfo.io/ip)/32
# ec2 IP ๋ฃฐ ์ถ๊ฐ
aws ec2 authorize-security-group-ingress --group-id $MNSGID --protocol '-1' --cidr 172.20.1.100/32
ssh -i pemํค ec2-user@$N1
ssh -i pemํค ec2-user@$N2
ssh -i pemํค ec2-user@$N3
๋ ธ๋๊ทธ๋ฃน ng1์ EKS์ ๊ด๋ฆฌํ ๋ ธ๋ ๊ทธ๋ฃน์ธ๋ฐ, ์ฟ ๋ฒ๋คํฐ์ค์ ์์ปค ๋ ธ๋๋ค์ด ์ํด ์๋ ๊ทธ๋ฃน์ผ๋ก ๋ณด์ ์ ์ฑ ๋ด ์ธ๋ฐ์ด๋ ๋ฃฐ์ ์ถ๊ฐํ์ฌ ์ ๊ทผํ ์ ์๋๋ก ํ๋ค.
๋ณธ์ธ์ ์ง์์ ์ฌ์ฉํ๋ ๊ณต์ธ ip์ ec2 ์๋ฒ์ ๋ด๋ถ ip๋ฅผ ๋ณด์๊ทธ๋ฃน์ ์ถ๊ฐํด์ eks ๋ ธ๋๊ทธ๋ฃน ์ ๊ทผ์ ํ ์ ์๋๋ก ํ๊ณ ํ ๋ฐ ssh ์ ์์ ํ์ธํ๋ค.
aws ssm start-session --target i-04332dffb3235a12f
Starting session with SessionId: nana-r66x7642x6tqrv75aiipq5h57i
sh-5.2$ whoami
ssm-user
sh-5.2$ pwd
/usr/bin
sh-5.2$ hostnamectl
Static hostname: ip-192-168-3-231.ap-northeast-2.compute.internal
Icon name: computer-vm
Chassis: vm ๐ด
Machine ID: ec2df7d5af5533fefc902e710ae161c9
Boot ID: a02d09acde7b4e82962ba4b70c9bc853
Virtualization: amazon
Operating System: Amazon Linux 2023.6.20250203
CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2023
Kernel: Linux 6.1.127-135.201.amzn2023.x86_64
Architecture: x86-64
Hardware Vendor: Amazon EC2
Hardware Model: t3.medium
Firmware Version: 1.0
sh-5.2$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash
ssm-user:x:1001:1001::/home/ssm-user:/bin/bash
...
# sudo ๊ถํ ํ์ธ
sh-5.2$ sudo -l
Matching Defaults entries for ssm-user on ip-192-168-3-231:
!visiblepw, always_set_home, match_group_by_gid,
always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY
HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL QTDIR
USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE
LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES",
env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER
LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS
_XKB_CHARSET XAUTHORITY",
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/var/lib/snapd/snap/bin
User ssm-user may run the following commands on ip-192-168-3-231:
(ALL) NOPASSWD: ALL
๋ํ ssh ์์ด aws session manager๋ฅผ ํตํด ec2 ์ธ์คํด์ค์ ์ ์ํ ์ ์๋๋ฐ, IAM ๊ถํ์ด ํ์ํ๋ฏ๋ก aws configure๋ก ์ฌ์ ์ ํค ์ค์ ํ๋ ์์ ์ด ํ์ํ๋ค.
์ธ์ ๋งค๋์ ์ ๊ฒฝ์ฐ ssm user๊ฐ sudo ๊ถํ์ด ๊ธฐ๋ณธ์ ์ผ๋ก ๋ถ์ฌ๋์ด์ root ๊ถํ์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
AWS VPC CNI
EKS์์ ํ๋๋ค์ AWS VPC CNI๋ฅผ ํตํด ec2 ์ธ์คํด์ค์ฒ๋ผ ๋คํธ์ํฌ๋ฅผ ์ฌ์ฉํ๋ค.
vpc cni๋ cni ๋ฐ์ด๋๋ฆฌ์ ipamd๋ผ๋ 2๊ฐ์ง ํต์ฌ ์์๋ก ๊ตฌ์ฑ๋ผ์๋๋ฐ, cni ๋ฐ์ด๋๋ฆฌ๋ kubelet์์ ์๋ก์ด ํ๋๋ฅผ ์์ฑํ ๋ ์๋์ผ๋ก ํ๋ ๋คํธ์ํฌ๋ฅผ ์ค์ ํ์ฌ ํต์ ํ ์ ์๊ฒ ํ๋ค. ๋ฐ์ด๋๋ฆฌ๋ ๊ฐ ๋ ธ๋์ ํ์ผ์์คํ ์ ์ค์น๋์ด ์๋ค.
ipamd๋ ec2 eni๋ฅผ ๊ด๋ฆฌํ๋ ์ญํ ์ ์ํํ๋๋ฐ ip์ฃผ์๋ฅผ ๊ฐ์ง๊ณ ์๊ณ ec2 ์ธ์คํด์ค ์ข ๋ฅ์ ๋ฐ๋ผ ์ฌ๋ฌ๊ฐ๋ฅผ ๊ฐ์ง ์ ์๋ค. eni์์ ์ฌ์ฉ ๊ฐ๋ฅํ ip ์ฃผ์๋ฅผ ๋ฏธ๋ฆฌ ํ๋ณดํ๋๋ฐ ์ด๋ฅผ warm pool์ด๋ผ๊ณ ํ๋ค. ํ๋๊ฐ ํ์ํ ๋ ๋น ๋ฅด๊ฒ ip ์ฃผ์๋ฅผ ํ ๋นํ๊ฒ ํด์ค์ผ๋ก์จ, ํ๋๊ฐ ์ฌ์ฉํ ๋คํธ์ํฌ ์ฃผ์๋ฅผ ๋ฏธ๋ฆฌ ์ค๋นํ๋ค.
์ฒ์ ec2 ์ธ์คํด์ค๊ฐ ์์๋๋ฉด ec2๋ ํ๋ผ์ด๋จธ๋ฆฌ eni๋ฅผ ๊ฐ์ง๊ณ ์๊ณ ์ด eni๋ ํผ๋ธ๋ฆญ, ํ๋ผ์ด๋น ์๋ธ๋ท์ผ๋ก ์ฐ๊ฒฐ๋ ์ ์๋ค. ๋ง์ฝ hostNetwork ๋ชจ๋์ผ ๊ฒฝ์ฐ ํ๋๋ eni์ ip์ ๋์ผํ๊ฒ ์ฌ์ฉ๋๋ค.
ํ๋๊ฐ ์๊ธฐ๋ฉด vpc cni๋ ipamd๋ฅผ ํตํด ip๋ฅผ ๋ฐ๋๋ฐ, vpc cni๋ ec2์ ์ถ๊ฐ๋ก eni๋ฅผ ์ฐ๊ฒฐํ ์ ์๋ค. ํ๋ ๊ฐ์๊ฐ ๋ง์์ง ์๋ก eni๊ฐ ์ถ๊ฐ๋๋๋ฐ ์ด๋ฅผ ์ธ์ปจ๋๋ฆฌ eni๋ผ๊ณ ํ๋ค.
ec2๋ง๋ค ์ต๋ eni๊ฐ์์ ip ๊ฐ์๊ฐ ๋ค๋ฅด๋ฏ๋ก ์คํํ ์ ์๋ ์ต๋ ํ๋ ๊ฐ์๋ ์ด๋ก ๊ฒฐ์ ๋๋ค๊ณ ๋ณผ ์ ์๋ค. ํ ๊ฐ์ ec2 ์์ ์คํ ๊ฐ๋ฅํ ํ๋์ ๊ฐ์๋ eni * (eni๊ฐ ์ง์ํ๋ ipv4 - 1) + 2๋ก ๊ณ์ฐ๋๋ค.
coreDNS ํ๋์ eks ๋ ธ๋์ ํ๋ผ์ด๋น ip๊ฐ ๊ฐ์ ์ด์
kubectl describe daemonset aws-node --namespace kube-system | grep Image | cut -d "/" -f 2
amazon-k8s-cni-init:v1.19.2-eksbuild.5
amazon-k8s-cni:v1.19.2-eksbuild.5
amazon
+----------------+-----------------+
| InstanceName | PrivateIPAdd |
+----------------+-----------------+
| myeks-ng1-Node| 192.168.3.231 |
| operator-host | 172.20.1.100 |
| myeks-ng1-Node| 192.168.1.112 |
| myeks-ng1-Node| 192.168.2.169 |
+----------------+-----------------+
kubectl get pod -n kube-system -o=custom-columns=NAME:.metadata.name,IP:.status.podIP,STATUS:.status.phase
NAME IP STATUS
aws-node-7pzrz 192.168.1.112 Running
aws-node-ctfl4 192.168.3.231 Running
aws-node-ns6ph 192.168.2.169 Running
coredns-86f5954566-mlwpn 192.168.1.100 Running
coredns-86f5954566-qfk2r 192.168.3.41 Running
kube-proxy-d6jc4 192.168.3.231 Running
kube-proxy-d9w9l 192.168.2.169 Running
kube-proxy-skt8n 192.168.1.112 Running
metrics-server-6bf5998d9c-lsbq6 192.168.1.160 Running
metrics-server-6bf5998d9c-pfl7z 192.168.3.183 Running
eks๋ vpc cni๋ฅผ ์ฌ์ฉํ์ฌ ํ๋๋ค์ vpc์ ์ค์ ๋คํธ์ํฌ์์ IP๋ฅผ ์ง์ ํ ๋น๋ฐ๋๋ฐ, ํ๋๋ค์ vpc ์๋ธ๋ท์ ์๋ ec2์ ๋์ผํ ๋คํธ์ํฌ์์ ๋์ํ๋ค.
aws-node์ kube-proxy๋ ec2์ ๋ฐ๋ชฌ์ ์ผ๋ก ์คํ๋๋๋ฐ ๋ฐ๋ชฌ์ ์ ํด๋น ๋ ธ๋์์ ๋คํธ์ํฌ๋ฅผ ์ ์ดํ๋ ํ๋์ด๋ฏ๋ก ์ด ๋ ธ๋์ ํ๋ผ์ด๋น ip๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ๊ฒ ๋๋ค.
์ด ์ธ ํ๋๋ ec2์ eni์์ ํ ๋น๋ ํ๋ผ์ด๋น ip๋ฅผ ์ฌ์ฉํ๊ณ ์ด ํ๋๊ฐ ์คํ๋๋ ๋ ธ๋์ ์๋ธ๋ท์์ ํ ๋น๋๋ค.
netshoot-pod ํ ์คํธ
[ec2-user@ip-192-168-3-231 ~]$ sudo lsns -t net
NS TYPE NPROCS PID USER NETNSID NSFS COMMAND
4026531840 net 111 1 root unassigned /usr/li
4026532211 net 2 3235 65535 0 /run/netns/cni-615c56d6-0bfb-b770-1e4c-29e55aaa917c /pause
4026532291 net 2 3323 65535 1 /run/netns/cni-49185490-e3e4-f8a0-c09d-eedb7e52642a /pause
4026532403 net 2 46278 65535 2 /run/netns/cni-a22f9035-44e1-8bb3-8403-84708f0b21e9 /pause
[ec2-user@ip-192-168-3-231 ~]$ PID=46278
[ec2-user@ip-192-168-3-231 ~]$ sudo nsenter -t $PID -n ip -c addr
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 proto kernel_lo
valid_lft forever preferred_lft forever
3: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc noqueue state UP group default
link/ether fa:42:c9:aa:e0:7e brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.3.250/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f842:c9ff:feaa:e07e/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
[ec2-user@ip-192-168-3-231 ~]$ sudo nsenter -t $PID -n ip -c route
default via 169.254.1.1 dev eth0
169.254.1.1 dev eth0 scope link
eks์ ํ๋ ๋คํธ์ํฌ ๋ค์์คํ์ด์ค๋ฅผ ํ์ธํ๊ณ , ํ๋ ๋ด๋ถ์ ๋คํธ์ํฌ ์ธํฐํ์ด์ค์ ๋ผ์ฐํ ํ ์ด๋ธ์ ํ์ธํ ์ ์๋ค.
ํ๋ ๋ด๋ถ์์ ์คํ ์ค์ธ pause ์ปจํ ์ด๋์ ํ๋ก์ธ์ค ID์ธ 46278๋ฅผ ์ดํด๋ณด๋ฉด ๋คํธ์ํฌ ๊ตฌ์กฐ๋ ์๋์ ๊ฐ๋ค.
Loopback (lo)
- 127.0.0.1/8: ํ๋ ๋ด๋ถ์์๋ง ์ฌ์ฉ ๊ฐ๋ฅํ ๋ฃจํ๋ฐฑ ์ธํฐํ์ด์ค
eth0@if6 (ํ๋์ ๋ฉ์ธ ๋คํธ์ํฌ ์ธํฐํ์ด์ค)
- eth0@if6: ํ๋์ ๊ธฐ๋ณธ ๋คํธ์ํฌ ์ธํฐํ์ด์ค
- MTU 9001 → AWS์์ ์ ๊ณตํ๋ ์ ๋ณด ํ๋ ์
- MAC ์ฃผ์: fa:42:c9:aa:e0:7e
- IPv4 ์ฃผ์: 192.168.3.250/32 -> aws eni๋ก ์ ๊ณต๋ ๊ฒ
- IPv6 ๋งํฌ-๋ก์ปฌ ์ฃผ์: fe80::f842:c9ff:feaa:e07e/64
ํ๋์์ ์ธ๋ถ ๋คํธ์ํฌ๋ก ํธ๋ํฝ์ ๋ณด๋ผ ๋, 169.254.1.1์ ๊ฒ์ดํธ์จ์ด๋ก ์ฌ์ฉํ๋๋ฐ, 169.254.1.1์ AWS VPC CNI์์ ์ ๊ณตํ๋ NAT ๊ฒ์ดํธ์จ์ด ์ญํ ์ ํ๋ค. ๋ก์ปฌ eni์ ์ฐ๊ฒฐ๋ ๋คํธ์ํฌ๋ ํ๋์ ๊ฐ์ ec2์์ ์คํ๋๋ ๋ค๋ฅธ ํ๋๋ค๊ณผ ํต์ ํ ๋ ์ฌ์ฉํ๋ค.
ํ๋ ๊ฐ ํต์ ์ ํ๊ธฐ ์ํด์๋ eni๋ก ๋ผ์ฐํ ์ ์ํํ๊ณ ์ธ๋ถ ํธ๋ํฝ์ ๊ฒ์ดํธ์จ์ด๋ฅผ ํตํด ํธ๋ํฝ์ ๋ณด๋ธ๋ค.
ํ๋ ๊ฐ ํต์ ํจํท ๋คํ
PODIP1=$(kubectl get pod -l app=netshoot-pod -o jsonpath='{.items[0].status.podIP}')
PODIP2=$(kubectl get pod -l app=netshoot-pod -o jsonpath='{.items[1].status.podIP}')
PODIP3=$(kubectl get pod -l app=netshoot-pod -o jsonpath='{.items[2].status.podIP}')
# ํ ํ
์คํธ
kubectl exec -it $PODNAME1 -- ping -c 2 $PODIP2
kubectl exec -it $PODNAME2 -- ping -c 2 $PODIP3
kubectl exec -it $PODNAME3 -- ping -c 2 $PODIP1
# 1๋ฒ ํ๋
ens5 In IP 192.168.2.27 > 192.168.1.182: ICMP echo request
eni1ca12149b57 Out IP 192.168.2.27 > 192.168.1.182: ICMP echo request
# 2๋ฒ ํ๋
eni3628be173f9 In IP 192.168.2.27 > 192.168.1.182: ICMP echo request
ens5 Out IP 192.168.2.27 > 192.168.1.182: ICMP echo request
1๋ฒ ํ๋ -> 2๋ฒ ํ๋๋ก ํ์ ์ ๋ ํจํท ๋คํ์ด๋ค.
์ถ๋ฐ์ง 192.168.2.27 → ๋ชฉ์ ์ง 192.168.1.182์ IP๊ฐ ๋ชจ๋ ๊ตฌ๊ฐ์์ ๋์ผํ๊ฒ ์ ์ง๋๋๋ฐ, NAT๊ฐ ๋์ง ์๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
eni๋ฅผ ํตํด ํจํท์ด ์ง์ ์ ๋ฌ๋๋ฏ๋ก vpc ๋คํธ์ํฌ์์ ๊ทธ๋๋ก ์ฒ๋ฆฌ๋๋ค๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.