|
| 1 | +# clusterctl init |
| 2 | + |
| 3 | +The `clusterctl init` command installs the Cluster API components and transforms the Kubernetes cluster |
| 4 | +into a management cluster. |
| 5 | + |
| 6 | +This document provides more detail on how `clusterctl init` works and on the supported options for customizing your |
| 7 | +management cluster. |
| 8 | + |
| 9 | +## Defining the management cluster |
| 10 | + |
| 11 | +The `clusterctl init` command accepts in input a list of providers to install. |
| 12 | + |
| 13 | +<aside class="note"> |
| 14 | + |
| 15 | +<h1> Which providers can I use? </h1> |
| 16 | + |
| 17 | +You can use the `clusterctl config providers` command to get the list of supported providers. |
| 18 | + |
| 19 | +If the provider of your choice is missing, you can customize the list of supported providers by using the |
| 20 | +[clusterctl configuration](../configuration.md) file. |
| 21 | + |
| 22 | +</aside> |
| 23 | + |
| 24 | +#### Automatically installed providers |
| 25 | + |
| 26 | +The `clusterctl init` command automatically adds the Cluster API core provider and |
| 27 | +the kubeadm bootstrap provider to the list of providers to install. This allows users to use a concise command syntax for initializing a management cluster. e.g. |
| 28 | +use the command: |
| 29 | + |
| 30 | +`clusterctl init --infrastracture aws` |
| 31 | + |
| 32 | +To install the `aws` infrastructure provider, the Cluster API core provider and the kubeadm bootstrap provider |
| 33 | + |
| 34 | +<aside class="note warning"> |
| 35 | + |
| 36 | +<h1> Warning </h1> |
| 37 | + |
| 38 | +The Cluster API core provider and the kubeadm bootstrap provider are automatically installed only if: |
| 39 | +- The user doesn't explicitly require to install a core/bootstrap provider using the `--core` or the `-bootstrap` flags; |
| 40 | +- There is not another instance of core provider/bootstrap provider already installed in the cluster; |
| 41 | + |
| 42 | +Please note that the second rule allows to execute `clusterctl init` more times: the first call actually initializes |
| 43 | +the management cluster, while the subsequent calls can be used to add more providers. |
| 44 | + |
| 45 | +</aside> |
| 46 | + |
| 47 | + |
| 48 | +#### Provider version |
| 49 | + |
| 50 | +The `clusterctl init` command by default installs the latest version available for each selected provider. |
| 51 | + |
| 52 | +<aside class="note"> |
| 53 | + |
| 54 | +<h1> Is it possible to install a specific version of a provider? </h1> |
| 55 | + |
| 56 | +You can specify the provider version by appending a version tag to the provider name, e.g. `aws:v0.4.1`. |
| 57 | + |
| 58 | +</aside> |
| 59 | + |
| 60 | +#### Target namespace |
| 61 | + |
| 62 | +The `clusterctl init` command by default installs each provider in the default target namespace defined by each provider, e.g. `capi-system` for the Cluster API core provider. |
| 63 | + |
| 64 | +See the provider documentation for more details. |
| 65 | + |
| 66 | +<aside class="note"> |
| 67 | + |
| 68 | +<h1> Is it possible to change the target namespace ? </h1> |
| 69 | + |
| 70 | +You can specify the target namespace by using the `--target-namespace` flag. |
| 71 | + |
| 72 | +Please, note that the `--target-namespace` flag applies to all the providers to be installed during a `clusterctl init` operation. |
| 73 | + |
| 74 | +</aside> |
| 75 | + |
| 76 | +<aside class="note warning"> |
| 77 | + |
| 78 | +<h1>Warning</h1> |
| 79 | + |
| 80 | +The `clusterctl init` command forbids users from installing two instances of the *same* provider in the |
| 81 | +same target namespace. |
| 82 | + |
| 83 | +</aside> |
| 84 | + |
| 85 | +#### Watching namespace |
| 86 | + |
| 87 | +The `clusterctl init` command by default installs each provider configured for watching objects in all namespaces. |
| 88 | + |
| 89 | +<aside class="note"> |
| 90 | + |
| 91 | +<h1> Is it possible to change the watching namespace ? </h1> |
| 92 | + |
| 93 | +You can specify the target namespace by using the `--watching-namespace` flag. |
| 94 | + |
| 95 | +Please, note that the `--watching-namespace` flag applies to all the providers to be installed during a `clusterctl init` operation. |
| 96 | + |
| 97 | +</aside> |
| 98 | + |
| 99 | +<aside class="note warning"> |
| 100 | + |
| 101 | +<h1>Warning</h1> |
| 102 | + |
| 103 | +The `clusterctl init` command forbids users from installing two instances of the *same* provider watching for objects in the |
| 104 | +same namespace. |
| 105 | + |
| 106 | +</aside> |
| 107 | + |
| 108 | +#### Multi-tenancy |
| 109 | + |
| 110 | +*Multi-tenancy* for Cluster API means a management cluster where multiple instances of the same provider are installed. |
| 111 | + |
| 112 | +The user can achieve multi-tenancy configurations with `clusterctl` by a combination of: |
| 113 | + |
| 114 | +- Multiple calls to `clusterctl init`; |
| 115 | +- Usage of the `--target-namespace` flag; |
| 116 | +- Usage of the `--watching-namespace` flag; |
| 117 | + |
| 118 | +The `clusterctl` command officially supports the following multi-tenancy configurations: |
| 119 | + |
| 120 | +{{#tabs name:"tab-multi-tenancy" tabs:"n-Infra, n-Core"}} |
| 121 | +{{#tab n-Infra}} |
| 122 | +A management cluster with <em>n (n>1)</em> instances of an infrastructure provider, and <em>only one</em> instance |
| 123 | +of Cluster API core provider, bootstrap provider and control plane provider (optional). |
| 124 | + |
| 125 | +For example: |
| 126 | + |
| 127 | +* Cluster API core provider installed in the `capi-system` namespace, watching objects in all namespaces; |
| 128 | +* The kubeadm bootstrap provider in `capbpk-system`, watching all namespaces; |
| 129 | +* The kubeadm control plane provider in `cacpk-system`, watching all namespaces; |
| 130 | +* The `aws` infrastructure provider in `aws-system1`, watching objects in `aws-system1` only; |
| 131 | +* The `aws` infrastructure provider in `aws-system2`, watching objects in `aws-system2` only; |
| 132 | +* etc. (more instances of the `aws` provider) |
| 133 | + |
| 134 | +{{#/tab }} |
| 135 | +{{#tab n-Core}} |
| 136 | +A management cluster with <em>n (n>1)</em> instances of the Cluster API core provider, each one with <em>a dedicated</em> |
| 137 | +instance of infrastructure provider, bootstrap provider, and control plane provider (optional). |
| 138 | + |
| 139 | +For example: |
| 140 | + |
| 141 | +* A Cluster API core provider installed in the `capi-system1` namespace, watching objects in `capi-system1` only, and with: |
| 142 | + * The kubeadm bootstrap provider in `capi-system1`, watching `capi-system1`; |
| 143 | + * The kubeadm control plane provider in `capi-system1`, watching `capi-system1`; |
| 144 | + * The `aws` infrastructure provider in `capi-system1`, watching objects `capi-system1`; |
| 145 | +* A Cluster API core provider installed in the `capi-system2` namespace, watching objects in `capi-system2` only, and with: |
| 146 | + * The kubeadm bootstrap provider in `capi-system2`, watching `capi-system2`; |
| 147 | + * The kubeadm control plane provider in `capi-system2`, watching `capi-system2`; |
| 148 | + * The `aws` infrastructure provider in `capi-system2`, watching objects `capi-system2`; |
| 149 | +* etc. (more instances of the Cluster API core provider and the dedicated providers) |
| 150 | + |
| 151 | + |
| 152 | +{{#/tab }} |
| 153 | +{{#/tabs }} |
| 154 | + |
| 155 | + |
| 156 | +<aside class="note warning"> |
| 157 | + |
| 158 | +<h1>Warning</h1> |
| 159 | + |
| 160 | +It is possible to achieve many other different configurations of multi-tenancy with `clusterctl`. |
| 161 | + |
| 162 | +However, the user should be aware that configurations not listed above are not verified by the `clusterctl`tests |
| 163 | +and support will be provided at best effort only. |
| 164 | + |
| 165 | +</aside> |
| 166 | + |
| 167 | + |
| 168 | +## Provider repositories |
| 169 | + |
| 170 | +To access provider specific information, such as the components YAML to be used for installing a provider, |
| 171 | +`clusterctl init` accesses the **provider repositories**, that are well-known places where the release assets for |
| 172 | +a provider are published. |
| 173 | + |
| 174 | +See [clusterctl configuration](../configuration.md) for more info about provider repository configurations. |
| 175 | + |
| 176 | +<aside class="note"> |
| 177 | + |
| 178 | +<h1> Is it possible to override files read from a provider repository? </h1> |
| 179 | + |
| 180 | +If, for any reasons, the user wants to replace the assets available on a provider repository with a locally available asset, |
| 181 | +the user is required to save the file under `$HOME/.cluster-api/overrides/<provider-name>/<version>/<file-name.yaml>`. |
| 182 | + |
| 183 | +</aside> |
| 184 | + |
| 185 | +## Variable substitution |
| 186 | +Providers can use variables in the components YAML published in the provider's repository. |
| 187 | + |
| 188 | +During `clusterctl init`, those variables are replaced with environment variables or with variables read from the |
| 189 | +[clusterctl configuration](../configuration.md). |
| 190 | + |
| 191 | +<aside class="note warning"> |
| 192 | + |
| 193 | +<h1> Action Required </h1> |
| 194 | + |
| 195 | +The user should ensure the variables required by a provider are set in advance. |
| 196 | + |
| 197 | +</aside> |
| 198 | + |
| 199 | +<aside class="note"> |
| 200 | + |
| 201 | +<h1> How can I known which variables a provider requires? </h1> |
| 202 | + |
| 203 | +Users can refer to the provider documentation for the list of variables to be set or use the |
| 204 | +`clusterctl config provider <provider-name>` command to get a list of expected variable names. |
| 205 | + |
| 206 | +</aside> |
| 207 | + |
| 208 | +## Additional information |
| 209 | + |
| 210 | +When installing a provider, the `clusterctl init` command executes a set of steps to simplify |
| 211 | +the lifecycle management of the provider's components. |
| 212 | + |
| 213 | +* All the provider's components are labeled, so they can be easily identified in |
| 214 | +subsequent moments of the provider's lifecycle, e.g. upgrades. |
| 215 | + |
| 216 | + ```bash |
| 217 | + labels: |
| 218 | + - clusterctl.cluster.x-k8s.io: "" |
| 219 | + - clusterctl.cluster.x-k8s.io/provider: "<provider-name>" |
| 220 | + ``` |
| 221 | + |
| 222 | +* An additional `Provider` object is created in the target namespace where the provider is installed. |
| 223 | +This object keeps track of the provider version, the watching namespace, and other useful information |
| 224 | +for the inventory of the providers currently installed in the management cluster. |
| 225 | + |
| 226 | +<aside class="note warning"> |
| 227 | + |
| 228 | +<h1>Warning</h1> |
| 229 | + |
| 230 | +The `clusterctl.cluster.x-k8s.io` labels and the `Provider` objects MUST NOT altered. |
| 231 | +If this happens, there are no guarantees about the proper functioning of `clusterctl`. |
| 232 | + |
| 233 | +</aside> |
0 commit comments