vault+routeros: internal-app PKI (pki-apps-caosh) and internal gateway access #167

Merged
ginjiruu merged 1 commit from internal-apps-pki into master 2026-11-20 02:43:19 +00:00
Owner

OpenBao and router groundwork for internal app names (<app>.apps.caosh.int.animeteamspeak.moe, machine-configs ADR-0005 amendment). No user-visible change; it pairs with the clusters PR that adds mini's internal Gateway, issuer and internal external-dns.

OpenBao (vault/)

  • modules/openbao-platform: a new optional pki_apps input. It creates the mount pki-apps-<site>, signed online by pki-issue with pathlen 0 and a DNS constraint on apps.<site>.int..., the same shape as pki-net. It adds role cert-manager (server certs for subdomains of that zone, 90 d) and policy pki-apps-<site>-cert-manager (sign/cert-manager only). Unset means no change, so vault/sim and other callers are unaffected unless they set it.
  • platform.tf: pki_apps for caosh, apps.caosh.int.animeteamspeak.moe.
  • cert-manager-mini.tf: JWT role cert-manager on auth/kubernetes-mini for system:serviceaccount:cert-manager:openbao-apps-issuer, audience = mini's ServiceAccount issuer (cert-manager adds it via serviceAccountRef.audiences).
  • eso-mini.tf: mini's ESO may read infra/.../apps/c1/generated/dns/pdns-api. mini's internal external-dns uses c1's PowerDNS API key.

Routers (routeros/)

  • modules/site internal_gateways = ["10.10.6.40"]: mini's internal Gateway, never port-forwarded.
  • modules/router firewall.tf: the servers zone (c1) may reach it on tcp 80/443, placed with the recursor allows. c1 nodes pull from harbor, which moves to the internal Gateway. Trusted clients already reach everything; mgmt, iot and guest do not.

Sim (harness OpenBao, this branch via IAC_REF)

  • vault/sim applied with pki_apps. The mount and role exist, and the policy is exactly sign/cert-manager update.
  • Signing grafana.apps.caosh.int.animeteamspeak.moe: the leaf verifies against the lab root through the 3-cert chain. The CA carries Name Constraints: critical, Permitted: DNS:apps.caosh.int.animeteamspeak.moe.
  • Signing vault.animeteamspeak.moe: refused (400).
  • task routeros:validate (3 roots), routeros:guard, and tofu validate for vault and vault/sim pass. The firewall rule is not simmed on the CHR pair; it is one accept of the existing rule shape.

Order

Merge before the clusters PR's internal issuer goes live, otherwise the ClusterIssuer stays not-Ready until it can log in. The router change re-arms all three roots; the arm lock serializes them.

OpenBao and router groundwork for internal app names (`<app>.apps.caosh.int.animeteamspeak.moe`, machine-configs ADR-0005 amendment). No user-visible change; it pairs with the clusters PR that adds mini's internal Gateway, issuer and internal external-dns. ## OpenBao (`vault/`) - `modules/openbao-platform`: a new optional `pki_apps` input. It creates the mount `pki-apps-<site>`, signed online by `pki-issue` with pathlen 0 and a DNS constraint on `apps.<site>.int...`, the same shape as `pki-net`. It adds role `cert-manager` (server certs for subdomains of that zone, 90 d) and policy `pki-apps-<site>-cert-manager` (`sign/cert-manager` only). Unset means no change, so `vault/sim` and other callers are unaffected unless they set it. - `platform.tf`: `pki_apps` for caosh, `apps.caosh.int.animeteamspeak.moe`. - `cert-manager-mini.tf`: JWT role `cert-manager` on `auth/kubernetes-mini` for `system:serviceaccount:cert-manager:openbao-apps-issuer`, audience = mini's ServiceAccount issuer (cert-manager adds it via `serviceAccountRef.audiences`). - `eso-mini.tf`: mini's ESO may read `infra/.../apps/c1/generated/dns/pdns-api`. mini's internal external-dns uses c1's PowerDNS API key. ## Routers (`routeros/`) - `modules/site` `internal_gateways = ["10.10.6.40"]`: mini's internal Gateway, never port-forwarded. - `modules/router` `firewall.tf`: the servers zone (c1) may reach it on tcp 80/443, placed with the recursor allows. c1 nodes pull from harbor, which moves to the internal Gateway. Trusted clients already reach everything; mgmt, iot and guest do not. ## Sim (harness OpenBao, this branch via `IAC_REF`) - `vault/sim` applied with `pki_apps`. The mount and role exist, and the policy is exactly `sign/cert-manager` update. - Signing `grafana.apps.caosh.int.animeteamspeak.moe`: the leaf verifies against the lab root through the 3-cert chain. The CA carries `Name Constraints: critical, Permitted: DNS:apps.caosh.int.animeteamspeak.moe`. - Signing `vault.animeteamspeak.moe`: refused (400). - `task routeros:validate` (3 roots), `routeros:guard`, and `tofu validate` for `vault` and `vault/sim` pass. The firewall rule is not simmed on the CHR pair; it is one accept of the existing rule shape. ## Order Merge before the clusters PR's internal issuer goes live, otherwise the ClusterIssuer stays not-Ready until it can log in. The router change re-arms all three roots; the arm lock serializes them.
Collaborator

tf-controller plan output:


OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place (current -> planned)

OpenTofu will perform the following actions:

  # vault_jwt_auth_backend_role.mini_cert_manager will be created
  + resource "vault_jwt_auth_backend_role" "mini_cert_manager" {
      + backend                      = "kubernetes-mini"
      + bound_audiences              = [
          + "https://kubernetes.default.svc.cluster.local",
        ]
      + bound_claims_type            = (known after apply)
      + bound_subject                = "system:serviceaccount:cert-manager:openbao-apps-issuer"
      + clock_skew_leeway            = 0
      + disable_bound_claims_parsing = false
      + expiration_leeway            = 0
      + id                           = (known after apply)
      + not_before_leeway            = 0
      + role_name                    = "cert-manager"
      + role_type                    = "jwt"
      + token_max_ttl                = 3600
      + token_policies               = [
          + "pki-apps-caosh-cert-manager",
        ]
      + token_ttl                    = 900
      + token_type                   = "default"
      + user_claim                   = "sub"
      + user_claim_json_pointer      = false
      + verbose_oidc_logging         = false
    }

  # vault_policy.mini_external_secrets will be updated in-place
  ~ resource "vault_policy" "mini_external_secrets" {
        id     = "mini-external-secrets"
        name   = "mini-external-secrets"
      ~ policy = <<-EOT
            # ESO on mini (ClusterSecretStore `openbao`): read-only.
            # RouterOS Terraform vars (flux-clusters clusters/mini/iac/routeros-*-vars.yaml).
            path "secret/data/routeros-secrets" {
              capabilities = ["read"]
            }
            
            path "secret/metadata/routeros-secrets" {
              capabilities = ["read"]
            }
            
            # RouterOS monitoring passwords (lab/iac#139): written by the routeros
            # roots (modules/monitoring), read by mktxp's ExternalSecret.
            path "secret/data/routeros-monitoring/*" {
              capabilities = ["read"]
            }
            
            path "secret/metadata/routeros-monitoring/*" {
              capabilities = ["read"]
            }
            
            # Generated app credentials (flux-clusters generic-templates/unifi-mini):
            # ESO generates the UniFi/mongo passwords once (CreatedOnce generator) and
            # PushSecrets them here, so the value survives a cluster rebuild instead
            # of living only in a k8s Secret. This is the first ESO-WRITTEN path; the
            # grants above stay read-only.
            path "secret/data/unifi/*" {
              capabilities = ["create", "read", "update", "patch", "delete"]
            }
            
            path "secret/metadata/unifi/*" {
              capabilities = ["create", "read", "update", "delete", "list"]
            }
          + 
          + path "infra/data/apps/c1/generated/dns/pdns-api" {
          +   capabilities = ["read"]
          + }
          + 
          + path "infra/metadata/apps/c1/generated/dns/pdns-api" {
          +   capabilities = ["read"]
          + }
        EOT
    }

  # module.platform.vault_mount.pki_apps["caosh"] will be created
  + resource "vault_mount" "pki_apps" {
      + accessor                     = (known after apply)
      + audit_non_hmac_request_keys  = (known after apply)
      + audit_non_hmac_response_keys = (known after apply)
      + default_lease_ttl_seconds    = (known after apply)
      + description                  = "Internal-app CA, site caosh (ADR-0009)"
      + external_entropy_access      = false
      + force_no_cache               = (known after apply)
      + id                           = (known after apply)
      + max_lease_ttl_seconds        = 94608000
      + path                         = "pki-apps-caosh"
      + seal_wrap                    = (known after apply)
      + type                         = "pki"
    }

  # module.platform.vault_pki_secret_backend_intermediate_cert_request.pki_apps["caosh"] will be created
  + resource "vault_pki_secret_backend_intermediate_cert_request" "pki_apps" {
      + add_basic_constraints = false
      + backend               = "pki-apps-caosh"
      + common_name           = "animeteamspeak pki-apps-caosh 2026"
      + csr                   = (known after apply)
      + format                = "pem"
      + id                    = (known after apply)
      + key_bits              = 256
      + key_id                = (known after apply)
      + key_name              = (known after apply)
      + key_ref               = (known after apply)
      + key_type              = "ec"
      + organization          = "animeteamspeak lab"
      + private_key           = (sensitive value)
      + private_key_format    = "der"
      + private_key_type      = (known after apply)
      + type                  = "internal"
    }

  # module.platform.vault_pki_secret_backend_intermediate_set_signed.pki_apps["caosh"] will be created
  + resource "vault_pki_secret_backend_intermediate_set_signed" "pki_apps" {
      + backend          = "pki-apps-caosh"
      + certificate      = (known after apply)
      + id               = (known after apply)
      + imported_issuers = (known after apply)
      + imported_keys    = (known after apply)
    }

  # module.platform.vault_pki_secret_backend_role.cert_manager["caosh"] will be created
  + resource "vault_pki_secret_backend_role" "cert_manager" {
      + allow_any_name                     = false
      + allow_bare_domains                 = false
      + allow_glob_domains                 = false
      + allow_ip_sans                      = false
      + allow_localhost                    = true
      + allow_subdomains                   = true
      + allow_wildcard_certificates        = true
      + allowed_domains                    = [
          + "apps.caosh.int.animeteamspeak.moe",
        ]
      + allowed_domains_template           = false
      + allowed_uri_sans_template          = (known after apply)
      + backend                            = "pki-apps-caosh"
      + basic_constraints_valid_for_non_ca = false
      + client_flag                        = false
      + cn_validations                     = (known after apply)
      + code_signing_flag                  = false
      + email_protection_flag              = false
      + enforce_hostnames                  = true
      + generate_lease                     = false
      + id                                 = (known after apply)
      + issuer_ref                         = (known after apply)
      + key_bits                           = 2048
      + key_type                           = "any"
      + key_usage                          = (known after apply)
      + max_ttl                            = "31536000"
      + name                               = "cert-manager"
      + no_store                           = false
      + not_before_duration                = (known after apply)
      + require_cn                         = true
      + serial_number_source               = (known after apply)
      + server_flag                        = true
      + signature_bits                     = (known after apply)
      + ttl                                = "7776000"
      + use_csr_common_name                = true
      + use_csr_sans                       = true
    }

  # module.platform.vault_pki_secret_backend_root_sign_intermediate.pki_apps["caosh"] will be created
  + resource "vault_pki_secret_backend_root_sign_intermediate" "pki_apps" {
      + backend               = "pki-issue"
      + ca_chain              = (known after apply)
      + certificate           = (known after apply)
      + certificate_bundle    = (known after apply)
      + common_name           = "animeteamspeak pki-apps-caosh 2026"
      + csr                   = (known after apply)
      + format                = "pem"
      + id                    = (known after apply)
      + issuing_ca            = (known after apply)
      + max_path_length       = 0
      + organization          = "animeteamspeak lab"
      + permitted_dns_domains = [
          + "apps.caosh.int.animeteamspeak.moe",
        ]
      + revoke                = false
      + serial_number         = (known after apply)
      + ttl                   = "26280h"
      + use_csr_values        = true
    }

  # module.platform.vault_policy.pki_apps_cert_manager["caosh"] will be created
  + resource "vault_policy" "pki_apps_cert_manager" {
      + id     = (known after apply)
      + name   = "pki-apps-caosh-cert-manager"
      + policy = <<-EOT
            path "pki-apps-caosh/sign/cert-manager" {
              capabilities = ["update"]
            }
        EOT
    }

Plan: 7 to add, 1 to change, 0 to destroy.

To apply this plan, please merge this pull request.

tf-controller plan output: ```hcl OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create ~ update in-place (current -> planned) OpenTofu will perform the following actions: # vault_jwt_auth_backend_role.mini_cert_manager will be created + resource "vault_jwt_auth_backend_role" "mini_cert_manager" { + backend = "kubernetes-mini" + bound_audiences = [ + "https://kubernetes.default.svc.cluster.local", ] + bound_claims_type = (known after apply) + bound_subject = "system:serviceaccount:cert-manager:openbao-apps-issuer" + clock_skew_leeway = 0 + disable_bound_claims_parsing = false + expiration_leeway = 0 + id = (known after apply) + not_before_leeway = 0 + role_name = "cert-manager" + role_type = "jwt" + token_max_ttl = 3600 + token_policies = [ + "pki-apps-caosh-cert-manager", ] + token_ttl = 900 + token_type = "default" + user_claim = "sub" + user_claim_json_pointer = false + verbose_oidc_logging = false } # vault_policy.mini_external_secrets will be updated in-place ~ resource "vault_policy" "mini_external_secrets" { id = "mini-external-secrets" name = "mini-external-secrets" ~ policy = <<-EOT # ESO on mini (ClusterSecretStore `openbao`): read-only. # RouterOS Terraform vars (flux-clusters clusters/mini/iac/routeros-*-vars.yaml). path "secret/data/routeros-secrets" { capabilities = ["read"] } path "secret/metadata/routeros-secrets" { capabilities = ["read"] } # RouterOS monitoring passwords (lab/iac#139): written by the routeros # roots (modules/monitoring), read by mktxp's ExternalSecret. path "secret/data/routeros-monitoring/*" { capabilities = ["read"] } path "secret/metadata/routeros-monitoring/*" { capabilities = ["read"] } # Generated app credentials (flux-clusters generic-templates/unifi-mini): # ESO generates the UniFi/mongo passwords once (CreatedOnce generator) and # PushSecrets them here, so the value survives a cluster rebuild instead # of living only in a k8s Secret. This is the first ESO-WRITTEN path; the # grants above stay read-only. path "secret/data/unifi/*" { capabilities = ["create", "read", "update", "patch", "delete"] } path "secret/metadata/unifi/*" { capabilities = ["create", "read", "update", "delete", "list"] } + + path "infra/data/apps/c1/generated/dns/pdns-api" { + capabilities = ["read"] + } + + path "infra/metadata/apps/c1/generated/dns/pdns-api" { + capabilities = ["read"] + } EOT } # module.platform.vault_mount.pki_apps["caosh"] will be created + resource "vault_mount" "pki_apps" { + accessor = (known after apply) + audit_non_hmac_request_keys = (known after apply) + audit_non_hmac_response_keys = (known after apply) + default_lease_ttl_seconds = (known after apply) + description = "Internal-app CA, site caosh (ADR-0009)" + external_entropy_access = false + force_no_cache = (known after apply) + id = (known after apply) + max_lease_ttl_seconds = 94608000 + path = "pki-apps-caosh" + seal_wrap = (known after apply) + type = "pki" } # module.platform.vault_pki_secret_backend_intermediate_cert_request.pki_apps["caosh"] will be created + resource "vault_pki_secret_backend_intermediate_cert_request" "pki_apps" { + add_basic_constraints = false + backend = "pki-apps-caosh" + common_name = "animeteamspeak pki-apps-caosh 2026" + csr = (known after apply) + format = "pem" + id = (known after apply) + key_bits = 256 + key_id = (known after apply) + key_name = (known after apply) + key_ref = (known after apply) + key_type = "ec" + organization = "animeteamspeak lab" + private_key = (sensitive value) + private_key_format = "der" + private_key_type = (known after apply) + type = "internal" } # module.platform.vault_pki_secret_backend_intermediate_set_signed.pki_apps["caosh"] will be created + resource "vault_pki_secret_backend_intermediate_set_signed" "pki_apps" { + backend = "pki-apps-caosh" + certificate = (known after apply) + id = (known after apply) + imported_issuers = (known after apply) + imported_keys = (known after apply) } # module.platform.vault_pki_secret_backend_role.cert_manager["caosh"] will be created + resource "vault_pki_secret_backend_role" "cert_manager" { + allow_any_name = false + allow_bare_domains = false + allow_glob_domains = false + allow_ip_sans = false + allow_localhost = true + allow_subdomains = true + allow_wildcard_certificates = true + allowed_domains = [ + "apps.caosh.int.animeteamspeak.moe", ] + allowed_domains_template = false + allowed_uri_sans_template = (known after apply) + backend = "pki-apps-caosh" + basic_constraints_valid_for_non_ca = false + client_flag = false + cn_validations = (known after apply) + code_signing_flag = false + email_protection_flag = false + enforce_hostnames = true + generate_lease = false + id = (known after apply) + issuer_ref = (known after apply) + key_bits = 2048 + key_type = "any" + key_usage = (known after apply) + max_ttl = "31536000" + name = "cert-manager" + no_store = false + not_before_duration = (known after apply) + require_cn = true + serial_number_source = (known after apply) + server_flag = true + signature_bits = (known after apply) + ttl = "7776000" + use_csr_common_name = true + use_csr_sans = true } # module.platform.vault_pki_secret_backend_root_sign_intermediate.pki_apps["caosh"] will be created + resource "vault_pki_secret_backend_root_sign_intermediate" "pki_apps" { + backend = "pki-issue" + ca_chain = (known after apply) + certificate = (known after apply) + certificate_bundle = (known after apply) + common_name = "animeteamspeak pki-apps-caosh 2026" + csr = (known after apply) + format = "pem" + id = (known after apply) + issuing_ca = (known after apply) + max_path_length = 0 + organization = "animeteamspeak lab" + permitted_dns_domains = [ + "apps.caosh.int.animeteamspeak.moe", ] + revoke = false + serial_number = (known after apply) + ttl = "26280h" + use_csr_values = true } # module.platform.vault_policy.pki_apps_cert_manager["caosh"] will be created + resource "vault_policy" "pki_apps_cert_manager" { + id = (known after apply) + name = "pki-apps-caosh-cert-manager" + policy = <<-EOT path "pki-apps-caosh/sign/cert-manager" { capabilities = ["update"] } EOT } Plan: 7 to add, 1 to change, 0 to destroy. ``` To apply this plan, please **merge** this pull request.
ginjiruu merged commit 3952a1815a into master 2026-11-20 02:43:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/iac!167
No description provided.