Skip to content

Commit 80682f2

Browse files
committed
Make host optional
1 parent ab8da3c commit 80682f2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

main.tf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@ resource "kubernetes_namespace" "headlamp" {
44
}
55
}
66

7+
locals {
8+
configure_ingress = var.host != null
9+
}
10+
711
resource "helm_release" "headlamp" {
812
namespace = kubernetes_namespace.headlamp.metadata[0].name
913
name = "headlamp"
1014
repository = "https://headlamp-k8s.github.io/headlamp"
1115
chart = "headlamp"
1216
version = var.headlamp_version
1317
values = [
14-
<<-EOT
18+
!local.configure_ingress ? "" : <<-EOT1
1519
ingress:
1620
enabled: true
1721
hosts:
1822
- host: ${var.host}
1923
paths:
2024
- path: /
2125
type: Prefix
22-
EOT
23-
, var.ingress_class == null ? "" : <<-EOT
26+
EOT1
27+
,
28+
!local.configure_ingress || var.ingress_class == null ? "" : <<-EOT2
2429
ingress:
2530
annotations:
2631
kubernetes.io/ingress.class: ${var.ingress_class}
27-
EOT
28-
, var.issuer_name == null ? "" : <<-EOT
32+
EOT2
33+
,
34+
!local.configure_ingress || var.issuer_name == null ? "" : <<-EOT3
2935
config:
3036
oidc:
3137
issuerURL: "${var.oidc_issuer_url}"
@@ -39,6 +45,6 @@ resource "helm_release" "headlamp" {
3945
- secretName: headlamp-tls
4046
hosts:
4147
- ${var.host}
42-
EOT
48+
EOT3
4349
]
4450
}

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ locals {
44

55
output "url" {
66
depends_on = [helm_release.headlamp]
7-
value = "${local.protocol}://${var.host}/"
7+
value = !local.configure_ingress ? null : "${local.protocol}://${var.host}/"
88
description = "installed application URL"
99
}

variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ variable "headlamp_version" {
1212

1313
variable "host" {
1414
type = string
15-
description = "FQDN for the ingress"
15+
default = null
16+
description = "FQDN for the ingress, must be set to enable ingress"
1617
}
1718

1819
variable "ingress_class" {

0 commit comments

Comments
 (0)