2023 01 07 - deptno/deptno.github.io GitHub Wiki
About Networking
- ๋์ผ ์๋ธ๋ท ๋ด(L2)์์๋ ์ ํ์ ๋๋ฌ์ด ๊ฐ๋ฅํ๋ค
- ์ด๊ฑธ ๋์ด์๋ผ๋ฉด L3 ๋ผ์ฐํฐ๊ฐ ํ์ํ๊ฒ๋๋ค.
10.48.0.128/26 via 10.0.0.12 dev eth0
- ์ผ๋ฐ์ ์ธ ๋ผ์ฐํ ํ๋กํ ์ฝ์ BGP
- overlay network <-> underlay network
- ๋์ ์๋์ ์ธ ๊ฐ๋ ์ด๋ค, ์ธ๋๋ ์ด๋ ์ผ๋ฐ ๋คํธ์ํฌ
- ์ค๋ฒ๋ ์ด ๋คํธ์ํฌ๋ ์ธ๋๋ ์ด ๋คํธ์ํฌ ์์์ ์ด๋ฃจ์ด์ง์ง๋ค
- ์ค๋ฒ๋ ์ด ๋คํธ์ํฌ ํจํท ์์ ์ธ๋๋ ์ด ๋คํธ์ํฌ ํจํท์ด ์กด์ฌํ๋ ๊ฐ๋
- ์ค๋ฒ๋ ์ด ๋คํธ์ํฌ์ ์ํฌ๋ก๋ ์ธ๋๋ ์ด ๋คํธ์ํฌ์์ ํต์ ์ ์ํด NAT, LB ๋ฑ์ ํ์๋กํ๋ค
- ๋ค์ ์ค๋ฒํค๋๊ฐ ์กด์ฌํ๋ค
- NAT(Network Addreess Translation)
- SNAT(Source ..)
- ์์ค ์ด๋๋ ์ค๋ฅผ ๋ณด๋์ ์๋ ๋ผ์ฐํฐ์ ์์ฒด IP๋ก ๊ต์ฒด
- ๋์์ฌ๋ ๋ผ์ฐํฐ๊ฐ ๋ฐ์์ ๋งคํ ์์ผ๋์ ์๋์ ํ๋ผ์ด๋น IP ๋ก ๊ต์ฒด
- DNAT(Destination...)
- SNAT(Source ..)
- MTU(Maximum Transmission Unit)
- ๋คํธ์ํฌ ๋งํฌ๊ฐ ํ๋ฐฉ์ ๋ณด๋ผ ์ ์๋ ํจํท ์ฌ์ด์ฆ
- ์ผ๋ฐ ์ ์ผ๋ก ๊ฐ๊ฒ ์ค์ ๋๋ค(1500 bytes)
- TCP๋ MTU๋ฅผ ํ์ตํ๋ค
- TCP๋ MTU ๋ณด๋ค ํฐ ํจํท์ ์ชผ๊ฐ ๋ค
- ํ๋๊ทธ๋จผํธ๋ฅผ ์ชผ๊ฐ๋ ์์ ์ ์ค๋ฒํค๋๊ฐ ํฌ๋ค
- MTU๊ฐ ํฌ๋ฉด CPU ์ฌ์ฉ์จ์ ์ ์ด์ง๋ค
About Kubernetes Networking
- Goal
- The fundamental network behaviors the Kubernetes network model defines.
- How Kubernetes works with a variety of different network implementations.
- What Kubernetes Services are.
- How DNS works within Kubernetes.
- What โNAT outgoingโ is and when you would want to use it.
- What โdual stackโ is.
- ์ฟ ๋ฒ๋คํฐ์ค ํ๋๊ฐ ํต์ ์๋ NAT์ด ์กด์ฌํ์ง ์์
- isolation ์ policy ๋ก ๊ตฌํํ์ฌ ๋คํธ์ํฌ์ ๋จ์์ฑ์ ๊ฐ์ ธ๊ฐ๋ค -> flat network isolation ์ด ์๋ค๋ ์๋ฏธ
- ์ฟ ๋ฒ๋คํฐ์ค๋ ๊ฑฐ์์์ฐ์ด๊ธดํ์ง๋ง host port -> pod port ๋งคํ ๋๋ host ip ๋ฅผ ์ด์ฉํ ๋คํธ์ํฌ๋ฅผ ์ง์
- kubenet ์ด๋ผ๋ first party ๊ฐ ์์ง๋ง ์์ฐ๊ณ cni ๋ฅผ ์ฌ์ฉ
- cni ์ ๋๊ฐ์ง ์ฑ
์
- ipam ์ ํตํด pod ์ ip ํ ๋น
- ํ๋๊ฐ ํต์
- Kubernetes DNS <-> virtual ip(cluster ip?)
- kube-proxy ๊ฐ vip ๋ฅผ ๋ก๋๋ฐธ๋ฐ์ฑ
- nodeport ์๋น์ค๋ every node
- Note that when using Calico in on-prem deployments you can also advertise service IP addresses, allowing services to be conveniently accessed without going via a node port or load balancer.
- Kubernetes dns ๋ ์ผ๋ฐ์ ์ผ๋ก coreDNS๋ฅผ ํตํด์๋น์ค๋ก ๊ตฌํ(์ผ๋ฐ ํ๋)
- ์ผ๋ฐ์ ์ผ๋ก ์ค๋ฒ๋ ์ด ๋คํธ์ํฌ์ ํด๋ฌ์คํฐ๊ฐ ํต์ ์์ SNAT ์ด node ์์ ์ด๋ฃจ์ด์ง๋ค pod -> node
Determine best networking option
-
flat netowrk ์ด๋ฏ๋ก network segmentation ์ policy ๋ฅผ ํตํด ๊ตฌํ๋๋ค
-
cni plugins
- network
- adding/deleting from pod network
- creating/deleting pod's network interface
- connecting/disconnecting
- ipam
- allocating/releasing ip addresses for pods when they are created or deleted
- ํ๋ฌ๊ทธ์ธํน์ cloud ๋ฒค๋์ ๋ฐ๋ผ ํ๋์ ๋ ธ๋์ ์ฌ๋ฌ cidr ๊ฐ ํ ๋น๋ ์ ์์
- network
-
kubenet
- ๊ธฐ๋ณธ์ด์ง๋ง node ๊ฐ ํต์ ์ ๊ตฌํ ์ํด๋์๋ค
-
overlay network
- underlay network ์์ ์ฌ๋ผ๊ฐ์ ํจํท์ ์ธ์บก์๋ ์ด์
- ์ธ์บก์๋ ์ด์ ํ๋กํ ์ฝ๋ก๋ vxlan, ip in ip ๊ฐ ์ ๋ช ํ๋ค
- underlay network ์ ๋ํ ๋ณ๊ฒฝ ์์ด ์ฌ์ฉ์ด ๊ฐ๋ฅํ๊ฒ ์ฅ์
- ๋จ์
- pod ip ๊ฐ ํด๋ฌ์คํฐ ๋ฐ์์ ๋ผ์ฐํ ๋์ง ์์
- ์ค๋ฒํค๋๊ฐ ๋ฐ์, ํจํท ๊ฐ์ธ๊ณ ํ๊ณ ํด์ผํด์
- ์ฑ๊ธ ์๋ธ๋ท์์๋ ์ธ์บก์๋ ์ด์ ์ด ๋์ง ์์ ํผํฌ๋จผ์ค ์ํฅ์ด ์๋ค๊ณ ํจ
- ์๋ธ๋ท ๋ง๋ค ๋ค๋ฅธ ์ธ์บก์๋ ์ด์ ์ ์ ํํ ์ ์์
-
IP routablility outside of cluster, cni ๊ตฌํ์ ๋ฐ๋ฅธ
- not routable
- inside -> outside
- pod ip -> host ip SNAT์ด ํธ์คํธ์ ์ผ์ด๋จ
- outside -> inside
- kubernetes service or ingress ๋ฅผ ํตํด์๋ง ์ ๊ทผ๋๋ฉฐ pod ip ๋ก๋ ์ ๊ทผ์ด ๋ถ๊ฐ
- inside -> outside
- routable
- SNAT ์ด ๋ถํ์ํ๋ฉฐ service, ingress ์์ด direct ๋ก pod ์ ์ ๊ทผ ๊ฐ๋ฅ
- ๋จ์ ์ broader network ์์ ip๊ฐ unique
- not routable
-
overlay network ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ผ๋ฐ์ ์ผ๋ก ์ธ๋ถ๋ผ์ฐํ ์ด ๋ถ๊ฐ๋ฅ
-
overlay network ๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ + ์ธ๋ถ๋ผ์ฐํ ์ด ๊ฐ๋ฅ ํ ๊ฒฝ์ฐ
-
BGP Border Gateway Protocol
-
Host local ipam
- ํธ์คํธ๋ง๋ค ipam (a/24) ๋ฅผ ๊ฐ์ง๊ณ ์์ด์ ์ดํดํ๊ธฐ ํธํ๋ค
- ip ํ ๋น์ด ๋นํจ์จ์ ์ด๋ค (๋ ธ๋๋ณ a/24 ์ด๊ธฐ ๋๋ฌธ)
-
vxlan ์ BGP๋ฅผ ์ด์ฉํ์ง ์๋๋ค, ipinip๋ณด๋ค ํจํท ์ฌ์ด์ฆ๊ฐ ์กฐ๊ธ ๋ ํฌ๋ค, ipip๊ฐ ์ง์๋์ง ์๋ ๊ณณ์์ ์ฌ์ฉ๋๋ค
-
ipinip ipv4 ๋ง์ง์
-
encapsulation mode ๋ cross subnet ์ด ํผํฌ๋จผ์ค์ ์ข๋ค
-
host ๊ฐ l3 ๋ผ์ฐํ (veth)