1
1
# Using Kustomize with Workload Cluster Manifests
2
2
3
- Although the ` clusterctl generate cluster ` command exposes a number of different configuration values
4
- for customizing workload cluster YAML manifests, some users may need additional flexibility above
5
- and beyond what ` clusterctl generate cluster ` or the example "flavor" templates that some CAPI providers
6
- supply (as an example, see [ these flavor templates] ( https://github.com/kubernetes-sigs/cluster-api-provider-azure/tree/master /templates/flavors )
7
- for the Cluster API Provider for Azure). In the future, a [ templating solution] ( https://github.com/kubernetes-sigs/cluster-api/issues/3252 )
8
- may be integrated into ` clusterctl ` to help address this need, but in the meantime users can use
3
+ Although the ` clusterctl generate cluster ` command exposes a number of different configuration values
4
+ for customizing workload cluster YAML manifests, some users may need additional flexibility above
5
+ and beyond what ` clusterctl generate cluster ` or the example "flavor" templates that some CAPI providers
6
+ supply (as an example, see [ these flavor templates] ( https://github.com/kubernetes-sigs/cluster-api-provider-azure/tree/main /templates/flavors )
7
+ for the Cluster API Provider for Azure). In the future, a [ templating solution] ( https://github.com/kubernetes-sigs/cluster-api/issues/3252 )
8
+ may be integrated into ` clusterctl ` to help address this need, but in the meantime users can use
9
9
` kustomize ` as a solution to this need.
10
10
11
- This document provides a few examples of using ` kustomize ` with Cluster API. All of these examples
11
+ This document provides a few examples of using ` kustomize ` with Cluster API. All of these examples
12
12
assume that you are using a directory structure that looks something like this:
13
13
14
14
```
@@ -25,13 +25,13 @@ assume that you are using a directory structure that looks something like this:
25
25
└── workload-mhc.yaml
26
26
```
27
27
28
- In the overlay directories, the "base" (unmodified) Cluster API configuration (perhaps generated using
28
+ In the overlay directories, the "base" (unmodified) Cluster API configuration (perhaps generated using
29
29
` clusterctl generate cluster ` ) would be referenced as a resource in ` kustomization.yaml ` using ` ../../base ` .
30
30
31
31
## Example: Using Kustomize to Specify Custom Images
32
32
33
- Users can use ` kustomize ` to specify custom OS images for Cluster API nodes. Using the Cluster API
34
- Provider for AWS (CAPA) as an example, the following ` kustomization.yaml ` would leverage a JSON 6902 patch
33
+ Users can use ` kustomize ` to specify custom OS images for Cluster API nodes. Using the Cluster API
34
+ Provider for AWS (CAPA) as an example, the following ` kustomization.yaml ` would leverage a JSON 6902 patch
35
35
to modify the AMI for nodes in a workload cluster:
36
36
37
37
``` yaml
@@ -57,13 +57,13 @@ The referenced JSON 6902 patch in `custom-ami.json` would look something like th
57
57
]
58
58
` ` `
59
59
60
- This configuration assumes that the workload cluster _only_ uses MachineDeployments. Since
61
- MachineDeployments and the KubeadmControlPlane both leverage AWSMachineTemplates, this `kustomize`
60
+ This configuration assumes that the workload cluster _only_ uses MachineDeployments. Since
61
+ MachineDeployments and the KubeadmControlPlane both leverage AWSMachineTemplates, this `kustomize`
62
62
configuration would catch all nodes in the workload cluster.
63
63
64
64
# # Example: Adding a MachineHealthCheck for a Workload Cluster
65
65
66
- Users could also use `kustomize` to combine additional resources, like a MachineHealthCheck (MHC), with the
66
+ Users could also use `kustomize` to combine additional resources, like a MachineHealthCheck (MHC), with the
67
67
base Cluster API manifest. In an overlay directory, specify the following in `kustomization.yaml` :
68
68
69
69
` ` ` yaml
@@ -98,24 +98,24 @@ spec:
98
98
timeout: 300s
99
99
` ` `
100
100
101
- You would want to ensure the `clusterName` field in the MachineHealthCheck manifest appropriately
102
- matches the name of the workload cluster, taking into account any transformations you may have specified
101
+ You would want to ensure the `clusterName` field in the MachineHealthCheck manifest appropriately
102
+ matches the name of the workload cluster, taking into account any transformations you may have specified
103
103
in `kustomization.yaml` (like the use of "namePrefix" or "nameSuffix").
104
104
105
- Running `kustomize build .` with this configuration would append the MHC to the base
105
+ Running `kustomize build .` with this configuration would append the MHC to the base
106
106
Cluster API manifest, thus creating the MHC at the same time as the workload cluster.
107
107
108
108
# # Modifying Names
109
109
110
- The `kustomize` "namePrefix" and "nameSuffix" transformers are not currently "Cluster API aware."
111
- Although it is possible to use these transformers with Cluster API manifests, doing so requires separate
112
- patches for Clusters versus infrastructure-specific equivalents (like an AzureCluster or a vSphereCluster).
110
+ The `kustomize` "namePrefix" and "nameSuffix" transformers are not currently "Cluster API aware."
111
+ Although it is possible to use these transformers with Cluster API manifests, doing so requires separate
112
+ patches for Clusters versus infrastructure-specific equivalents (like an AzureCluster or a vSphereCluster).
113
113
This can significantly increase the complexity of using `kustomize` for this use case.
114
114
115
- Modifying the transformer configurations for `kustomize` can make it more effective with Cluster API.
116
- For example, changes to the `nameReference` transformer in `kustomize` will enable `kustomize` to know
117
- about the references between Cluster API objects in a manifest. See
118
- [here](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs) for more
115
+ Modifying the transformer configurations for `kustomize` can make it more effective with Cluster API.
116
+ For example, changes to the `nameReference` transformer in `kustomize` will enable `kustomize` to know
117
+ about the references between Cluster API objects in a manifest. See
118
+ [here](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs) for more
119
119
information on transformer configurations.
120
120
121
121
Add the following content to the `namereference.yaml` transformer configuration :
@@ -175,7 +175,7 @@ Add the following content to the `namereference.yaml` transformer configuration:
175
175
kind: MachineDeployment
176
176
` ` `
177
177
178
- Including this custom configuration in a `kustomization.yaml` would then enable the use of simple
178
+ Including this custom configuration in a `kustomization.yaml` would then enable the use of simple
179
179
" namePrefix" and/or "nameSuffix" directives, like this:
180
180
181
181
` ` ` yaml
@@ -190,6 +190,6 @@ namePrefix: "blue-"
190
190
nameSuffix: "-dev"
191
191
` ` `
192
192
193
- Running `kustomize build. ` with this configuration would modify the name of all the Cluster API
194
- objects _and_ the associated referenced objects, adding "blue-" at the beginning and appending "-dev"
193
+ Running `kustomize build. ` with this configuration would modify the name of all the Cluster API
194
+ objects _and_ the associated referenced objects, adding "blue-" at the beginning and appending "-dev"
195
195
at the end.
0 commit comments