Networking

Calico

CNI Kubernetes (Tigera, Apache 2.0). Modes BGP routage direct, IP-in-IP ou VXLAN overlay, dataplane eBPF optionnel. NetworkPolicies standard + GlobalNetworkPolicy. Large adoption production.

Calico est un plugin CNI Kubernetes développé et maintenu par Tigera. Il gère à la fois le networking des pods (routage BGP direct ou overlay IP-in-IP/VXLAN) et l'application des NetworkPolicies via son agent Felix. C'est l'un des CNI les plus déployés en production, avec un large support des clouds managed (AKS, EKS, GKE optionnel) et des distributions Kubernetes.

Calico propose deux niveaux : Calico Open Source (Apache 2.0, le sujet de cette fiche) et Calico Enterprise (produit commercial Tigera avec sécurité avancée, compliance, etc.).

Idéal pour : clusters production nécessitant des NetworkPolicies solides, intégration BGP avec l'infrastructure réseau existante, environnements on-premise et cloud hybride.


Informations essentielles

Origine : Tigera  ·  Licence : Apache 2.0 (Open Source)  ·  Architectures : x86_64, ARM64, ppc64le, s390x

Liens : Site officiel  ·  Documentation  ·  GitHub  ·  Releases

Support : Les 3 dernières versions mineures sont maintenues.

Modes de dataplane

ModeMécanismeOverheadPrérequis
BGP (direct)Routage L3 natif, pas d'encapsulationNulNœuds sur même L2 ou BGP peering
IP-in-IPOverlay léger (encapsulation IP dans IP)FaibleAucun
VXLANOverlay UDP (port 4789)FaibleAucun
eBPFDataplane kernel eBPF (remplace iptables)NulKernel 5.3+

Architecture

ComposantRôle
Tigera OperatorGestion du cycle de vie Calico (installation recommandée)
calico-nodeDaemonSet - Felix (policies) + BIRD (BGP) + confd
FelixAgent de politique réseau - programme iptables/eBPF
BIRDDaemon BGP - annonce les routes des pods
TyphaCache pour les gros clusters (>200 nœuds)

Installation

Via Tigera Operator (recommandé)

# Installer le Tigera Operator
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/tigera-operator.yaml

# Créer la ressource Installation
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/custom-resources.yaml

# Vérifier (attendre que tous les pods soient Running)
watch kubectl get pods -n calico-system

Via manifests (alternative)

# Installation en une commande (mode VXLAN par défaut)
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/calico.yaml

# Vérifier
kubectl get pods -n kube-system -l k8s-app=calico-node

Configuration du mode réseau

# Installation CRD (Tigera Operator)
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
  name: default
spec:
  calicoNetwork:
    ipPools:
    - blockSize: 26
      cidr: 10.244.0.0/16
      encapsulation: VXLAN       # None (BGP), IPIPCrossSubnet, VXLAN, VXLANCrossSubnet
      natOutgoing: Enabled
      nodeSelector: all()

Modes d'encapsulation

# BGP direct (pas d'overlay) - meilleure performance, nœuds sur même L2 ou BGP configuré
encapsulation: None

# IP-in-IP cross-subnet - encapsulation seulement entre sous-réseaux
encapsulation: IPIPCrossSubnet

# VXLAN - overlay universel
encapsulation: VXLAN

NetworkPolicies

Calico supporte les NetworkPolicies standard Kubernetes et ses CRDs étendus.

NetworkPolicy standard

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all-ingress
  namespace: production
spec:
  podSelector: {}
  policyTypes:
  - Ingress

GlobalNetworkPolicy (Calico) - règle cluster-wide

apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
  name: deny-nodeport-access
spec:
  selector: all()
  order: 10
  ingress:
  - action: Deny
    protocol: TCP
    destination:
      ports: [30000:32767]
  types:
  - Ingress

Dataplane eBPF (optionnel, kernel 5.3+)

Le dataplane eBPF remplace Felix+iptables par des programmes eBPF dans le kernel. Plus performant, surtout pour les gros clusters avec beaucoup de Services.

# Activer via Tigera Operator
kubectl patch installation default --type merge \
  -p '{"spec":{"calicoNetwork":{"linuxDataplane":"BPF"}}}'

# Vérifier
kubectl -n calico-system exec ds/calico-node -- calico-node -show-status

calicoctl

calicoctl est le CLI Calico pour gérer les ressources Calico (NetworkPolicy, IPPool, etc.).

# Installer calicoctl
curl -L https://github.com/projectcalico/calico/releases/latest/download/calicoctl-linux-amd64 \
  -o /usr/local/bin/calicoctl
chmod +x /usr/local/bin/calicoctl

# Lister les ressources
calicoctl get nodes
calicoctl get ippool -o wide
calicoctl get networkpolicy -A

# Voir l'état BGP d'un nœud
calicoctl node status

Mise à jour

# Via Tigera Operator (met à jour Calico de manière rolling)
kubectl patch installation default --type merge \
  -p '{"spec":{"variant":"Calico","calicoNetwork":{}}}'

# Ou mettre à jour la version du manifeste operator
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v<nouvelle-version>/manifests/tigera-operator.yaml

# Vérifier
kubectl get tigerastatus

Troubleshooting

Pods sans connectivité

# État des nœuds Calico
kubectl get nodes -o wide
kubectl get pods -n calico-system

# Logs Felix (agent de policy)
kubectl logs -n calico-system ds/calico-node -c calico-node | grep -i error

# État BGP
calicoctl node status

# Vérifier les routes sur un nœud
ip route | grep bird

NetworkPolicy ne s'applique pas

# Lister les policies actives
calicoctl get networkpolicy -A -o wide
calicoctl get globalnetworkpolicy -o wide

# Diagnostics Felix
kubectl -n calico-system exec ds/calico-node -- calico-node -show-status

Commandes utiles

# calicoctl
calicoctl get nodes
calicoctl get ippool -o wide
calicoctl get networkpolicy -A
calicoctl get globalnetworkpolicy
calicoctl node status        # état BGP

# kubectl
kubectl get pods -n calico-system
kubectl get tigerastatus
kubectl logs -n calico-system ds/calico-node -c calico-node

Ressources

Newsletter · 2 000+ abonnés

Reste au courant de ce qui bouge en prod

RudeOps veille devops hebdo, droit au but.

Gratuit · Sans spam · Désinscription en un clic