Install Calico¶
Part of: Install a CNI Plugin on Kubernetes
Calico installer — Installs Calico using the Tigera Operator. Pod CIDR is auto-detected from the cluster. Encapsulation mode is prompted interactively (VXLAN default).
Prerequisite: Kubernetes cluster running, kubeconfig configured, no existing CNI installed (or use the dispatcher to clean up first).
Script¶
| Script | Path |
|---|---|
install-calico.sh | scripts/kubernetes/cni/install-calico.sh |
Run directly (without the dispatcher):
curl -fsSL https://raw.githubusercontent.com/ibtisam-iq/silver-stack/main/scripts/kubernetes/cni/install-calico.sh | sudo bash
Defaults¶
| Parameter | Default | Notes |
|---|---|---|
| Calico version | Latest from GitHub API | Falls back to v3.31.2 if API unreachable |
| Encapsulation mode | VXLAN | Prompted at Phase 4 — press Enter to keep default |
| Pod CIDR | Auto-detected | Read from kube-system/kubeadm-config ConfigMap |
| Working directory | /tmp/calico-install | Cleaned and recreated at each run |
Installation Phases¶
Phase 1 — Cluster Access Verification¶
Sources ensure_kubeconfig from the silver-stack library, then confirms kube-system is reachable:
Exits immediately if the cluster is not accessible.
Phase 2 — Pod CIDR Detection¶
Reads the Pod CIDR that was set during kubeadm init — the cluster itself is the source of truth, not an environment variable:
kubectl -n kube-system get cm kubeadm-config \
-o jsonpath='{.data.ClusterConfiguration}' | grep podSubnet
Exits with an error if podSubnet cannot be parsed (e.g. cluster was not bootstrapped with kubeadm).
Phase 3 — Existing Calico Check¶
Checks for a live Installation CRD (operator.tigera.io):
If found, waits up to 60 seconds for automatic cleanup. If cleanup does not complete within the timeout, the script prints manual recovery steps and exits.
Phase 4 — Encapsulation Mode¶
Prompts the operator:
Press Enter to keep VXLAN. Type IPIP (or any valid Calico encapsulation value) to override. The value is patched directly into the custom resources manifest at Phase 9.
Phase 5 — Calico Version Resolution¶
Fetches the latest release tag from the GitHub API:
Falls back to v3.31.2 if the API is unreachable.
Phase 6 — Workspace Preparation¶
Creates /tmp/calico-install/, removing any prior run's artifacts:
Phase 7 — Install Tigera Operator¶
Applies the operator CRDs and the operator itself in two sequential kubectl create calls:
Both manifests are pulled from the official Calico release on GitHub at the resolved version.
Phase 8 — Download Custom Resources¶
Downloads the Calico custom-resources.yaml manifest to /tmp/calico-install/custom-resources.yaml for patching:
Phase 9 — Patch Custom Resources¶
Two sed -i substitutions are applied in-place before the manifest is applied to the cluster:
| Field patched | Value source |
|---|---|
cidr: | Pod CIDR detected in Phase 2 |
encapsulation: | Encapsulation mode chosen in Phase 4 |
Phase 10 — Apply Custom Resources¶
This triggers the Tigera Operator to begin reconciling the Calico installation.
Phase 11 — Stabilization Wait¶
Two readiness checks run in sequence:
- Polls for
calico-systemnamespace creation (up to 120s, 2s interval) - Waits for rollout readiness (up to 300s each):
kubectl -n calico-system rollout status deployment/calico-kube-controllers --timeout=300s
kubectl -n calico-system rollout status daemonset/calico-node --timeout=300s
Exits with error if either times out.
Phase 12 — Verification¶
Confirms Calico pods exist post-install. A final ok banner is printed on success.
Post-Install Checks¶
# All nodes should now show Ready
kubectl get nodes
# Calico pods should be Running
kubectl -n calico-system get pods
# Tigera operator should be Running
kubectl -n tigera-operator get pods
Troubleshooting¶
| Symptom | Likely cause | Fix |
|---|---|---|
Unable to detect Pod CIDR | Cluster not bootstrapped with kubeadm | Manually set CIDR or use a kubeadm cluster |
calico-system namespace was not created | Tigera Operator failed to start | Check kubectl -n tigera-operator logs |
Calico controllers failed to become ready | Resource contention or wrong CIDR | Check events: kubectl -n calico-system get events |
existing Calico Installation detected | Prior install not cleaned up | Run reset-calico.sh first, or use the dispatcher |