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.

0 commit comments

Comments
 (0)