Skip to content
Merged
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
[![terraform](https://github.com/guyzsarun-lab/homelab/actions/workflows/terraform.yaml/badge.svg)](https://github.com/guyzsarun-lab/homelab/actions/workflows/terraform.yaml)

## Components
- [Kong](#kong-api-gateway) API Gateway
- [Kong](#kong) API Gateway
- [Grafana](#grafana) for monitoring

### Kong
Terraform is used for configuring Kong API Gateway. for Kong installation see [ansible-playbook](https://github.com/guyzsarun-lab/ansible).
Expand All @@ -16,4 +17,14 @@ terraform plan
#### Routes
Route for VMs and Kubernetes services are in the `kong/routes` directory. simply update the route file and run `terraform apply`.
#### Certificates
Certificates are stored in the `kong/certificates` directory. put the certificate and key file in the directory and run `terraform apply`.
Certificates are stored in the `kong/certificates` directory. put the certificate and key file in the directory and run `terraform apply`.

### Grafana

#### Installation
Update the grafana variable ( url, datasource ) and run the following commands.
```bash
cd grafana
terraform init
terraform plan
```
2 changes: 2 additions & 0 deletions grafana/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dashboard/private/*.json
dashboard/private/*.tftpl
38 changes: 38 additions & 0 deletions grafana/dashboard.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
resource "grafana_dashboard" "networking" {
folder = grafana_folder.folder["Networking"].uid
for_each = fileset("${path.module}/dashboard/networking", "*.json")
config_json = file("${path.module}/dashboard/networking/${each.value}")
}

resource "grafana_dashboard" "hardware" {
folder = grafana_folder.folder["Hardware"].uid
for_each = fileset("${path.module}/dashboard/hardware", "*.json")
config_json = file("${path.module}/dashboard/hardware/${each.value}")
}

resource "grafana_dashboard" "logging" {
folder = grafana_folder.folder["Loki"].uid
for_each = fileset("${path.module}/dashboard/logging", "*.tftpl")
config_json = templatefile("${path.module}/dashboard/logging/${each.value}", { datasource-uid = grafana_data_source.loki.uid })
}

resource "grafana_dashboard" "private" {
folder = grafana_folder.folder["Finance"].uid
for_each = fileset("${path.module}/dashboard/private", "*.tftpl")
config_json = templatefile("${path.module}/dashboard/private/${each.value}", { datasource-uid = grafana_data_source.google-sheets.uid })
}

resource "grafana_dashboard" "public" {
folder = grafana_folder.folder["Public"].uid
for_each = fileset("${path.module}/dashboard/public", "*.json")
config_json = file("${path.module}/dashboard/public/${each.value}")
}

resource "grafana_dashboard_public" "public" {
org_id = grafana_organization.homelab.org_id
dashboard_uid = each.value.uid

for_each = grafana_dashboard.public
share = "public"
is_enabled = true
}
Loading