25๋ ๋ Cilium Study 1๊ธฐ ์ ๋ฆฌ ๊ธ์ ๋๋ค.
(โ|HomeLab:N/A) root@k8s-ctr:~# helm upgrade cilium cilium/cilium --namespace kube-system --reuse-values \
--set ipMasqAgent.enabled=true --set ipMasqAgent.config.nonMasqueradeCIDRs='{10.10.1.0/24,10.10.2.0/24}'
Release "cilium" has been upgraded. Happy Helming!
NAME: cilium
LAST DEPLOYED: Fri Aug 1 23:16:12 2025
NAMESPACE: kube-system
STATUS: deployed
REVISION: 3
TEST SUITE: None
NOTES:
You have successfully installed Cilium with Hubble Relay and Hubble UI.
Your release version is 1.18.0.
For any further help, visit https://docs.cilium.io/en/v1.18/gettinghelp
(โ|HomeLab:N/A) root@k8s-ctr:~# kubectl get cm -n kube-system ip-masq-agent -o yaml | yq
{
"apiVersion": "v1",
"data": {
"config": "{\"nonMasqueradeCIDRs\":[\"10.10.1.0/24\",\"10.10.2.0/24\"]}"
},
"kind": "ConfigMap",
"metadata": {
"annotations": {
"meta.helm.sh/release-name": "cilium",
"meta.helm.sh/release-namespace": "kube-system"
},
"creationTimestamp": "2025-08-01T14:16:13Z",
"labels": {
"app.kubernetes.io/managed-by": "Helm"
},
"name": "ip-masq-agent",
"namespace": "kube-system",
"resourceVersion": "2618",
"uid": "da66ff20-4823-4a86-b69b-91d02ed65585"
}
}
(โ|HomeLab:N/A) root@k8s-ctr:~# cilium config view | grep -i ip-masq
enable-ip-masq-agent true
(โ|HomeLab:N/A) root@k8s-ctr:~# kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg bpf ipmasq list
IP PREFIX/ADDRESS
10.10.1.0/24
10.10.2.0/24
169.254.0.0/16
ํ ํ ์คํธ
(โ|HomeLab:N/A) root@k8s-ctr:~# kubectl get pod -A -owide | grep curl
default curl-pod 1/1 Running 0 7s 172.20.1.71 k8s-ctr <none> <none>

(โ|HomeLab:N/A) root@k8s-ctr:~# ip -c route
default via 192.168.163.2 dev eth0 proto dhcp src 192.168.163.147 metric 100
๊ฒฐ๊ณผ๋ฅผ ํ์ธํด๋ณด๋ฉด tcp 0 ์ผ๋ก ์๋ต์ด ์๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
ํ์ฌ ํด๋ฌ์คํฐ ๋ ธ๋ (k8s-ctr)์ default gateway๊ฐ 192.168.163.2๋ก ํ๋์์ ์ธ๋ถ๋ก ๋๊ฐ๋ ๋ชจ๋ ํธ๋ํฝ์ eth0 → 192.168.163.2๋ก ์ฐ์ ๋ผ์ฐํ ๋๋ค.
curl-pod → 10.10.1.200์ผ๋ก ์์ฒญ ์์๋ ip-masq-agent ๋๋ถ์ SNAT ์์ด ํ๋ IP (10.244.0.226)๋ก ์ง์ ๋๊ฐ๋๋ฐ,
์๋ต ํจํท์ด ๋์ฐฉํ์ ๋ ๋ผ์ฐํฐ๊ฐ 10.244.0.0/16 ๋์ญ์ ๋ชจ๋ฅด๊ณ , ๋ค์ ๊ธฐ๋ณธ ๋ผ์ฐํธ๋ก ๋ณด๋ด๋ฉด ํด๋น ์์ฒญ์ unreachable๋ก ์ฒ๋ฆฌ๋๋ค.
๋ผ์ฐํฐ์ pod cidr ์ถ๊ฐ
root@router:~# ip route add 172.20.1.0/24 via 192.168.10.100
ip route add 172.20.0.0/24 via 192.168.10.101
root@router:~# ip -c route | grep 172.20
172.20.0.0/24 via 192.168.10.101 dev eth1
172.20.1.0/24 via 192.168.10.100 dev eth1
(โ|HomeLab:N/A) root@k8s-ctr:~# kubectl exec -it curl-pod -- curl -s 10.10.1.200
<h1>Web Server : router</h1>
root@router:~# tcpdump -i eth1 tcp port 80 -nnq
23:56:15.768505 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 0
23:56:15.769443 IP 10.10.1.200.80 > 172.20.1.71.41642: tcp 0
23:56:15.769651 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 0
23:56:15.769717 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 75
23:56:15.770212 IP 10.10.1.200.80 > 172.20.1.71.41642: tcp 0
23:56:15.785994 IP 10.10.1.200.80 > 172.20.1.71.41642: tcp 256
23:56:15.786349 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 0
23:56:15.786610 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 0
23:56:15.787306 IP 10.10.1.200.80 > 172.20.1.71.41642: tcp 0
23:56:15.787510 IP 172.20.1.71.41642 > 10.10.1.200.80: tcp 0
NAT ์์ด ํด๋ฌ์คํฐ ์ธ๋ถ ↔ ํ๋ ๊ฐ ์ง์ IP๋ก ์ด๋ฃจ์ด์ง๋๋ฐ ip-masq-agent ์ค์ ์ด ์ ์๋ํ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.