mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-22 10:19:21 +07:00
feat(external): inject Cloudflare Tunnel secret to the cluster
This commit is contained in:
parent
70be424bac
commit
f432719241
31
external/cloudflare.tf
vendored
31
external/cloudflare.tf
vendored
@ -27,7 +27,7 @@ resource "cloudflare_record" "tunnels" {
|
||||
zone_id = data.cloudflare_zone.khuedoan_com.id
|
||||
type = "CNAME"
|
||||
name = each.key
|
||||
value = "${cloudflare_argo_tunnel.homelab.id}.cfargotunnel.com"
|
||||
value = cloudflare_argo_tunnel.homelab.cname
|
||||
proxied = true
|
||||
ttl = 1 # Auto
|
||||
}
|
||||
@ -35,3 +35,32 @@ resource "cloudflare_record" "tunnels" {
|
||||
# TODO
|
||||
# api token
|
||||
# add it to certmanager, external-dns, cloudflaredknamespace
|
||||
|
||||
resource "kubernetes_namespace" "namespaces" {
|
||||
for_each = toset([
|
||||
"cert-manager",
|
||||
"cloudflared",
|
||||
"external-dns",
|
||||
"velero"
|
||||
])
|
||||
|
||||
metadata {
|
||||
name = each.key
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_secret" "cloudflared_credentials" {
|
||||
metadata {
|
||||
name = "cloudflared-credentials"
|
||||
namespace = "cloudflared"
|
||||
}
|
||||
|
||||
data = {
|
||||
"credentials.json" = base64encode(jsonencode({
|
||||
AccountTag = "" # TODO account_id
|
||||
TunnelName = cloudflare_argo_tunnel.homelab.name
|
||||
TunnelID = cloudflare_argo_tunnel.homelab.id
|
||||
TunnelSecret = base64encode(random_password.tunnel_secret.result)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user