Search

Cilium

key: "node.cilium.io/agent-not-ready" value: "true" effect: "NoExecute"
Markdown
복사
설정한 taint는 제거되기 전까지 pod 실행을 block하다가, cilium이 node에서 실행되어 노드를 초기화 하고, 준비가 되면 node의 taint를 제거하게 됨, pod의 실행이 가능해지고 cilium이 네트워크를 관리하게 된다.
Cilium CLI Install
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt) CLI_ARCH=amd64 if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
Shell
복사
Cilium Install
helm repo add cilium https://helm.cilium.io/ helm repo update helm install cilium cilium/cilium \ --namespace kube-system \ --set cni.chainingMode=aws-cni \ --set cni.exclusive=false \ --set enableIPv4Masquerade=false \ --set routingMode=native
Shell
복사
cilium 설치 후 기존 pod에는 적용되지 않을 수 있어서, 재시작 해야 하는 pod를 찾는 script
for ns in $(kubectl get ns -o jsonpath='{.items[*].metadata.name}'); do ceps=$(kubectl -n "${ns}" get cep \ -o jsonpath='{.items[*].metadata.name}') pods=$(kubectl -n "${ns}" get pod \ -o custom-columns=NAME:.metadata.name,NETWORK:.spec.hostNetwork \ | grep -E '\s(<none>|false)' | awk '{print $1}' | tr '\n' ' ') ncep=$(echo "${pods} ${ceps}" | tr ' ' '\n' | sort | uniq -u | paste -s -d ' ' -) for pod in $(echo $ncep); do echo "${ns}/${pod}"; done done
Shell
복사
설치 확인
cilium status --wait
Shell
복사
EKS_CLUSTER_NAME="<EKS_CLUSTER_NAME>" EKS_CLUSTER_ROLE=$(aws eks describe-cluster --name $EKS_CLUSTER_NAME --query cluster.roleArn --output text | cut -d / -f 2)
Shell
복사
aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AmazonEKSVPCResourceController --role-name $EKS_CLUSTER_ROLE
Shell
복사
kubectl -n kube-system patch ds aws-node \ -p '{"spec":{"template":{"spec":{"initContainers":[{"env":[{"name":"DISABLE_TCP_EARLY_DEMUX","value":"true"}],"name":"aws-vpc-cni-init"}],"containers":[{"env":[{"name":"ENABLE_POD_ENI","value":"true"}],"name":"aws-node"}]}}}}' kubectl -n kube-system rollout status ds aws-node
Shell
복사
HAS-TRUN-ATTACH 가 true 인지 확인
kubectl get nodes -L vpc.amazonaws.com/has-trunk-attached
Shell
복사

hubble 설정

hubble은 cilium의 관찰 계층으로, 클러스터의 네트워크 및 보안 계층에 대한 클러스터 전체 가시성 확보가 가능하다.
먼저 worker node sg에 tcp 4244 self open을 해준다.
hubble 활성화
cilium hubble enable
Shell
복사
확인
cilium status
Shell
복사
hubble CLI Install
HUBBLE_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/hubble/master/stable.txt) HUBBLE_ARCH=amd64 if [ "$(uname -m)" = "aarch64" ]; then HUBBLE_ARCH=arm64; fi curl -L --fail --remote-name-all https://github.com/cilium/hubble/releases/download/$HUBBLE_VERSION/hubble-linux-${HUBBLE_ARCH}.tar.gz{,.sha256sum} sha256sum --check hubble-linux-${HUBBLE_ARCH}.tar.gz.sha256sum sudo tar xzvfC hubble-linux-${HUBBLE_ARCH}.tar.gz /usr/local/bin rm hubble-linux-${HUBBLE_ARCH}.tar.gz{,.sha256sum}
Shell
복사
hubble api 테스트
cilium hubble port-forward& hubble status
Shell
복사
hubble로 flow query
hubble observe
Shell
복사

실습