Cilium Multi-Pool IPAM

Cilium Multi-Pool IPAM (CRD-Backed by Cilium Multi-Pool IPAM)

CiliumPodIPPool CRD가 지원하는 multi-pool IPAM을 활성화하는 방법을 안내하는 튜토리얼이에요. 여러 IP 풀을 만들고 파드가 어느 풀에서 IP를 받을지 지정하는 방법을 보여줘요.

출처: CRD-Backed by Cilium Multi-Pool IPAM

본문

이 문서는 CiliumPodIPPool CRD가 지원하는 multi-pool IPAM을 활성화하는 방법을 안내하는 빠른 튜토리얼이에요. 이 튜토리얼의 목적은 컴포넌트가 어떻게 구성되고 리소스가 서로 어떻게 상호작용하는지 보여줘서, 사용자가 스스로 자동화하거나 확장할 수 있게 하는 것이에요.

자세한 내용은 Multi-Pool 섹션을 참고하세요.

Multi-pool IPAM 모드 활성화 (Enable Multi-pool IPAM mode)

  1. helm으로 다음 옵션을 사용해 Kubernetes용 Cilium을 설정하세요:

    • --set ipam.mode=multi-pool
    • --set kubeProxyReplacement=true
    • --set bpf.masquerade=true

    이 옵션들이 각각 왜 필요한지에 대한 자세한 내용은 Limitations을 참고하세요.

  2. IPv4 주소용 default 풀을 다음 옵션으로 생성하세요:

    • --set ipam.operator.autoCreateCiliumPodIPPools.default.ipv4.cidrs='{10.10.0.0/16}'
    • --set ipam.operator.autoCreateCiliumPodIPPools.default.ipv4.maskSize=27
  3. Cilium과 Cilium-Operator를 배포하세요. Cilium은 Cilium Operator가 자신의 노드에 podCIDR을 할당할 때까지 자동으로 기다려요.

설치 검증 (Validate installation)

  1. Cilium이 올바르게 시작했는지 검증하세요:

    $ cilium status --wait
     /¯\
    

/¯_/¯\ Cilium: OK _/¯_/ Operator: OK /¯_/¯\ Envoy DaemonSet: disabled (using embedded mode) _/¯_/ Hubble Relay: OK __/ ClusterMesh: disabled

[...]


2. `default` 풀에 대한 `CiliumPodIPPool` 리소스가 `ipam.operator.autoCreateCiliumPodIPPools.default.*` Helm 값에 지정된 CIDR로 생성됐는지 검증하세요:

$ kubectl get ciliumpodippool default -o yaml apiVersion: cilium.io/v2alpha1 kind: CiliumPodIPPool metadata: name: default spec: ipv4: cidrs: - 10.10.0.0/16 maskSize: 27


3. 다음 `CiliumPodIPPool` 리소스로 추가 파드 IP 풀 `mars`를 생성하세요:

$ cat <<EOF | kubectl apply -f - apiVersion: cilium.io/v2alpha1 kind: CiliumPodIPPool metadata: name: mars spec: ipv4: cidrs: - 10.20.0.0/16 maskSize: 27 EOF


4. 두 풀 리소스가 모두 존재하는지 검증하세요:

$ kubectl get ciliumpodippools NAME AGE default 106s mars 7s


5. 각각 두 개의 파드를 가진 두 deployment를 생성하세요. 하나는 `default` 풀에서, 하나는 `ipam.cilium.io/ipam-pool: mars` 어노테이션을 통해 `mars` 풀에서 할당합니다:

$ cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata: name: nginx-default spec: selector: matchLabels: app: nginx-default replicas: 2 template: metadata: labels: app: nginx-default spec: containers: - name: nginx image: nginx:1.25.1 ports: - containerPort: 80

apiVersion: apps/v1 kind: Deployment metadata: name: nginx-mars spec: selector: matchLabels: app: nginx-mars replicas: 2 template: metadata: labels: app: nginx-mars annotations: ipam.cilium.io/ip-pool: mars spec: containers: - name: nginx image: nginx:1.25.1 ports: - containerPort: 80 EOF


6. 파드가 풀 정의에 지정된 서로 다른 CIDR에서 IPv4 주소를 할당받았는지 검증하세요:

$ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-default-79885c7f58-fdfgf 1/1 Running 0 5s 10.10.10.36 kind-worker2 nginx-default-79885c7f58-qch6b 1/1 Running 0 5s 10.10.10.77 kind-worker nginx-mars-76766f95f5-d9vzt 1/1 Running 0 5s 10.20.0.20 kind-worker2 nginx-mars-76766f95f5-mtn2r 1/1 Running 0 5s 10.20.0.37 kind-worker


7. 파드 간 연결성을 테스트하세요:

$ kubectl exec pod/nginx-default-79885c7f58-fdfgf -- curl -s -o /dev/null -w "%{http_code}" http://10.20.0.37 200


8. 또는 `ipam.cilium.io/ipam-pool` 어노테이션을 네임스페이스에도 적용할 수 있어요:

$ kubectl create namespace cilium-test-1 $ kubectl annotate namespace cilium-test-1 ipam.cilium.io/ip-pool=mars


네임스페이스 `cilium-test-1`에서 새로 생성된 모든 파드는 `mars` 풀에서 IPv4 주소를 할당받아요. Cilium 연결성 테스트(기본적으로 `cilium-test-1` 네임스페이스를 사용해 워크로드를 생성함)를 실행해 연결성을 검증하세요:

$ cilium connectivity test [...] ✅ All 42 tests (295 actions) successful, 13 tests skipped, 0 scenarios skipped.


> **Note:** 연결성 테스트는 성공적으로 완료되려면 최소 2개의 워커 노드가 있는 클러스터가 필요해요.

1. 연결성 테스트 파드가 `mars` 풀에 정의된 10.20.0.0/16 CIDR에서 IPv4 주소를 할당받았는지 검증하세요:

$ kubectl --namespace cilium-test get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES client-6f6788d7cc-7fw9w 1/1 Running 0 8m56s 10.20.0.238 kind-worker client2-bc59f56d5-hsv2g 1/1 Running 0 8m56s 10.20.0.193 kind-worker echo-other-node-646976b7dd-5zlr4 2/2 Running 0 8m56s 10.20.1.145 kind-worker2 echo-same-node-58f99d79f4-4k5v4 2/2 Running 0 8m56s 10.20.0.202 kind-worker ...


## 더 알아보기 (Learn more)

- [CRD-Backed IPAM](https://docs.cilium.io/en/stable/network/kubernetes/ipam-crd/)
- [Cilium Cluster-Pool IPAM](https://docs.cilium.io/en/stable/network/kubernetes/ipam-cluster-pool/)
- [IPAM 개념 (Multi-Pool)](https://docs.cilium.io/en/stable/concepts/ipam/multi-pool/)