mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-22 02:07:46 +07:00
feat(external): create API token for external-dns
This commit is contained in:
parent
529b12919a
commit
e698fb44de
3
external/applicationset.tf
vendored
3
external/applicationset.tf
vendored
@ -1,6 +1,5 @@
|
||||
provider "kubernetes" {
|
||||
# Environment variables
|
||||
# KUBE_CONFIG_PATH
|
||||
config_path = "${path.root}/../metal/kubeconfig.yaml"
|
||||
}
|
||||
|
||||
resource "kubernetes_manifest" "external_applicationset" {
|
||||
|
39
external/cloudflare.tf
vendored
39
external/cloudflare.tf
vendored
@ -11,6 +11,12 @@ data "cloudflare_zone" "khuedoan_com" {
|
||||
name = "khuedoan.com"
|
||||
}
|
||||
|
||||
data "cloudflare_api_token_permission_groups" "all" {}
|
||||
|
||||
data "http" "public_ip" {
|
||||
url = "https://icanhazip.com"
|
||||
}
|
||||
|
||||
resource "random_password" "tunnel_secret" {
|
||||
length = 64
|
||||
special = false
|
||||
@ -68,3 +74,36 @@ resource "kubernetes_secret" "cloudflared_credentials" {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudflare_api_token" "external_dns" {
|
||||
name = "homelab_external_dns"
|
||||
|
||||
policy {
|
||||
permission_groups = [
|
||||
data.cloudflare_api_token_permission_groups.all.permissions["DNS Write"],
|
||||
data.cloudflare_api_token_permission_groups.all.permissions["Zone Read"]
|
||||
]
|
||||
resources = {
|
||||
"com.cloudflare.api.account.zone.*" = "*"
|
||||
}
|
||||
}
|
||||
|
||||
condition {
|
||||
request_ip {
|
||||
in = [
|
||||
data.http.public_ip.body
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_secret" "external_dns_token" {
|
||||
metadata {
|
||||
name = "cloudflare-api-token"
|
||||
namespace = "external-dns"
|
||||
}
|
||||
|
||||
data = {
|
||||
"value" = cloudflare_api_token.external_dns.value
|
||||
}
|
||||
}
|
||||
|
6
external/external-dns/values.yaml
vendored
6
external/external-dns/values.yaml
vendored
@ -1,2 +1,8 @@
|
||||
external-dns:
|
||||
provider: cloudflare
|
||||
env:
|
||||
- name: CF_API_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-api-token
|
||||
key: value
|
||||
|
5
external/versions.tf
vendored
5
external/versions.tf
vendored
@ -25,5 +25,10 @@ terraform {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.7.0"
|
||||
}
|
||||
|
||||
http = {
|
||||
source = "hashicorp/http"
|
||||
version = "~> 2.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user