Skip to content

Commit

Permalink
add additional managed namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nbucci committed Nov 6, 2024
1 parent 5b8a5a4 commit 39acc3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ locals {
)

final_namespace = var.create_namespace ? resource.kubernetes_namespace_v1.this[0].metadata[0].name : data.kubernetes_namespace_v1.this[0].metadata[0].name

managed_namespaces = distinct(concat(var.managed_namespaces, var.additional_managed_namespaces))
}

resource "kubernetes_namespace_v1" "this" {
Expand Down Expand Up @@ -38,6 +40,7 @@ resource "kubernetes_service_account_v1" "this" {

resource "kubernetes_secret_v1" "this" {
metadata {
# This is the prefix, used by the server, to generate a unique name ONLY IF the name field has not been provided. This value will also be combined with a unique suffix.
generate_name = "${var.service_account_name}-"
namespace = local.final_namespace
labels = local.k8s_full_labels
Expand Down Expand Up @@ -103,7 +106,7 @@ resource "kubernetes_cluster_role_v1" "namespace_scoped" {
}

resource "kubernetes_role_binding_v1" "this" {
for_each = toset(var.managed_namespaces)
for_each = toset(local.managed_namespaces)

metadata {
name = var.role_binding_name
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ variable "managed_namespaces" {
default = []
}

variable "additional_managed_namespaces" {
description = "List of additional namespaces where the controller should manage the scale of deployments."
type = list(string)
default = []
}

variable "managed_namespaces_label_selector" {
description = "Label selector for the namespaces where the controller should manage the scale of deployments. The namespaces fetched by this selector will be merged with the `managed_namespaces` variable."
type = map(string)
Expand Down

0 comments on commit 39acc3e

Please sign in to comment.