|
1 |
| -# Using clusterctl while developing cluster API |
| 1 | +# clusterctl for Developers |
| 2 | + |
| 3 | +This document describes how to use `clusterctl` during the development workflow. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +* A Cluster API development setup (go, git, etc.) |
| 8 | +* A local clone of the Cluster API GitHub repository |
| 9 | +* A local clone of the GitHub repositories for the providers you want to install |
| 10 | + |
| 11 | +## Getting started |
| 12 | + |
| 13 | +### Build clustertl |
| 14 | + |
| 15 | +From the root of the local copy of Cluster API, you can build the `clusterctl` binary by running: |
| 16 | + |
| 17 | +```shell |
| 18 | +make clusterctl |
| 19 | +``` |
| 20 | + |
| 21 | +The output of the build is saved in the `bin/` folder; In order to use it you have to specify |
| 22 | +the full path, create an alias or copy it into a folder under your `$PATH`. |
| 23 | + |
| 24 | +### Create a clusterctl-settings.json file |
| 25 | + |
| 26 | +Next, create a `clusterctl-settings.json` file and place it in your local copy of Cluster API. Here is an example: |
| 27 | + |
| 28 | +```yaml |
| 29 | +{ |
| 30 | + "providers": [ "cluster-api", "kubeadm-bootstrap", "aws"], |
| 31 | + "provider_repos": ["../cluster-api-provider-aws"] |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +**enable_providers** (Array[]String, default=[]): A list of the providers to enable. See [available providers]() for more details. |
| 36 | + |
| 37 | +**provider_repos** (Array[]String, default=[]): A list of paths to all the providers you want to use. Each provider must have |
| 38 | +a `clusterctl-settings.json` file describing how to build the provider assets. |
| 39 | + |
| 40 | +## Run the local-overrides hack! |
| 41 | + |
| 42 | +You can now run the local-overrides hack from the root of the local copy of Cluster API: |
| 43 | + |
| 44 | +```shell |
| 45 | +cmd/clusterctl/hack/local-overrides.py |
| 46 | +``` |
| 47 | + |
| 48 | +The script reads from the local repositories of the providers you want to install, builds the providers assets, |
| 49 | +and place them in a local override folder located under `$HOME/.cluster-api/overrides/`. |
| 50 | +Additionally, the command output provide you `clusterctl init` command with all the necessary flags. |
| 51 | + |
| 52 | +```shell |
| 53 | +clusterctl local overrides generated from local repositories for the cluster-api, kubeadm-bootstrap, aws providers. |
| 54 | +in order to use them, please run: |
| 55 | + |
| 56 | +clusterctl init --core cluster-api:v0.3.0 --bootstrap kubeadm-bootstrap:v0.3.0 --infrastructure aws:v0.5.0 |
| 57 | +``` |
| 58 | + |
| 59 | +## Available providers |
| 60 | + |
| 61 | +The following providers are currently defined in the script: |
| 62 | + |
| 63 | +* `cluster-api` |
| 64 | +* `kubeadm-bootstrap` |
| 65 | +* `kubeadm-controlplane` |
| 66 | +* `docker` |
| 67 | + |
| 68 | +More providers can be added by editing the `clusterctl-settings.json` in your local copy of Cluster API; |
| 69 | +please note that each `provider_repo` should have its own `clusterctl-settings.json` describing how to build the provider assets, e.g. |
| 70 | + |
| 71 | +```yaml |
| 72 | +{ |
| 73 | + "name": "aws", |
| 74 | + "config": { |
| 75 | + "componentsFile": "infrastructure-components.yaml", |
| 76 | + "nextVersion": "v0.5.0", |
| 77 | + "type": "InfrastructureProvider" |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
0 commit comments