To ensure that critical infrastructure (like CRDs and secrets) is deployed before applications, use a structured directory layout and define dependencies via Kustomization objects. When Flux is bootstrapped with --path=kubernetes/cluster, it reconciles the cluster based on the definitions in that directory (e.g., infrastructure.yaml).
Recommended directory structure:
kubernetes/cluster/: Contains the primary reconciliation logic and Flux system components.kubernetes/infrastructure/: Contains infrastructure-specific manifests (e.g., cert-manager, sealed-secrets).kubernetes/apps/: Contains the actual applications to be deployed.
Typical deployment order and dependencies:
sealed-secrets: Deployed first as other objects depend on it.cert-manager: Deployed after sealed-secrets (e.g., to access Cloudflare tokens for DNS challenges).longhorn: Installs operators and CRDs.apps: Deployed last, with explicit dependencies on cert-manager, sealed-secrets, and longhorn.
kubernetes/
├─ apps/
├─ cluster/
│ ├─ infrastructure.yaml
│ ├─ flux-system/
│ │ ├─ gotk-components.yaml
│ │ ├─ gotk-sync.yaml
│ │ ├─ kustomization.yaml
├─ infrastructure/
│ ├─ cert-manager/
│ ├─ sealed-secrets/