cilium 테스트용 로컬 환경 구성하기

저는 kind(v0.24.0)와 orbstack 사용합니다.

 

cilium-cli 설치하기

$ brew install cilium-cli
$ cilium version
cilium-cli: v0.16.16 compiled with go1.23.0 on darwin/arm64
cilium image (default): v1.16.0
cilium image (stable): v1.16.1
cilium image (running): unknown. Unable to obtain cilium version. Reason: release: not found

 

 

kind를 이용하여 마스터 노드1대 워커노드 2대의 쿠버네티스 클러스터를 생성합니다. 

cilium은 systemd cgroup 드라이버 사용을 권장하기 때문에 cgroup 드라이버를 systemd로 변경하는 설정입니다. 

cilium은 kube-proxy를 완전히 대체도 가능하기 때문에 kube-proxy도 없는 버전으로 진행합니다.

# cilium-kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker
  
networking:
  disableDefaultCNI: true
  kubeProxyMode: "none"
kubeadmConfigPatches:
  - |
    kind: KubeProxyConfiguration
    mode: "none"
  - |
    kind: KubeletConfiguration
    cgroupDriver: "systemd"

 

이제 이 파일을 갖고 cilium을 설치할 쿠버네티스 클러스터를 만들어봅니다. 

➜ kind create cluster --name cilium-k8s --config cilium-kind-config.yaml
➜ kubectl get nodes
NAME                       STATUS     ROLES           AGE   VERSION
cilium-k8s-control-plane   NotReady   control-plane   76s   v1.31.0
cilium-k8s-worker          NotReady   <none>          61s   v1.31.0
cilium-k8s-worker2         NotReady   <none>          61s   v1.31.0
➜ kubectl get pods -A
NAMESPACE            NAME                                               READY   STATUS    RESTARTS   AGE
kube-system          coredns-6f6b679f8f-6cmd7                           0/1     Pending   0          83s
kube-system          coredns-6f6b679f8f-kbhtx                           0/1     Pending   0          83s
kube-system          etcd-cilium-k8s-control-plane                      1/1     Running   0          90s
kube-system          kube-apiserver-cilium-k8s-control-plane            1/1     Running   0          90s
kube-system          kube-controller-manager-cilium-k8s-control-plane   1/1     Running   0          89s
kube-system          kube-scheduler-cilium-k8s-control-plane            1/1     Running   0          90s
local-path-storage   local-path-provisioner-57c5987fd4-4fxdh            0/1     Pending   0          83s

 

 

파드 내용에도 kube-proxy는 존재하지 않고 node도 cni가 구성이 되지 않아 NotReady 상태입니다.

 

파드의 네트워크 역할을 해줄 addon인 cilium을 설치해보도록 하겠습니다. 

해당 옵션들은 kube-proxy가 없으면서, 오버레이 모드를 사용하지 않고 direct 모드로 라우팅하고, LB로 사용하기 위한 옵션들을 추가로 설정했습니다. helm으로 설치를 진행하지만 cilium cli를 이용해도 동일하게 --set 옵션을 통해 설치 옵션을 전달할 수 있습니다. 

# helm repo 추가하기
helm repo add cilium https://helm.cilium.io/

KUBERNETES_SERVICE_HOST=$( kubectl get nodes cilium-k8s-control-plane -o yaml | yq '.status.addresses[0].address' )
KUBERNETES_SERVICE_PORT=6443

# helm으로 설치하기
helm install cilium cilium/cilium --version 1.16.0 \
  --namespace kube-system \
  --set kubeProxyReplacement=true \
  --set k8sServiceHost=$KUBERNETES_SERVICE_HOST \
  --set k8sServicePort=$KUBERNETES_SERVICE_PORT \
  --set hostServices.enabled=false \
  --set externalIPs.enabled=true \
  --set nodePort.enabled=true \
  --set hostPort.enabled=true \
  --set bpf.masquerade=true \
  --set image.pullPolicy=IfNotPresent \
  --set ipam.mode=cluster-pool \
  --set tunnel=disabled

 

cilium-cli를 설치합니다. mac을 사용하고 있다면 brew를 사용하여 설치할 수 있습니다. 

brew install cilium-cli

 

 

이제 cilium의 상태를 확인해보도록 하겠습니다. 

cilium status
    /¯¯\
 /¯¯\__/¯¯\    Cilium:             OK
 \__/¯¯\__/    Operator:           OK
 /¯¯\__/¯¯\    Envoy DaemonSet:    OK
 \__/¯¯\__/    Hubble Relay:       disabled
    \__/       ClusterMesh:        disabled

DaemonSet              cilium             Desired: 3, Ready: 3/3, Available: 3/3
DaemonSet              cilium-envoy       Desired: 3, Ready: 3/3, Available: 3/3
Deployment             cilium-operator    Desired: 2, Ready: 2/2, Available: 2/2
Containers:            cilium             Running: 3
                       cilium-envoy       Running: 3
                       cilium-operator    Running: 2
Cluster Pods:          3/3 managed by Cilium
Helm chart version:    1.16.0