add traefik dashboard ingress

This commit is contained in:
2024-03-06 20:06:22 +01:00
parent 9f83240ef1
commit f35e7e73fa
12 changed files with 161 additions and 32 deletions

View File

@@ -0,0 +1,9 @@
output "traefik_dashboard_password" {
value = random_password.traefik_dashboard_password.result
sensitive = true
}
output "traefik_dashboard_username" {
value = "admin"
sensitive = true
}

View File

@@ -0,0 +1,12 @@
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = ">= 2.12.1"
}
kubectl = {
source = "gavinbunney/kubectl"
version = ">= 1.14.0"
}
}
}

View File

@@ -11,10 +11,26 @@ resource "helm_release" "traefik" {
# If values file specified by the var.values_file input variable exists then apply the values from this file
# else apply the default values from the chart
values = [fileexists("${path.root}/${var.values_file}") == true ? file("${path.root}/${var.values_file}") : ""]
values = [fileexists("${path.root}/${var.values_file}") == true ? templatefile("${path.root}/${var.values_file}", var.traefik_template_values) : ""]
set {
name = "deployment.replicas"
value = var.replica_count
}
}
}
resource "random_password" "traefik_dashboard_password" {
length = 128
special = true
override_special = "_%@"
upper = true
lower = true
}
resource "kubectl_manifest" "dashboard-ingress" {
depends_on = [helm_release.traefik]
yaml_body = templatefile("${path.root}/${var.traefik_dashboard_ingress_file}", {
traefik_dashboard_username = base64encode("admin")
traefik_dashboard_password = base64encode(random_password.traefik_dashboard_password.result)
})
}

View File

@@ -34,5 +34,13 @@ variable "replica_count" {
variable "values_file" {
description = "The name of the traefik helmchart values file to use"
type = string
default = "traefik-values.yml"
}
variable "traefik_template_values" {
default = {}
}
variable "traefik_dashboard_ingress_file" {
description = "The name of the kubernetes manifest file to use"
type = string
}