sigs.k8s.io/cluster-api@v1.7.1/docs/book/src/clusterctl/configuration.md (about) 1 # clusterctl Configuration File 2 3 The `clusterctl` config file is located at `$XDG_CONFIG_HOME/cluster-api/clusterctl.yaml`. 4 It can be used to: 5 6 - Customize the list of providers and provider repositories. 7 - Provide configuration values to be used for variable substitution when installing providers or creating clusters. 8 - Define image overrides for air-gapped environments. 9 10 ## Provider repositories 11 12 The `clusterctl` CLI is designed to work with providers implementing the [clusterctl Provider Contract](provider-contract.md). 13 14 Each provider is expected to define a provider repository, a well-known place where release assets are published. 15 16 By default, `clusterctl` ships with providers sponsored by SIG Cluster 17 Lifecycle. Use `clusterctl config repositories` to get a list of supported 18 providers and their repository configuration. 19 20 Users can customize the list of available providers using the `clusterctl` configuration file, as shown in the following example: 21 22 ```yaml 23 providers: 24 # add a custom provider 25 - name: "my-infra-provider" 26 url: "https://github.com/myorg/myrepo/releases/latest/infrastructure-components.yaml" 27 type: "InfrastructureProvider" 28 # override a pre-defined provider 29 - name: "cluster-api" 30 url: "https://github.com/myorg/myforkofclusterapi/releases/latest/core-components.yaml" 31 type: "CoreProvider" 32 # add a custom provider on a self-hosted GitLab (host should start with "gitlab.") 33 - name: "my-other-infra-provider" 34 url: "https://gitlab.example.com/api/v4/projects/myorg%2Fmyrepo/packages/generic/myrepo/v1.2.3/infrastructure-components.yaml" 35 type: "InfrastructureProvider" 36 # override a pre-defined provider on a self-hosted GitLab (host should start with "gitlab.") 37 - name: "kubeadm" 38 url: "https://gitlab.example.com/api/v4/projects/external-packages%2Fcluster-api/packages/generic/cluster-api/v1.1.3/bootstrap-components.yaml" 39 type: "BootstrapProvider" 40 ``` 41 42 See [provider contract](provider-contract.md) for instructions about how to set up a provider repository. 43 44 **Note**: It is possible to use the `${HOME}` and `${CLUSTERCTL_REPOSITORY_PATH}` environment variables in `url`. 45 46 ## Variables 47 48 When installing a provider `clusterctl` reads a YAML file that is published in the provider repository. While executing 49 this operation, `clusterctl` can substitute certain variables with the ones provided by the user. 50 51 The same mechanism also applies when `clusterctl` reads the cluster templates YAML published in the repository, e.g. 52 when injecting the Kubernetes version to use, or the number of worker machines to create. 53 54 The user can provide values using OS environment variables, but it is also possible to add 55 variables in the `clusterctl` config file: 56 57 ```yaml 58 # Values for environment variable substitution 59 AWS_B64ENCODED_CREDENTIALS: XXXXXXXX 60 ``` 61 62 The format of keys should always be `UPPERCASE_WITH_UNDERSCORE` for both OS environment variables and in the `clusterctl` 63 config file (NOTE: this limitation derives from [Viper](https://github.com/spf13/viper), the library we are using internally to retrieve variables). 64 65 In case a variable is defined both in the config file and as an OS environment variable, 66 the environment variable takes precedence. 67 68 ## Cert-Manager configuration 69 70 While doing init, clusterctl checks if there is a version of cert-manager already installed. If not, clusterctl will 71 install a default version. 72 73 By default, cert-manager will be fetched from `https://github.com/cert-manager/cert-manager/releases`; however, if the user 74 wants to use a different repository, it is possible to use the following configuration: 75 76 ```yaml 77 cert-manager: 78 url: "/Users/foo/.config/cluster-api/dev-repository/cert-manager/latest/cert-manager.yaml" 79 ``` 80 81 **Note**: It is possible to use the `${HOME}` and `${CLUSTERCTL_REPOSITORY_PATH}` environment variables in `url`. 82 83 Similarly, it is possible to override the default version installed by clusterctl by configuring: 84 85 ```yaml 86 cert-manager: 87 ... 88 version: "v1.1.1" 89 ``` 90 91 For situations when resources are limited or the network is slow, the cert-manager wait time to be running can be customized by adding a field to the clusterctl config file, for example: 92 93 ```yaml 94 cert-manager: 95 ... 96 timeout: 15m 97 ``` 98 99 The value string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". 100 101 If no value is specified, or the format is invalid, the default value of 10 minutes will be used. 102 103 Please note that the configuration above will be considered also when doing `clusterctl upgrade plan` or `clusterctl upgrade plan`. 104 105 ## Migrating to user-managed cert-manager 106 107 You may want to migrate to a user-managed cert-manager further down the line, after initialising cert-manager on the management cluster through `clusterctl`. 108 109 `clusterctl` looks for the label `clusterctl.cluster.x-k8s.io/core=cert-manager` on all api resources in the `cert-manager` namespace. If it finds the label, `clusterctl` will manage the cert-manager deployment. You can list all the resources with that label by running: 110 ```bash 111 kubectl api-resources --verbs=list -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -A --selector=clusterctl.cluster.x-k8s.io/core=cert-manager 112 ``` 113 114 If you want to manage and install your own cert-manager, you'll need to remove this label from all API resources. 115 116 <aside class="note warning"> 117 118 <h1>Warning</h1> 119 120 Cluster API has a direct dependency on cert-manager. It's possible you could encounter issues if you use a different version to the Cluster API default version. 121 122 </aside> 123 124 ## Avoiding GitHub rate limiting 125 126 Follow [this](./overview.md#avoiding-github-rate-limiting) 127 128 ## Overrides Layer 129 130 <aside class="note warning"> 131 132 <h1> Warning! </h1> 133 134 Overrides only provide file replacements; instead, provider version resolution is based only on the actual repository structure. 135 136 </aside> 137 138 `clusterctl` uses an overrides layer to read in injected provider components, 139 cluster templates and metadata. By default, it reads the files from 140 `$XDG_CONFIG_HOME/cluster-api/overrides`. 141 142 The directory structure under the `overrides` directory should follow the 143 template: 144 145 ``` 146 <providerType-providerName>/<version>/<fileName> 147 ``` 148 149 For example, 150 151 ``` 152 ├── bootstrap-kubeadm 153 │ └── v1.1.5 154 │ └── bootstrap-components.yaml 155 ├── cluster-api 156 │ └── v1.1.5 157 │ └── core-components.yaml 158 ├── control-plane-kubeadm 159 │ └── v1.1.5 160 │ └── control-plane-components.yaml 161 └── infrastructure-aws 162 └── v0.5.0 163 ├── cluster-template-dev.yaml 164 └── infrastructure-components.yaml 165 ``` 166 167 For developers who want to generate the overrides layer, see 168 [Build artifacts locally](developers.md#build-artifacts-locally). 169 170 Once these overrides are specified, `clusterctl` will use them instead of 171 getting the values from the default or specified providers. 172 173 One example usage of the overrides layer is that it allows you to deploy 174 clusters with custom templates that may not be available from the official 175 provider repositories. 176 For example, you can now do: 177 178 ```bash 179 clusterctl generate cluster mycluster --flavor dev --infrastructure aws:v0.5.0 -v5 180 ``` 181 182 The `-v5` provides verbose logging which will confirm the usage of the 183 override file. 184 185 ```bash 186 Using Override="cluster-template-dev.yaml" Provider="infrastructure-aws" Version="v0.5.0" 187 ``` 188 189 Another example, if you would like to deploy a custom version of CAPA, you can 190 make changes to `infrastructure-components.yaml` in the overrides folder and 191 run, 192 193 ```bash 194 clusterctl init --infrastructure aws:v0.5.0 -v5 195 ``` 196 197 ```bash 198 ... 199 Using Override="infrastructure-components.yaml" Provider="infrastructure-aws" Version="v0.5.0" 200 ... 201 ``` 202 203 If you prefer to have the overrides directory at a different location (e.g. 204 `/Users/foobar/workspace/dev-releases`) you can specify the overrides 205 directory in the clusterctl config file as 206 207 ```yaml 208 overridesFolder: /Users/foobar/workspace/dev-releases 209 ``` 210 211 **Note**: It is possible to use the `${HOME}` and `${CLUSTERCTL_REPOSITORY_PATH}` environment variables in `overridesFolder`. 212 213 ## Image overrides 214 215 <aside class="note warning"> 216 217 <h1> Warning! </h1> 218 219 Image override is an advanced feature and wrong configuration can easily lead to non-functional clusters. 220 It's strongly recommended to test configurations on dev/test environments before using this functionality in production. 221 222 This feature must always be used in conjunction with 223 [version tag](commands/init.md#provider-version) when executing clusterctl commands. 224 225 </aside> 226 227 When working in air-gapped environments, it's necessary to alter the manifests to be installed in order to pull 228 images from a local/custom image repository instead of public ones (e.g. `gcr.io`, or `quay.io`). 229 230 The `clusterctl` configuration file can be used to instruct `clusterctl` to override images automatically. 231 232 This can be achieved by adding an `images` configuration entry as shown in the example: 233 234 ```yaml 235 images: 236 all: 237 repository: myorg.io/local-repo 238 ``` 239 240 Please note that the image override feature allows for more fine-grained configuration, allowing to set image 241 overrides for specific components, for example: 242 243 ```yaml 244 images: 245 all: 246 repository: myorg.io/local-repo 247 cert-manager: 248 tag: v1.5.3 249 ``` 250 251 In this example we are overriding the image repository for all the components and the image tag for 252 all the images in the cert-manager component. 253 254 If required to alter only a specific image you can use: 255 256 ```yaml 257 images: 258 all: 259 repository: myorg.io/local-repo 260 cert-manager/cert-manager-cainjector: 261 tag: v1.5.3 262 ``` 263 264 ## Debugging/Logging 265 266 To have more verbose logs you can use the `-v` flag when running the `clusterctl` and set the level of the logging verbose with a positive integer number, ie. `-v 3`. 267 268 If you do not want to use the flag every time you issue a command you can set the environment variable `CLUSTERCTL_LOG_LEVEL` or set the variable in the `clusterctl` config file located by default at `$XDG_CONFIG_HOME/cluster-api/clusterctl.yaml`. 269 270 271 ## Skip checking for updates 272 273 `clusterctl` automatically checks for new versions every time it is used. If you do not want `clusterctl` to check for new updates you can set the environment variable `CLUSTERCTL_DISABLE_VERSIONCHECK` to `"true"` or set the variable in the `clusterctl` config file located by default at `$XDG_CONFIG_HOME/cluster-api/clusterctl.yaml`.