This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

flux

Flux cluster bootstrap and workload deployment

Flux network showing browser access, Vault sign-in and certificate renewal, and Terraform and Forgejo deployment pathsFlux network showing browser access, Vault sign-in and certificate renewal, and Terraform and Forgejo deployment paths

The three Vault nodes show the same service from different network paths. Vertical network diagram · Interactive 3D network diagram

Views with one Vault node are available in horizontal, vertical, and interactive 3D layouts.

  • DNS manages the Flux host and Operator ingress records.
  • AppRole manages the Vault identity used for DNS, Xen Orchestra login, SSH certificates, and Terraform state.

Provision the XCP-ng VM, then run the K3s bootstrap. Apply the separate Terraform workload root to install the Flux Operator and FluxInstance. Follow the Operator ingress runbook to make the UI available.

1 - Flux DNS

Owner-local DNS Terraform

This root manages the records in dnsconfig.json using //infra/flux/dns:tf.<operation>. Follow the shared transfer procedure before operating this root.

2 - Flux K3s bootstrap

After provisioning the VM, wait for cloud-init and verify the initial SSH host key out of band. Run bazel run //infra/flux/ansible. AL uses the Flux AppRole to obtain a short-lived Vault-signed SSH client certificate for the ansible user, which cloud-init configures on the guest. Ansible installs a Vault-signed host certificate during bootstrap.

The shared K3s role installs the repository-pinned binary and writes the server configuration. The API server trusts the existing Flux Vault OIDC issuer. The only project manifest in the auto-deploy directory grants Kubernetes cluster administration to the Vault group src_infra_flux_admins, which includes the deployment AppRole. Terraform uses that grant to install charts with cluster-scoped resources.

After K3s starts, the shared role publishes the public API server CA at the Vault path configured by Flux. It updates that entry if the CA has changed.

The host firewall accepts SSH and lets cluster pods reach the API. Vault can reach TCP 6443 from its private address for TokenReview. The DC1 management and workload LANs and shared ingress peers can connect to TCP 443 on the VM. The Terraform workload root opens its SSH forward automatically and authenticates with a Vault OIDC token.

The normal Flux playbook enables the HTTPS socket. On an existing VM with Traefik listening on TCP 443, apply the workload root before running the playbook so Traefik releases the port. Systemd listens on TCP 443 and starts its TCP proxy on demand. Traefik terminates TLS on loopback TCP 8443. The host firewall checks the original source address. Traefik sees the proxy’s loopback address.

The socket role installs the SELinux policy that lets the systemd proxy bind and connect to the HTTP port type used by TCP 443 and 8443.

3 - Flux Vault AppRole

This Terraform root manages the Flux AppRoles, their DNS and SSH signing policies, and the Flux PKI, OIDC, and SOPS Transit configuration. Shared Vault manages the mounts and cross-component memberships, including the Forgejo and Harbor grants. The DNS root authenticates with the src_infra_flux AppRole and uses a separate state backend.

Review changes with //infra/flux/approle:tf.plan. The state transfer record describes the completed migration from shared Vault state.

4 - Flux workloads

Terraform installs the Flux Operator using the mirrored Forgejo chart and image, then applies the FluxInstance after the operator is ready. The instance uses the distribution embedded in the operator and pulls controller images from Forgejo. The chart and images support anonymous reads.

The workload root also installs cert-manager with its CRDs and Traefik with a non-root loopback HTTPS listener on the VM. Both pull their pinned charts and images from Forgejo. Publish the cert-manager and Traefik mirrors before applying the root.

After bootstrapping K3s, run Terraform from any host that can reach the VM’s SSH port. AL obtains a Vault-signed SSH client certificate, verifies the VM’s SSH host certificate, and opens the API forward on a private loopback port for the invocation. AL also fetches the Kubernetes server CA and a Vault OIDC ID token for Helm. The K3s bootstrap binding grants the Flux AppRole cluster administration through its Vault group.

bazel run //infra/flux/tf:tf.plan
bazel run //infra/flux/tf:tf.apply

Helm waits for the operator deployment. FluxInstance reconciliation continues after the Helm release completes. Bump the local instance chart version when changing its template so Terraform plans a Helm upgrade.

Open https://operator.flux.alwaldend.com and sign in with Vault OIDC. On the DC1 management and workload LANs, DNS points directly to the Flux VM and browsers need to trust the Vault server CA. Outside those LANs, use shared ingress with a trusted client certificate. The Flux user group receives the Kubernetes view role.

For the initial rollout, apply the Flux AppRole root before running the K3s playbook. Then apply the workload root. cert-manager uses a short-lived Flux service account token to renew the backend certificate through Vault, which validates the token over the private network. The workload plan needs the Vault OIDC client and the public API CA, both supplied by AL. After the workload apply, activate the host HTTPS socket. When migrating the existing listener, TCP 443 is briefly unavailable between those stages.

Before applying shared ingress, apply the Flux DNS root and verify that the flux-operator issuer and flux-operator-tls certificate are ready in flux-system. Shared ingress connects to dc1.operator.flux.alwaldend.com over WireGuard, with TLS verification for the public hostname.

5 - Flux XCP-ng VM

This root provisions the Fedora VM and its disks on XCP-ng through Xen Orchestra. It reads the host address from Flux DNS.

The src_infra_flux Vault AppRole signs in to Xen Orchestra through Vault OIDC. AL injects the invocation-scoped XO token and revokes it on normal shutdown. Flux can provision within its assigned resource set. The state backend uses the same AppRole and the dedicated tf_backend/xcp_ng_setup path.

Before the first provisioning run, synchronize the AppRole’s XO identity if needed, then reconcile the src_infra_flux resource set using the Xen Orchestra workflow.

XO_BOOTSTRAP_APPROLE=src_infra_flux bazel run //infra/xcp_ng/cmd/xo_login:bootstrap
bazel run //infra/xcp_ng/tf:tf.plan
bazel run //infra/xcp_ng/tf:tf.apply

Review the Flux VM plan before applying it.

bazel run //infra/flux/tf_setup:tf_setup.plan
bazel run //infra/flux/tf_setup:tf_setup.apply

6 - OpenSpec

6.1 - Specifications

6.1.1 - Infra flux

6.1.1.1 - Flux infrastructure specification

Define the Flux DNS, Vault identities, minimal K3s bootstrap, and Terraform workload configuration.

The Flux infrastructure project SHALL expose its site-local DNS declarations through a standalone Terraform package authenticated with the existing src_infra_flux Vault AppRole and its dedicated DNS state backend. The project SHALL manage the Flux-specific AppRoles, policies, identity groups, PKI, OIDC, and Transit configuration from a separate local root.

  • WHEN a maintainer selects the Flux DNS Terraform package
  • THEN it consumes the existing Flux DNS declaration and uses the component AppRole and DNS backend
  • AND no Flux VM, host deployment, or cluster reconciliation package is required
  • WHEN shared Vault reconciles a Forgejo, Harbor, or global grant for Flux
  • THEN it resolves the Flux identities by their Vault names
  • AND the Flux AppRole root owns the identities and component policies

Flux SHALL provision its guest through Xen Orchestra with an invocation-scoped session issued for the Flux Vault AppRole.

  • WHEN an operator applies the VM root
  • THEN the provider uses the Flux resource set and resolves the guest address from the Flux DNS declaration

Flux SHALL bootstrap a K3s host with the repository-pinned binary and configure Vault OIDC for the API. The K3s auto-deploy directory SHALL contain only the project RBAC binding that authorizes Terraform to administer the cluster.

  • WHEN an operator runs the Flux bootstrap playbook
  • THEN it installs K3s from the packaged binary and binds the Flux Vault administrator group

Terraform SHALL manage the Flux Operator and FluxInstance as ordered releases using a dedicated state backend.

  • WHEN an operator applies the workload root
  • THEN Terraform installs the mirrored operator and its CRDs before submitting the FluxInstance
  • AND the launcher opens its SSH tunnel and supplies the Vault OIDC token and server CA
  • AND the instance selects the mirrored Flux controller images

Flux SHALL install Traefik and cert-manager as Terraform-managed Helm releases using pinned charts and images mirrored in Forgejo.

  • WHEN an operator applies the workload Terraform root
  • THEN Terraform installs Traefik with a cluster-local Service and cert-manager with its CRDs