Skip to content

Commit db51e43

Browse files
authored
Merge pull request #1688 from ludnix2/extraKustomizeFolder
Make Kustomization folder configurable
2 parents 0ea4402 + c25ca34 commit db51e43

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ For Traefik, Nginx, HAProxy, Rancher, Cilium, Traefik, and Longhorn, for maximum
292292

293293
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`.
294294

295+
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.
296+
295297
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).
296298

297299
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).

kustomization_user.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
user_kustomization_templates = try(fileset("extra-manifests", "**/*.yaml.tpl"), toset([]))
2+
user_kustomization_templates = try(fileset(var.extra_kustomize_folder, "**/*.yaml.tpl"), toset([]))
33
}
44

55
resource "null_resource" "kustomization_user" {
@@ -20,12 +20,12 @@ resource "null_resource" "kustomization_user" {
2020
}
2121

2222
provisioner "file" {
23-
content = templatefile("extra-manifests/${each.key}", var.extra_kustomize_parameters)
23+
content = templatefile("${var.extra_kustomize_folder}/${each.key}", var.extra_kustomize_parameters)
2424
destination = replace("/var/user_kustomize/${each.key}", ".yaml.tpl", ".yaml")
2525
}
2626

2727
triggers = {
28-
manifest_sha1 = "${sha1(templatefile("extra-manifests/${each.key}", var.extra_kustomize_parameters))}"
28+
manifest_sha1 = "${sha1(templatefile("${var.extra_kustomize_folder}/${each.key}", var.extra_kustomize_parameters))}"
2929
}
3030

3131
depends_on = [

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,12 @@ variable "extra_kustomize_parameters" {
10391039
description = "All values will be passed to the `kustomization.tmp.yml` template."
10401040
}
10411041

1042+
variable "extra_kustomize_folder" {
1043+
type = string
1044+
default = "extra-manifests"
1045+
description = "Folder from where to upload extra manifests"
1046+
}
1047+
10421048
variable "create_kubeconfig" {
10431049
type = bool
10441050
default = true

0 commit comments

Comments
 (0)