|
| 1 | +## How To Create Local Repositories for Cluster-API providers to user with clusterctl |
| 2 | + |
| 3 | +### Why? |
| 4 | + |
| 5 | +You might want to use `clusterctl init` to install your provider. If you are in your development phase, you cannot yet make use of that |
| 6 | +as `clusterctl` will either try to find providers, which are hardcoded in the CLI source code, you will have to specify some kind of configuration file |
| 7 | +that will point to the urls, where your providers are located. By convention, there must a `*-components.yaml` file, which is publicly available (e.g. Github releases). |
| 8 | + |
| 9 | +There are a few naming and versioning conventions that need to be fulfilled in order to let clusterctl generate the correct manifests. |
| 10 | + |
| 11 | +The following section will explain, how create a configuration file, which will allow you to setup the proxmox cluster-api provider on a kubernetes cluster |
| 12 | +using `clusterctl init` |
| 13 | + |
| 14 | +### Guide |
| 15 | + |
| 16 | +in order for clusterctl to make use of local providers, we need some kind of contract files, which have to be available. |
| 17 | +`metadata.yaml` and `*-components.yaml` |
| 18 | + |
| 19 | +the `*-components.yaml` file depends on the type of provider. For example `infrastructure-components.yaml, core-components.yaml`. |
| 20 | + |
| 21 | +As an example of creating local repositories for cluster-api, kubeadm and proxmox, we first have to add a `clusterctl-settings.json` to our `proxmox` repository: |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "name": "infrastructure-proxmox", |
| 26 | + "config": { |
| 27 | + "componentsFile": "infrastructure-components.yaml", |
| 28 | + "nextVersion": "v0.1.0" |
| 29 | + } |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +The labeling has to start with `infrastructure-` as the clusterctl script expects precise labelling |
| 34 | +Then we also have to make sure, there is a `metadata.yaml` file in the root directory of the promox repository |
| 35 | + |
| 36 | +```yaml |
| 37 | +# metadata.yaml |
| 38 | +apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 |
| 39 | +kind: Metadata |
| 40 | +releaseSeries: |
| 41 | +- major: 0 |
| 42 | + minor: 1 |
| 43 | + contract: v1beta1 |
| 44 | +``` |
| 45 | +
|
| 46 | +Make sure that a `major` and `minor` version in the `metadata.yaml` matches the `nextVersion` in the `clusterctl-settings.json` file |
| 47 | + |
| 48 | +next we create another `clusterctl-settings.json` file in a locally checked out [cluster-api](https://github.com/kubernetes-sigs/cluster-api) repository. |
| 49 | +```json |
| 50 | +{ |
| 51 | + "providers": ["cluster-api", "infrastructure-proxmox", "bootstrap-kubeadm", "control-plane-kubeadm", "ipam-in-cluster"], |
| 52 | + "provider_repos": ["../cluster-api-provider-proxmox", "../cluster-api-ipam-provider-in-cluster/"] |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +The path to the different repositories must be from the root of the cluster-api repository. |
| 57 | +Make sure to clone [IPAM provider](https://github.com/kubernetes-sigs/cluster-api-ipam-provider-in-cluster) in same directory. |
| 58 | + |
| 59 | +Next we have to execute the helper script in the cluster-api repository to generate local providers |
| 60 | + |
| 61 | +```bash |
| 62 | +# go to the root directory of cluster api |
| 63 | +cd <cluster-api-repo-path> |
| 64 | +
|
| 65 | +# run the helper script |
| 66 | +./cmd/clusterctl/hack/create-local-repository.py |
| 67 | +``` |
| 68 | + |
| 69 | +next you can find the generated files in: |
| 70 | + |
| 71 | +`~/.config/cluster-api/dev-repository` |
| 72 | + |
| 73 | +The cli tool will also tell you how to invoke the command properly. Make sure that you use the correct config file |
| 74 | + |
| 75 | +Prior to executing `clusterctl init`, make sure to export the required environment variables: |
| 76 | + |
| 77 | +``` |
| 78 | +# required |
| 79 | +export PROXMOX_URL=https://pve.example.com |
| 80 | +export PROXMOX_TOKEN="<TOKEN_ID>" |
| 81 | +export PROXMOX_SECRET="<TOKEN_SECRET>" |
| 82 | +
|
| 83 | +# optional |
| 84 | +export CAPMOX_LOGLEVEL=4 |
| 85 | +``` |
0 commit comments