Skip to content

Commit 5427353

Browse files
Update main.tf
1 parent 3fa30e5 commit 5427353

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

main.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ locals {
3737
prometheus_config_hash = filesha256("${path.module}/manifests/prometheus-config.yaml")
3838
prometheus_service_hash = filesha256("${path.module}/manifests/prometheus-service.yaml")
3939
prometheus_deployment_hash = filesha256("${path.module}/manifests/prometheus-deployment.yaml")
40+
4041

4142
# Combine all hashes into one string before hashing again
4243
prometheus_full_hash = sha256("${local.prometheus_config_hash}${local.prometheus_service_hash}${local.prometheus_deployment_hash}")
@@ -52,3 +53,33 @@ resource "kubectl_manifest" "prometheus_deployment" {
5253
kubectl_manifest.prometheus_service
5354
]
5455
}
56+
57+
58+
# Deploy Node Exporter DaemonSet + Service
59+
resource "kubectl_manifest" "node_exporter" {
60+
yaml_body = file("${path.module}/manifests/node-exporter.yaml")
61+
depends_on = [kubectl_manifest.monitoring_namespace]
62+
}
63+
64+
# Deploy Node Exporter DaemonSet - Service
65+
66+
67+
resource "kubectl_manifest" "node_exporter" {
68+
yaml_body = file("${path.module}/manifests/node-exporter-service.yaml")
69+
depends_on = [kubectl_manifest.monitoring_namespace]
70+
}
71+
72+
# (Optional) Use SHA hash to force reapply if manifest changes
73+
locals {
74+
node_exporter_hash = filesha256("${path.module}/manifests/node-exporter.yaml")
75+
}
76+
77+
resource "null_resource" "trigger_node_exporter_restart" {
78+
triggers = {
79+
config_hash = local.node_exporter_hash
80+
}
81+
82+
provisioner "local-exec" {
83+
command = "kubectl rollout restart daemonset/node-exporter -n monitoring || true"
84+
}
85+
}

0 commit comments

Comments
 (0)