|
| 1 | +When using the `clusterctl` you can generate your own cluster spec from a |
| 2 | +template. |
| 3 | + |
| 4 | +This is what happens when you run: |
| 5 | + |
| 6 | +```sh |
| 7 | +$ clusterctl config cluster <cluster-name> --infrastructure packet > |
| 8 | +out/cluster.yaml |
| 9 | +``` |
| 10 | + |
| 11 | +The workflow triggered by that command summarized here: |
| 12 | + |
| 13 | +1. Based on the `--infrastructure` option it goes to the right repository and it |
| 14 | + looks for the `latest` release. At the time I am writing it is |
| 15 | + [v0.3.0](gh-release-v030). |
| 16 | +2. `clusterctl` lookup a file called `cluster-template.yaml` from the release artifacts |
| 17 | +3. `clusterctl` uses `cluster-template.yaml` plus a set of environment variables |
| 18 | + that you can find described in the README.md to generate the cluster |
| 19 | + specification |
| 20 | +4. With the command `> out/cluster.yaml` the generated spec gets moved to |
| 21 | + `./out/cluster.yaml` other than being printed to `stdout`. |
| 22 | + |
| 23 | +This is good if you do not have particular needs or if you are trying capp. |
| 24 | + |
| 25 | +The current `cluster-templates.yaml` uses `apt` and it depends upon `Ubuntu`. |
| 26 | +But you can open and modify it to match your requirements. |
| 27 | + |
| 28 | +## When should I modify the template? |
| 29 | + |
| 30 | +Every time you feel like the default one is not enough, or if you need more |
| 31 | +automation. Here a few examples: |
| 32 | + |
| 33 | +1. ClusterAPI decided to leave the CNI configuration out from its workflow |
| 34 | + because there are too many of them. If you want to automate that part and |
| 35 | + let's suppose you want `flannel` you can add the following line to |
| 36 | + `postKubeadmCommands` for the `KubeadmControlPlane` resource: |
| 37 | + |
| 38 | +```sh |
| 39 | +kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml |
| 40 | +``` |
| 41 | + |
| 42 | +2. If you want to use an operating system that is not Ubuntu you can change the |
| 43 | + `preKubeadmCommands` for the `KubeadmControlPlane` and the |
| 44 | + `KubeadmConfigTemplate` to use kubernetes binaries or a different package |
| 45 | + manager. |
| 46 | + |
| 47 | +3. (2a) If you want to change operating system you have to change the `OS` field |
| 48 | + for the `PacketMachineTemplate` resource |
| 49 | + |
| 50 | + |
| 51 | +[gh-release-v030]: https://github.com/kubernetes-sigs/cluster-api-provider-packet/releases/tag/v0.3.0 |
0 commit comments