use helm native traefik dashboard ingress

This commit is contained in:
2024-03-06 21:22:43 +01:00
parent f35e7e73fa
commit b82d213532
7 changed files with 57 additions and 92 deletions

View File

@@ -4,9 +4,5 @@ terraform {
source = "hashicorp/helm"
version = ">= 2.12.1"
}
kubectl = {
source = "gavinbunney/kubectl"
version = ">= 1.14.0"
}
}
}

View File

@@ -5,13 +5,17 @@ resource "helm_release" "traefik" {
repository = "https://traefik.github.io/charts"
chart = "traefik"
version = var.traefik_chart_version
cleanup_on_fail = true
# Helm chart deployment can sometimes take longer than the default 5 minutes
timeout = var.timeout_seconds
# 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 ? templatefile("${path.root}/${var.values_file}", var.traefik_template_values) : ""]
values = [fileexists("${path.root}/${var.values_file}") == true ? templatefile("${path.root}/${var.values_file}", merge({
traefik_dashboard_username = base64encode("admin")
traefik_dashboard_password = base64encode(random_password.traefik_dashboard_password.result)
}, var.traefik_template_values)) : ""]
set {
name = "deployment.replicas"
@@ -25,12 +29,4 @@ resource "random_password" "traefik_dashboard_password" {
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

@@ -22,7 +22,7 @@ variable "traefik_chart_version" {
variable "timeout_seconds" {
type = number
description = "Helm chart deployment can sometimes take longer than the default 5 minutes. Set a custom timeout here."
default = 800 # 10 minutes
default = 180 # 10 minutes
}
variable "replica_count" {
@@ -38,9 +38,4 @@ variable "values_file" {
variable "traefik_template_values" {
default = {}
}
variable "traefik_dashboard_ingress_file" {
description = "The name of the kubernetes manifest file to use"
type = string
}