You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -318,12 +318,26 @@ See the [guide on adding robot servers](docs/add-robot-server.md)
318
318
319
319
If you need to install additional Helm charts or Kubernetes manifests that are not provided by default, you can easily do so by using [Kustomize](https://kustomize.io). This is done by creating one or more `extra-manifests/kustomization.yaml.tpl` files beside your `kube.tf`.
320
320
321
-
If you'd like to use a different folder name, you can configure it using the `extra_kustomize_folder` variable. By default, it is set to `extra-manifests`. This can be useful when working with multiple environments, allowing you to deploy different manifests for each one.
322
-
323
321
These files need to be valid `Kustomization` manifests, additionally supporting terraform templating! (The templating parameters can be passed via the `extra_kustomize_parameters` variable (via a map) to the module).
324
322
325
323
All files in the `extra-manifests` directory and its subdirectories including the rendered versions of the `*.yaml.tpl` will be applied to k3s with `kubectl apply -k` (which will be executed after and independently of the basic cluster configuration).
326
324
325
+
If you'd like to use a different folder name or apply the kustomizations in multiple steps due to CRD installation etc, you can override the values using `user_kustomizations`-variable. Note! This will override `extra_kustomize_deployment_commands` and `extra_kustomize_parameters`, so you will need to move them into the `user_kustomizations`-variable.
326
+
327
+
Example of using user_kustomizations in `kube.tf`:
See a working example in [examples/kustomization_user_deploy](https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/tree/master/examples/kustomization_user_deploy).
328
342
329
343
_You can use the above to pass all kinds of Kubernetes YAML configs, including HelmChart and/or HelmChartConfig definitions (see the previous section if you do not know what those are in the context of k3s)._
@@ -334,22 +348,22 @@ _That said, you can also use pure Terraform and import the kube-hetzner module a
334
348
335
349
<details>
336
350
337
-
<summary>Custom pre- and post-install actions</summary>
351
+
<summary>Adding applications with Helm, custom pre- and post-install actions</summary>
338
352
339
353
After the initial bootstrapping of your Kubernetes cluster, you might want to deploy applications using the same terraform mechanism. For many scenarios it is sufficient to create a `kustomization.yaml.tpl` file (see [Adding Extras](#adding-extras)). All applied kustomizations will be applied at once by executing a single `kubectl apply -k` command.
340
354
341
355
However, some applications that e.g. provide custom CRDs (e.g. [ArgoCD](https://argoproj.github.io/cd/)) need a different deployment strategy: one has to deploy CRDs first, then wait for the deployment, before being able to install the actual application. In the ArgoCD case, not waiting for the CRD setup to finish will cause failures.
342
356
343
-
To support these scenarios, this module provides a flexible mechanism using the `user_kustomizations` variable in your `kube.tf`. This allows you to define multiple "sets" of kustomizations that are applied sequentially, ordered by a numeric key. Each set can have its own `source_folder`, `kustomize_parameters`, and `pre_commands`/`post_commands` for running scripts before or after `kubectl apply`. This is the recommended way to handle complex, ordered deployments.
357
+
To support these scenarios, you can use the `user_kustomizations` variable in your `kube.tf`. This allows you to define multiple "sets" of kustomizations that are applied sequentially. Each set can have its own `source_folder`, `kustomize_parameters`, and `pre_commands`/`post_commands` for running scripts before or after the `kubectl apply -k`.
344
358
345
-
For backward compatibility, if `user_kustomizations` is not defined, the module falls back to the previous behavior. The following sections provide examples of how this new system can be used.
359
+
For backward compatibility, if `user_kustomizations` is not defined, the module uses the `extra_kustomize_parameters` and `extra_kustomize_deployment_commands` with `extra-manifests` being the source folder.
346
360
347
-
### Pre-install Actions, Example: external-secrets repo and Helm
348
-
You can install Helm repos and CRDs before the main Kustomization scripts by adding the helm charts to the `extra-manifests-preinstall`folder and specifying the Helm chart in `extra-manifests-preinstall/kustomization.yaml.tpl`, just like with `extra-manifests`.
361
+
### Example: external-secrets repo and Helm
362
+
You can install Helm repos and CRDs before the main Kustomization scripts by adding the Helm charts a different folder, e.g. `extra-manifests-preinstall` and specifying the folder in `user_kustomizations`-settings.
349
363
350
-
For example, to add `external-secrets` so that it can be referenced later on, create files:
351
-
1. extra-manifests-preinstall/eso.yaml.tpl
364
+
For example, to add `external-secrets` you can first create the CRDs:
Specify `extra_kustomize_deployment_commands` in your `kube.tf` file containing a series of commands to be executed, after the `Kustomization` step has finished:
387
+
Then create the objects that use the previously created CRDs:
Copy file name to clipboardExpand all lines: kube.tf.example
+3-9Lines changed: 3 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -956,7 +956,7 @@ module "kube-hetzner" {
956
956
# Extra commands to be executed after the `kubectl apply -k` (useful for post-install actions, e.g. wait for CRD, apply additional manifests, etc.).
957
957
# extra_kustomize_deployment_commands=""
958
958
959
-
# Extra values that will be passed to the `extra-manifests/kustomization.yaml.tpl` and `extra-manifests-preinstall/kustomization.yaml.tpl` when present.
959
+
# Extra values that will be passed to the `extra-manifests/kustomization.yaml.tpl`.
960
960
# extra_kustomize_parameters={}
961
961
962
962
# You can add extra kustomizations to be deployed in sequence by setting the `user_kustomizations` variable.
# kustomize_parameters = var.extra_kustomize_parameters # Same as `extra_kustomize_parameters` in kube.tf, replace with actual values if uncommenting
986
980
# pre_commands = ""
987
-
# post_commands = var.extra_kustomize_deployment_commands # Same as `extra_kustomize_deployment_commands` in kube.tf, replace with actual values if uncommenting
981
+
# post_commands = var.extra_kustomize_deployment_commands # Same as `extra_kustomize_deployment_commands` in kube.tf, replace with actual values if uncommenting
0 commit comments