|
| 1 | ++++ |
| 2 | +title = "CNI" |
| 3 | +icon = "fa-solid fa-network-wired" |
| 4 | ++++ |
| 5 | + |
| 6 | +When deploying a cluster with CAPI, deployment and configuration of CNI is up to the user. By leveraging CAPI cluster |
| 7 | +lifecycle hooks, this handler deploys a requested CNI provider on the new cluster at the `AfterControlPlaneInitialized` |
| 8 | +phase. |
| 9 | + |
| 10 | +The hook uses either the [Cluster API Add-on Provider for Helm] or `ClusterResourceSet` to deploy the CNI resources |
| 11 | +depending on the selected deployment strategy. |
| 12 | + |
| 13 | +Currently the hook supports [Cilium](#cilium) and [Calico](#calico) CNI providers. |
| 14 | + |
| 15 | +## Cilium |
| 16 | + |
| 17 | +Deployment of Cilium is opt-in via the [provider-specific cluster configuration]({{< ref ".." >}}). |
| 18 | + |
| 19 | +### Cilium Example |
| 20 | + |
| 21 | +To enable deployment of Cilium on a cluster, specify the following values: |
| 22 | + |
| 23 | +```yaml |
| 24 | +apiVersion: cluster.x-k8s.io/v1beta1 |
| 25 | +kind: Cluster |
| 26 | +metadata: |
| 27 | + name: <NAME> |
| 28 | +spec: |
| 29 | + topology: |
| 30 | + variables: |
| 31 | + - name: clusterConfig |
| 32 | + value: |
| 33 | + addons: |
| 34 | + cni: |
| 35 | + provider: Cilium |
| 36 | + strategy: HelmAddon |
| 37 | +``` |
| 38 | +
|
| 39 | +To deploy the addon via `ClusterResourceSet` replace the value of `strategy` with `ClusterResourceSet`. |
| 40 | + |
| 41 | +## Calico |
| 42 | + |
| 43 | +Deployment of Calico is opt-in via the [provider-specific cluster configuration]({{< ref ".." >}}). |
| 44 | + |
| 45 | +### Calico Example |
| 46 | + |
| 47 | +To enable deployment of Calico on a cluster, specify the following values: |
| 48 | + |
| 49 | +```yaml |
| 50 | +apiVersion: cluster.x-k8s.io/v1beta1 |
| 51 | +kind: Cluster |
| 52 | +metadata: |
| 53 | + name: <NAME> |
| 54 | +spec: |
| 55 | + topology: |
| 56 | + variables: |
| 57 | + - name: clusterConfig |
| 58 | + value: |
| 59 | + addons: |
| 60 | + cni: |
| 61 | + provider: Calico |
| 62 | + strategy: HelmAddon |
| 63 | +``` |
| 64 | + |
| 65 | +### ClusterResourceSet strategy |
| 66 | + |
| 67 | +To deploy the addon via `ClusterResourceSet` replace the value of `strategy` with `ClusterResourceSet`. |
| 68 | + |
| 69 | +When using the `ClusterResourceSet` strategy, the hook creates two `ClusterResourceSets`: one to deploy the Tigera |
| 70 | +Operator, and one to deploy Calico via the Tigera `Installation` CRD. The Tigera Operator CRS is shared between all |
| 71 | +clusters in the operator, whereas the Calico installation CRS is unique per cluster. |
| 72 | + |
| 73 | +As ClusterResourceSets must exist in the same name as the cluster they apply to, the lifecycle hook copies default |
| 74 | +ConfigMaps from the same namespace as the CAPI runtime extensions hook pod is running in. This enables users to |
| 75 | +configure defaults specific for their environment rather than compiling the defaults into the binary. |
| 76 | + |
| 77 | +The Helm chart comes with default configurations for the Calico Installation CRS per supported provider, but overriding |
| 78 | +is possible. To do so, specify: |
| 79 | + |
| 80 | +```shell |
| 81 | +--set-file handlers.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.configMap.content=<file> |
| 82 | +``` |
| 83 | + |
| 84 | +[Cluster API Add-on Provider for Helm]: https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm |
0 commit comments