Kube-Hetzner allows you to provide user-defined resources after the initial setup of the Kubernetes cluster. You can deploy additional resources using Kustomize scripts in the extra-manifests
directory with the extension .yaml.tpl
. These scripts are recursively copied onto the control plane and deployed with kubectl apply -k
. The main entry point for these additional resources is the kustomization.yaml.tpl
file. In this file, you need to list the names of other manifests without the .tpl
extension in the resources section.
When you execute terraform apply, the manifests in the extra-manifests directory, including the rendered versions of the *.yaml.tpl
files, will be automatically deployed to the cluster.
Here are some examples of common use cases for deploying additional resources:
Note: When trying out the demos, make sure that the files from the demo folders are located in the
extra-manifests
directory.
The easiest use case is to deploy simple resources to the cluster. Since the Kustomize resources are Terraform template files, they can make use of parameters provided in the extra_kustomize_parameters
map of the kube.tf
file.
...
extra_kustomize_parameters = {
my_config_key = "somestring"
}
...
The variable defined in kube.tf
can be used in any .yaml.tpl
manifest.
apiVersion: v1
kind: ConfigMap
metadata:
name: demo-config
data:
someConfigKey: ${sealed_secrets_crt}
For a full demo see the simple-resources example.
If you want to deploy a Helm chart to your cluster, you can use the Helm Chart controller included in K3s. The Helm Chart controller provides the CRDs HelmChart
and HelmChartConfig
.
For a full demo see the helm-chart example.
In more complex use cases, you may want to deploy to multiple namespaces with a common base. Kustomize supports this behavior, and it can be since Kube-Hetzner is considering all subdirectories of extra-manifests
.
For a full demo see the multiple-namespaces example.
To check the existing kustomization, you can run the following command:
$ terraform state list | grep kustom
...
module.kube-hetzner.null_resource.kustomization
module.kube-hetzner.null_resource.kustomization_user["demo-config-map.yaml.tpl"]
module.kube-hetzner.null_resource.kustomization_user["demo-pod.yaml.tpl"]
module.kube-hetzner.null_resource.kustomization_user["kustomization.yaml.tpl"]
...
If you want to rerun just the kustomization part, you can use the following command:
terraform apply -replace='module.kube-hetzner.null_resource.kustomization_user["kustomization.yaml.tpl"]' --auto-approve