mirror of
https://github.com/khuedoan/homelab.git
synced 2024-12-22 20:34:32 +07:00
refactor(external): remove hardcoded internal DNS records
Use external-dns instead
This commit is contained in:
parent
924a88f67b
commit
275861a57b
1
external/.gitignore
vendored
1
external/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.env
|
||||
.terraform*
|
||||
terraform.tfstate
|
||||
terraform.tfvars
|
||||
|
5
external/applicationset.tf
vendored
5
external/applicationset.tf
vendored
@ -1,3 +1,8 @@
|
||||
provider "kubernetes" {
|
||||
# Environment variables
|
||||
# KUBE_CONFIG_PATH
|
||||
}
|
||||
|
||||
resource "kubernetes_manifest" "external_applicationset" {
|
||||
manifest = {
|
||||
apiVersion = "argoproj.io/v1alpha1"
|
||||
|
6
external/backblaze.tf
vendored
6
external/backblaze.tf
vendored
@ -1,3 +1,9 @@
|
||||
provider "backblaze" {
|
||||
# Environment variables
|
||||
# B2_APPLICATION_KEY
|
||||
# B2_APPLICATION_KEY_ID
|
||||
}
|
||||
|
||||
resource "b2_bucket" "backup" {
|
||||
bucket_name = "homelab-backup"
|
||||
bucket_type = "allPrivate"
|
||||
|
50
external/cloudflare.tf
vendored
50
external/cloudflare.tf
vendored
@ -1,35 +1,13 @@
|
||||
locals {
|
||||
internal_records = [
|
||||
"*.knative",
|
||||
"argocd",
|
||||
"authentik",
|
||||
"dex",
|
||||
"grafana",
|
||||
"home",
|
||||
"jellyfin",
|
||||
"paperless",
|
||||
"seafile",
|
||||
"syncthing",
|
||||
"tekton",
|
||||
"vault",
|
||||
]
|
||||
|
||||
tunnel_records = [
|
||||
"git"
|
||||
]
|
||||
provider "cloudflare" {
|
||||
# Environment variables
|
||||
# CLOUDFLARE_API_KEY
|
||||
}
|
||||
|
||||
resource "cloudflare_record" "internal_records" {
|
||||
for_each = toset(local.internal_records)
|
||||
zone_id = cloudflare_zone.khuedoan_com.id
|
||||
type = "A"
|
||||
name = each.key
|
||||
# TODO use data to get ingress IP
|
||||
value = "192.168.1.150"
|
||||
ttl = 1 # Auto
|
||||
data "cloudflare_zone" "khuedoan_com" {
|
||||
name = "khuedoan.com"
|
||||
}
|
||||
|
||||
resource "random_password" "homelab_tunnel" {
|
||||
resource "random_password" "tunnel_secret" {
|
||||
length = 64
|
||||
special = false
|
||||
}
|
||||
@ -38,14 +16,22 @@ resource "cloudflare_argo_tunnel" "homelab" {
|
||||
# TODO (optimize) Use variable for account_id
|
||||
account_id = "xxx"
|
||||
name = "homelab"
|
||||
secret = base64encode(random_password.homelab_tunnel.result)
|
||||
secret = base64encode(random_password.tunnel_secret.result)
|
||||
}
|
||||
|
||||
resource "cloudflare_record" "git" {
|
||||
zone_id = cloudflare_zone.khuedoan_com.id
|
||||
resource "cloudflare_record" "tunnels" {
|
||||
for_each = toset([
|
||||
"git"
|
||||
])
|
||||
|
||||
zone_id = data.cloudflare_zone.khuedoan_com.id
|
||||
type = "CNAME"
|
||||
name = "git"
|
||||
name = each.key
|
||||
value = "${cloudflare_argo_tunnel.homelab.id}.cfargotunnel.com"
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
|
||||
# TODO
|
||||
# api token
|
||||
# add it to certmanager, external-dns, cloudflaredknamespace
|
||||
|
Loading…
Reference in New Issue
Block a user