Skip to content

Commit 64b08b2

Browse files
feat: add k8s dashboard (using helm chart) (#68)
* feat: add k8s dashboard (using helm chart) * chore: tf format
1 parent c949713 commit 64b08b2

File tree

7 files changed

+601
-0
lines changed

7 files changed

+601
-0
lines changed

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ module "monitoring" {
8686
grafana_admin_password = data.azurerm_key_vault_secret.grafana_admin_password.value
8787
}
8888

89+
module "kubernetes-dashboard" {
90+
depends_on = [
91+
module.aks
92+
]
93+
94+
source = "./modules/kubernetes-dashboard/"
95+
96+
// variables
97+
namespace = "kubernetes-dashboard"
98+
}
99+
89100
module "keyvault" {
90101
source = "./modules/keyvault/"
91102

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
resource "kubernetes_namespace" "namespace" {
2+
metadata {
3+
name = var.namespace
4+
}
5+
}
6+
7+
resource "helm_release" "kubernetes-dashboard" {
8+
name = "kubernetes-dashboard"
9+
repository = "https://kubernetes.github.io/dashboard/"
10+
chart = "kubernetes-dashboard"
11+
version = "7.14.0"
12+
namespace = var.namespace
13+
14+
cleanup_on_fail = true
15+
create_namespace = false
16+
17+
values = [
18+
templatefile("${path.module}/values/dashboard.yaml.tftpl", {})
19+
]
20+
21+
depends_on = [
22+
kubernetes_namespace.namespace,
23+
]
24+
}
25+
26+
# RBAC Explanation:
27+
#
28+
# With default authentication, users authenticate by providing their own Kubernetes tokens
29+
# (ServiceAccount tokens, user tokens, etc.). The dashboard acts as a proxy - when a user
30+
# makes a request through the dashboard UI, the dashboard forwards that request to the
31+
# Kubernetes API server using the user's token. The dashboard containers themselves don't
32+
# need special permissions because they're just proxying requests.
33+
#
34+
# Login to the UI is done using Cloudflare Tunnel + Cloudflare Access.
35+
# We create a authorization token linked to this service account that expires in 104 years
36+
# starting from today (31/10/2025).
37+
# If you are still there when this expires, you can generate a new one by running the
38+
# following command in the terminal (with kubectl configured):
39+
# kubectl create token admin-user -n kubernetes-dashboard
40+
# Then change it in the header value "Authorization" found in
41+
# the Cloudflare Rules section in our Cloudflare account.
42+
resource "kubernetes_service_account" "admin_user" {
43+
metadata {
44+
name = "admin-user"
45+
namespace = var.namespace
46+
}
47+
}
48+
49+
resource "kubernetes_cluster_role_binding" "admin_user" {
50+
metadata {
51+
name = "admin-user-binding"
52+
}
53+
role_ref {
54+
api_group = "rbac.authorization.k8s.io"
55+
kind = "ClusterRole"
56+
name = "cluster-admin"
57+
}
58+
subject {
59+
kind = "ServiceAccount"
60+
name = "admin-user"
61+
namespace = var.namespace
62+
}
63+
64+
depends_on = [
65+
helm_release.kubernetes-dashboard
66+
]
67+
}
68+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "namespace" {
2+
description = "Namespace where Kubernetes Dashboard is deployed"
3+
value = var.namespace
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = "~> 1.0"
3+
required_providers {
4+
kubernetes = {
5+
source = "hashicorp/kubernetes"
6+
version = "2.21.1"
7+
}
8+
helm = {
9+
source = "hashicorp/helm"
10+
version = "2.17.0"
11+
}
12+
}
13+
}
14+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# General app configuration
2+
app:
3+
# Disable ingress since we're using Cloudflare tunnels
4+
ingress:
5+
enabled: false
6+
7+
# Kong gateway configuration - this is the main service entry point
8+
# Kong acts as the gateway/router for all dashboard components (auth, api, web)
9+
kong:
10+
enabled: true
11+
proxy:
12+
type: ClusterIP
13+
# Enable HTTP mode since Cloudflare tunnel handles TLS termination
14+
# The dashboard will be accessible via HTTP internally, Cloudflare encrypts externally
15+
http:
16+
enabled: true
17+
18+
# Metrics scraper - reduce CPU request to avoid scheduling issues on small clusters
19+
metricsScraper:
20+
containers:
21+
resources:
22+
requests:
23+
cpu: 10m # Reduced from default 100m to avoid scheduling issues
24+
memory: 100Mi # Reduced from default 200Mi
25+
limits:
26+
cpu: 250m # Keep limit high to allow burst if needed
27+
memory: 400Mi
28+
29+
api:
30+
containers:
31+
resources:
32+
requests:
33+
cpu: 50m # Reduced from default 100m
34+
memory: 150Mi
35+
limits:
36+
cpu: 250m
37+
memory: 400Mi
38+
39+
web:
40+
containers:
41+
resources:
42+
requests:
43+
cpu: 50m # Reduced from default 100m
44+
memory: 150Mi
45+
limits:
46+
cpu: 250m
47+
memory: 400Mi

0 commit comments

Comments
 (0)