CNI - Calico
Docker network
bridge
┌─── container0 ───┐
host eth0 ─── docker0(172.17.0.1) ┬── veth0 ─── eth0(172.17.0.2) │
│ └──────────────────┘
│ ┌─── container1 ───┐
├── veth1 ─── eth0(172.17.0.3) │
│ └──────────────────┘
│ ┌─── container2 ───┐
└── veth2 ─── eth0(172.17.0.4) │
└──────────────────┘
host
┌─── container2 ───┐
┌─── container1 ───┐ │
┌─── container0 ───┐ │─┘
host eth0 ─── docker0(172.17.0.1) ─── veth0 ─── eth0(172.17.0.2) │─┘
└──────────────────┘
Kubernetes network
Kubernetes network 기본 요구 사항
- 노드의 파드는 NAT 없이 모든 노드의 모든 파드와 통신할 수 있다.
- 노드의 에이전트(예: 시스템 데몬, kubelet)는 해당 노드의 모든 파드와 통신할 수 있다.
- 노드의 호스트 네트워크에 있는 파드는 NAT 없이 모든 노드에 있는 모든 파드와 통신할 수 있다.
Pod
Docker 의 host 방식으로 pod 내의 컨테이너간 네트워크를 공유합니다. Pause
라는 container가 생성되며 이 컨테이너가 IPC, Network namespace를 생성하고 유지합니다.
Calico

danger
EKS에서 VPC CNI 대신 Calico를 사용할 때, Kubernetes API server는 Calico Pod network에 있는 Pod와 연결된 Service를 사용하는 Webhook에 연결이 직접적으로 되지 않습니다. CNI-Genie
같은 어플리케이션이 추가적으로 필요할 수 있습니다.
Installation
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
Policy | IPAM | CNI | Overlay | Routing | Datastore |
---|---|---|---|---|---|
Calico | Calico | Calico | VXLAN | Calico | Kubernetes |
calico.yaml
# This section includes base Calico installation configuration.
# For more information, see: https://projectcalico.docs.tigera.io/archive/v3.19/reference/installation/api#operator.tigera.io/v1.Installation
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
name: default
spec:
# Configures Calico networking.
calicoNetwork:
# Note: The ipPools section cannot be modified post-install.
ipPools:
- blockSize: 26
cidr: 192.168.0.0/16
encapsulation: VXLANCrossSubnet
natOutgoing: Enabled
nodeSelector: all()
---
# This section configures the Calico API server.
# For more information, see: https://projectcalico.docs.tigera.io/archive/v3.20/reference/installation/api#operator.tigera.io/v1.APIServer
apiVersion: operator.tigera.io/v1
kind: APIServer
metadata:
name: default
spec: {}
아래와 같이 operator가 생성하는 리소스에 대한 tolerations을 추가할 수 있습니다.
apiVersion: operator.tigera.io/v1
kind: Installation
spec:
controlPlaneTolerations:
- effect: NoSchedule
key: node.cloudprovider.kubernetes.io/uninitialized
value: "true"
kubectl apply -f calico.yaml
watch kubectl get pods -n calico-system
마스터 노드에 Pod이 생성 될 수 있도록 설정하려면 아래 명령어를 실행하면 됩니다.
kubectl taint nodes <name> node-role.kubernetes.io/master:NoSchedule-
kubectl taint nodes <name> node-role.kubernetes.io/master:NoSchedule
kubectl get nodes -o wide
Test
kubectl run tmp-shell --rm -it --image nicolaka/netshoot -- /bin/bash
Reference
- https://kubernetes.io/ko/docs/concepts/cluster-administration/networking/
- https://docs.projectcalico.org/getting-started/kubernetes/quickstart
- https://www.youtube.com/watch?v=JyLtg_SJ1lo
- https://docs.projectcalico.org/reference/installation/api
- https://github.com/nicolaka/netshoot
- https://projectcalico.docs.tigera.io/getting-started/kubernetes/managed-public-cloud/eks