Files
a13labs.infra/terraform/modules/apps/grafana/grafana.tf
T
alexandre.pires e6a3f3affd Add custom error pages and Nginx configuration for proxy module
- Introduced custom HTML error pages for various HTTP status codes (400, 401, 403, 404, 408, 429, 500, 502, 503, 504) in the proxy module.
- Created a .gitignore file to exclude non-HTML files in the error resources directory.
- Updated Nginx configuration to serve custom error pages for upstream errors.
- Added new Nginx configuration templates for handling HTTP and stream protocols.
- Implemented Wireguard configuration templates and associated variables for secure connections.
- Established Kubernetes resources for Stunnel and Wireguard, including deployment, service accounts, and config maps.
- Defined variables for the Stunnel and Wireguard modules to facilitate configuration.
- Created a new Wol Proxy module with Kubernetes resources for deployment and service management.
2025-10-02 00:19:01 +02:00

137 lines
3.1 KiB
Terraform

resource "kubernetes_deployment" "grafana" {
metadata {
name = "grafana"
namespace = kubernetes_namespace.grafana.metadata[0].name
labels = {
app = "grafana"
}
}
spec {
selector {
match_labels = {
app = "grafana"
}
}
template {
metadata {
labels = {
app = "grafana"
}
}
spec {
container {
name = "grafana"
image = "grafana/grafana:${local.app_version}"
image_pull_policy = "IfNotPresent"
security_context {
run_as_user = 1000
run_as_non_root = true
privileged = false
allow_privilege_escalation = false
}
port {
name = "http-grafana"
container_port = 3000
protocol = "TCP"
}
readiness_probe {
http_get {
path = "/robots.txt"
port = 3000
scheme = "HTTP"
}
failure_threshold = 3
initial_delay_seconds = 10
period_seconds = 30
success_threshold = 1
timeout_seconds = 2
}
liveness_probe {
tcp_socket {
port = 3000
}
failure_threshold = 3
initial_delay_seconds = 30
period_seconds = 10
success_threshold = 1
timeout_seconds = 1
}
resources {
requests = {
cpu = "250m"
memory = "750Mi"
}
}
volume_mount {
name = "grafana-pv"
mount_path = "/var/lib/grafana"
}
}
volume {
name = "grafana-pv"
host_path {
path = local.monitoring_folder
}
}
}
}
}
}
resource "kubernetes_service" "grafana" {
metadata {
name = "grafana"
namespace = kubernetes_namespace.grafana.metadata[0].name
}
spec {
selector = {
app = "grafana"
}
port {
port = 3000
protocol = "TCP"
target_port = "http-grafana"
}
session_affinity = "None"
type = "ClusterIP"
}
}
resource "kubernetes_ingress_v1" "grafana" {
metadata {
name = "ingress"
namespace = kubernetes_namespace.grafana.metadata[0].name
annotations = {
"kubernetes.io/ingress.class" = "public"
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
"kubernetes.io/tls-acme" = "true"
"nginx.ingress.kubernetes.io/ssl-redirect" = "true"
}
}
spec {
tls {
hosts = [var.fqdn]
secret_name = "grafana-tls"
}
rule {
host = var.fqdn
http {
path {
backend {
service {
name = kubernetes_service.grafana.metadata[0].name
port {
number = 3000
}
}
}
}
}
}
}
}