Skip to content

Commit 1a539da

Browse files
authored
Merge pull request #4778 from fabriziopandini/update-book-for-clusterctl-generate-cluster
📖 update book for using clusterctl generate cluster
2 parents e970639 + 15e72d4 commit 1a539da

File tree

14 files changed

+135
-27
lines changed

14 files changed

+135
-27
lines changed

cmd/clusterctl/client/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (c *clusterctlClient) Init(options InitOptions) ([]Components, error) {
121121
log.Info("")
122122
log.Info("You can now create your first workload cluster by running the following:")
123123
log.Info("")
124-
log.Info(" clusterctl config cluster [name] --kubernetes-version [version] | kubectl apply -f -")
124+
log.Info(" clusterctl generate cluster [name] --kubernetes-version [version] | kubectl apply -f -")
125125
log.Info("")
126126
}
127127

docs/book/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- [clusterctl CLI](./clusterctl/overview.md)
2222
- [clusterctl Commands](clusterctl/commands/commands.md)
2323
- [init](clusterctl/commands/init.md)
24-
- [config cluster](clusterctl/commands/config-cluster.md)
24+
- [generate cluster](clusterctl/commands/generate-cluster.md)
2525
- [generate yaml](clusterctl/commands/generate-yaml.md)
2626
- [get kubeconfig](clusterctl/commands/get-kubeconfig.md)
2727
- [describe cluster](clusterctl/commands/describe-cluster.md)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# clusterctl Commands
22

33
* [`clusterctl init`](init.md)
4-
* [`clusterctl config cluster`](config-cluster.md)
4+
* [`clusterctl generate cluster`](generate-cluster.md)
55
* [`clusterctl generate yaml`](generate-yaml.md)
66
* [`clusterctl get kubeconfig`](get-kubeconfig.md)
77
* [`clusterctl describe cluster`](describe-cluster.md)
@@ -10,3 +10,4 @@
1010
* [`clusterctl delete`](delete.md)
1111
* [`clusterctl completion`](completion.md)
1212
* [`clusterctl alpha rollout`](alpha-rollout.md)
13+
* [`clusterctl config cluster` (deprecated)](config-cluster.md)

docs/book/src/clusterctl/commands/config-cluster.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# clusterctl config cluster
22

3+
<aside class="note warning">
4+
5+
<h1> Warning! </h1>
6+
7+
This command has been deprecated and it will be removed in future releases.
8+
Use [`clusterctl generate cluster`](generate-cluster.md).
9+
10+
</aside>
11+
312
The `clusterctl config cluster` command returns a YAML template for creating a workload cluster.
413

514
For example
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# clusterctl generate cluster
2+
3+
The `clusterctl generate cluster` command returns a YAML template for creating a workload cluster.
4+
5+
For example
6+
7+
```
8+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 --control-plane-machine-count=3 --worker-machine-count=3 > my-cluster.yaml
9+
```
10+
11+
Geenerates a YAML file named `my-cluster.yaml` with a predefined list of Cluster API objects; Cluster, Machines,
12+
Machine Deployments, etc. to be deployed in the current namespace (in case, use the `--target-namespace` flag to
13+
specify a different target namespace).
14+
15+
Then, the file can be modified using your editor of choice; when ready, run the following command
16+
to apply the cluster manifest.
17+
18+
```
19+
kubectl apply -f my-cluster.yaml
20+
```
21+
22+
### Selecting the infrastructure provider to use
23+
24+
The `clusterctl generate cluster` command uses smart defaults in order to simplify the user experience; in the example above,
25+
it detects that there is only an `aws` infrastructure provider in the current management cluster and so it automatically
26+
selects a cluster template from the `aws` provider's repository.
27+
28+
In case there is more than one infrastructure provider, the following syntax can be used to select which infrastructure
29+
provider to use for the workload cluster:
30+
31+
```
32+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
33+
--infrastructure aws > my-cluster.yaml
34+
```
35+
36+
or
37+
38+
```
39+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
40+
--infrastructure aws:v0.4.1 > my-cluster.yaml
41+
```
42+
43+
### Flavors
44+
45+
The infrastructure provider authors can provide different types of cluster templates, or flavors; use the `--flavor` flag
46+
to specify which flavor to use; e.g.
47+
48+
```
49+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
50+
--flavor high-availability > my-cluster.yaml
51+
```
52+
53+
Please refer to the providers documentation for more info about available flavors.
54+
55+
### Alternative source for cluster templates
56+
57+
clusterctl uses the provider's repository as a primary source for cluster templates; the following alternative sources
58+
for cluster templates can be used as well:
59+
60+
#### ConfigMaps
61+
62+
Use the `--from-config-map` flag to read cluster templates stored in a Kubernetes ConfigMap; e.g.
63+
64+
```
65+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
66+
--from-config-map my-templates > my-cluster.yaml
67+
```
68+
69+
Also following flags are available `--from-config-map-namespace` (defaults to current namespace) and `--from-config-map-key`
70+
(defaults to `template`).
71+
72+
#### GitHub or local file system folder
73+
74+
Use the `--from` flag to read cluster templates stored in a GitHub repository or in a local file system folder; e.g.
75+
76+
```
77+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
78+
--from https://github.com/my-org/my-repository/blob/master/my-template.yaml > my-cluster.yaml
79+
```
80+
81+
or
82+
83+
```
84+
clusterctl generate cluster my-cluster --kubernetes-version v1.16.3 \
85+
--from ~/my-template.yaml > my-cluster.yaml
86+
```
87+
88+
### Variables
89+
90+
If the selected cluster template expects some environment variables, the user should ensure those variables are set in advance.
91+
92+
E.g. if the `AWS_CREDENTIALS` variable is expected for a cluster template targeting the `aws` infrastructure, you
93+
should ensure the corresponding environment variable to be set before executing `clusterctl generate cluster`.
94+
95+
Please refer to the providers documentation for more info about the required variables or use the
96+
`clusterctl generate cluster --list-variables` flag to get a list of variables names required by a cluster template.
97+
98+
The [clusterctl configuration](./../configuration.md) file can be used as alternative to environment variables.

docs/book/src/clusterctl/commands/init.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ The user should ensure the variables required by a provider are set in advance.
142142
<h1> How can I known which variables a provider requires? </h1>
143143

144144
Users can refer to the provider documentation for the list of variables to be set or use the
145-
`clusterctl config provider <provider-name>` command to get a list of expected variable names.
145+
`clusterctl generate provider <provider-name> --describe` command to get a list of expected variable names.
146146

147147
</aside>
148148

docs/book/src/clusterctl/commands/move.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This can now be achieved with the following procedure:
5555

5656
1. Create a temporary bootstrap cluster, e.g. using Kind or Minikube
5757
2. Use `clusterctl init` to install the provider components
58-
3. Use `clusterctl config cluster ... | kubectl apply -f -` to provision a target management cluster
58+
3. Use `clusterctl generate cluster ... | kubectl apply -f -` to provision a target management cluster
5959
4. Wait for the target management cluster to be up and running
6060
5. Get the kubeconfig for the new target management cluster
6161
6. Use `clusterctl init` with the new cluster's kubeconfig to install the provider components

docs/book/src/clusterctl/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ provider repositories.
132132
For example, you can now do:
133133
134134
```bash
135-
clusterctl config cluster mycluster --flavor dev --infrastructure aws:v0.5.0 -v5
135+
clusterctl generate cluster mycluster --flavor dev --infrastructure aws:v0.5.0 -v5
136136
```
137137

138138
The `-v5` provides verbose logging which will confirm the usage of the

docs/book/src/clusterctl/developers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The above config file changes the location of the [overrides layer] folder thus
106106
you dev session isn't hijacked by other local artifacts.
107107

108108
With the only exception of the docker provider, the local repository folder does not contain cluster templates,
109-
so the `clusterctl config cluster` command will fail.
109+
so the `clusterctl generate cluster` command will fail.
110110

111111
</aside>
112112

docs/book/src/clusterctl/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mis-configurations or in managing day 2 operations such as upgrades.
1212
* use [`clusterctl upgrade`](commands/upgrade.md) to upgrade Cluster API providers
1313
* use [`clusterctl delete`](commands/delete.md) to delete Cluster API providers
1414

15-
* use [`clusterctl config cluster`](commands/config-cluster.md) to spec out workload clusters
15+
* use [`clusterctl generate cluster`](commands/config-cluster.md) to spec out workload clusters
1616
* use [`clusterctl generate yaml`](commands/generate-yaml.md) to process yaml
1717
* use [`clusterctl get kubeconfig`](commands/get-kubeconfig.md) to get the kubeconfig of an existing workload cluster.
1818
using clusterctl's internal yaml processor.

docs/book/src/clusterctl/provider-contract.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ providers.
194194

195195
### Workload cluster templates
196196

197-
An infrastructure provider could publish a **cluster templates** file to be used by `clusterctl config cluster`.
197+
An infrastructure provider could publish a **cluster templates** file to be used by `clusterctl generate cluster`.
198198
This is single YAML with _all_ the objects required to create a new workload cluster.
199199

200200
The following rules apply:
@@ -205,7 +205,7 @@ Cluster templates MUST be stored in the same folder as the component YAML and fo
205205
1. The default cluster template should be named `cluster-template.yaml`.
206206
2. Additional cluster template should be named `cluster-template-{flavor}.yaml`. e.g `cluster-template-prod.yaml`
207207

208-
`{flavor}` is the name the user can pass to the `clusterctl config cluster --flavor` flag to identify the specific template to use.
208+
`{flavor}` is the name the user can pass to the `clusterctl generate cluster --flavor` flag to identify the specific template to use.
209209

210210
Each provider SHOULD create user facing documentation with the list of available cluster templates.
211211

@@ -224,7 +224,7 @@ notes that are required to assist the user in defining the value for each variab
224224

225225
##### Common variables
226226

227-
The `clusterctl config cluster` command allows user to set a small set of common variables via CLI flags or command arguments.
227+
The `clusterctl generate cluster` command allows user to set a small set of common variables via CLI flags or command arguments.
228228

229229
Templates writers should use the common variables to ensure consistency across providers and a simpler user experience
230230
(if compared to the usage of OS environment variables or the `clusterctl` config file).
@@ -236,7 +236,7 @@ Templates writers should use the common variables to ensure consistency across p
236236
|`--controlplane-machine-count`| `${CONTROL_PLANE_MACHINE_COUNT}` | The number of control plane machines to be added to the workload cluster |
237237
|`--worker-machine-count`| `${WORKER_MACHINE_COUNT}` | The number of worker machines to be added to the workload cluster |
238238

239-
Additionally, the value of the command argument to `clusterctl config cluster <cluster-name>` (`<cluster-name>` in this case), will
239+
Additionally, the value of the command argument to `clusterctl generate cluster <cluster-name>` (`<cluster-name>` in this case), will
240240
be applied to every occurrence of the `${ CLUSTER_NAME }` variable.
241241

242242
## OwnerReferences chain

docs/book/src/developer/e2e.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Using the config file it is possible to:
5555
- A list of additional files to be added to the provider repository, to be used e.g.
5656
to provide `cluster-templates.yaml` files.
5757
- Define the list of variables to be used when doing `clusterctl init` or
58-
`clusterctl config cluster`.
58+
`clusterctl generate cluster`.
5959
- Define a list of intervals to be used in the test specs for defining timeouts for the
6060
wait and `Eventually` methods.
6161
- Define the list of images to be loaded in the management cluster (this is specific to

docs/book/src/tasks/using-kustomize.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Using Kustomize with Workload Cluster Manifests
22

3-
Although the `clusterctl config cluster` command exposes a number of different configuration values
3+
Although the `clusterctl generate cluster` command exposes a number of different configuration values
44
for customizing workload cluster YAML manifests, some users may need additional flexibility above
5-
and beyond what `clusterctl config cluster` or the example "flavor" templates that some CAPI providers
5+
and beyond what `clusterctl generate cluster` or the example "flavor" templates that some CAPI providers
66
supply (as an example, see [these flavor templates](https://github.com/kubernetes-sigs/cluster-api-provider-azure/tree/master/templates/flavors)
77
for the Cluster API Provider for Azure). In the future, a [templating solution](https://github.com/kubernetes-sigs/cluster-api/issues/3252)
88
may be integrated into `clusterctl` to help address this need, but in the meantime users can use
@@ -26,7 +26,7 @@ assume that you are using a directory structure that looks something like this:
2626
```
2727

2828
In the overlay directories, the "base" (unmodified) Cluster API configuration (perhaps generated using
29-
`clusterctl config cluster`) would be referenced as a resource in `kustomization.yaml` using `../../base`.
29+
`clusterctl generate cluster`) would be referenced as a resource in `kustomization.yaml` using `../../base`.
3030

3131
## Example: Using Kustomize to Specify Custom Images
3232

docs/book/src/user/quick-start.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ Your management cluster has been initialized successfully!
321321
322322
You can now create your first workload cluster by running the following:
323323
324-
clusterctl config cluster [name] --kubernetes-version [version] | kubectl apply -f -
324+
clusterctl generate cluster [name] --kubernetes-version [version] | kubectl apply -f -
325325
```
326326
327327
<aside class="note">
@@ -341,13 +341,13 @@ Once the management cluster is ready, you can create your first workload cluster
341341
342342
#### Preparing the workload cluster configuration
343343
344-
The `clusterctl config cluster` command returns a YAML template for creating a [workload cluster].
344+
The `clusterctl generate cluster` command returns a YAML template for creating a [workload cluster].
345345
346346
<aside class="note">
347347
348348
<h1> Which provider will be used for my cluster? </h1>
349349
350-
The `clusterctl config cluster` command uses smart defaults in order to simplify the user experience; in this example,
350+
The `clusterctl generate cluster` command uses smart defaults in order to simplify the user experience; in this example,
351351
it detects that there is only an `aws` infrastructure provider and so it uses that when creating the cluster.
352352
353353
</aside>
@@ -356,10 +356,10 @@ it detects that there is only an `aws` infrastructure provider and so it uses th
356356
357357
<h1> What topology will be used for my cluster? </h1>
358358
359-
The `clusterctl config cluster` command by default uses cluster templates which are provided by the infrastructure
359+
The `clusterctl generate cluster` command by default uses cluster templates which are provided by the infrastructure
360360
providers. See the provider's documentation for more information.
361361
362-
See the `clusterctl config cluster` [command][clusterctl config cluster] documentation for
362+
See the `clusterctl generate cluster` [command][clusterctl generate cluster] documentation for
363363
details about how to use alternative sources. for cluster templates.
364364
365365
</aside>
@@ -369,7 +369,7 @@ details about how to use alternative sources. for cluster templates.
369369
Depending on the infrastructure provider you are planning to use, some additional prerequisites should be satisfied
370370
before configuring a cluster with Cluster API. Instructions are provided for common providers below.
371371
372-
Otherwise, you can look at the `clusterctl config cluster` [command][clusterctl config cluster] documentation for details about how to
372+
Otherwise, you can look at the `clusterctl generate cluster` [command][clusterctl generate cluster] documentation for details about how to
373373
discover the list of variables required by a cluster templates.
374374
375375
{{#tabs name:"tab-configuration-infrastructure" tabs:"AWS,Azure,DigitalOcean,Docker,GCP,vSphere,OpenStack,Metal3,Packet"}}
@@ -492,7 +492,7 @@ Depending on your OpenStack and underlying hypervisor the following options migh
492492
493493
To see all required OpenStack environment variables execute:
494494
```bash
495-
clusterctl config cluster --infrastructure openstack --list-variables capi-quickstart
495+
clusterctl generate cluster --infrastructure openstack --list-variables capi-quickstart
496496
```
497497
498498
The following script can be used to export some of them:
@@ -578,7 +578,7 @@ For the purpose of this tutorial, we'll name our cluster capi-quickstart.
578578
{{#tab Azure|AWS|DigitalOcean|GCP|vSphere|OpenStack|Metal3|Packet}}
579579
580580
```bash
581-
clusterctl config cluster capi-quickstart \
581+
clusterctl generate cluster capi-quickstart \
582582
--kubernetes-version v1.19.7 \
583583
--control-plane-machine-count=3 \
584584
--worker-machine-count=3 \
@@ -597,7 +597,7 @@ The Docker provider is not designed for production use and is intended for devel
597597
</aside>
598598
599599
```bash
600-
clusterctl config cluster capi-quickstart --flavor development \
600+
clusterctl generate cluster capi-quickstart --flavor development \
601601
--kubernetes-version v1.19.7 \
602602
--control-plane-machine-count=3 \
603603
--worker-machine-count=3 \
@@ -612,7 +612,7 @@ Machine Deployments, etc.
612612
613613
The file can be eventually modified using your editor of choice.
614614
615-
See [clusterctl config cluster] for more details.
615+
See [clusterctl generate cluster] for more details.
616616
617617
#### Apply the workload cluster
618618
@@ -761,7 +761,7 @@ See the [clusterctl] documentation for more detail about clusterctl supported ac
761761
[capa]: https://cluster-api-aws.sigs.k8s.io
762762
[capv-upload-images]: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/master/docs/getting_started.md#uploading-the-machine-images
763763
[clusterawsadm]: https://cluster-api-aws.sigs.k8s.io/clusterawsadm/clusterawsadm.html
764-
[clusterctl config cluster]: ../clusterctl/commands/config-cluster.md
764+
[clusterctl generate cluster]: ../clusterctl/commands/generate-cluster.md
765765
[clusterctl get kubeconfig]: ../clusterctl/commands/get-kubeconfig.md
766766
[clusterctl]: ../clusterctl/overview.md
767767
[Docker]: https://www.docker.com/

0 commit comments

Comments
 (0)