GitOps Flow
Phoebe uses Flux as its GitOps operator. Flux continuously monitors the Git repository and automatically applies changes to the cluster when they are committed to the main branch.
Architecture
┌─────────────────┐ push ┌──────────────┐ sync ┌─────────────┐
│ Developer │ ─────────► │ GitHub │ ◄───────── │ Flux │
│ (You!) │ │ Repository │ │ (Cluster) │
└─────────────────┘ └──────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ Kubernetes │
│ Resources │
└─────────────┘How It Works
1. Git Repository as Source of Truth
The Git repository (hbjydev/phoebe) is the single source of truth for the cluster state. All Kubernetes manifests, Helm releases, and configurations are stored in the kubernetes/ directory.
2. Flux Components
Flux runs inside the cluster and consists of several controllers:
- Source Controller: Fetches manifests from the Git repository
- Kustomize Controller: Applies Kustomizations and manages dependencies
- Helm Controller: Deploys applications via HelmRelease resources
- Notification Controller: Handles alerting and external notifications
3. Reconciliation Loop
- Flux polls the Git repository (default interval: 1 hour, configurable per resource)
- When changes are detected, Flux pulls the latest manifests
- The Kustomize Controller applies resources in dependency order
- HelmReleases are reconciled by the Helm Controller
- External Secrets injects sensitive data from 1Password
4. SOPS Decryption
Encrypted secrets (using SOPS with Age encryption) are automatically decrypted at apply time:
spec:
decryption:
provider: sops
secretRef:
name: sops-ageDirectory Structure
kubernetes/
├── apps/ # Application deployments by namespace
│ ├── cert-manager/
│ ├── flux-system/
│ ├── kube-system/
│ └── ...
├── components/ # Reusable Kustomize components
│ ├── common/
│ ├── postgres/
│ ├── redis/
│ └── volsync/
└── flux/ # Flux system configuration
└── cluster/
└── ks.yaml # Root KustomizationKustomization Hierarchy
The root Kustomization at kubernetes/flux/cluster/ks.yaml points to kubernetes/apps/, which contains per-namespace Kustomizations. Dependencies between applications are defined using dependsOn:
spec:
dependsOn:
- name: external-secretsManual Sync
To force an immediate sync (useful for debugging), use the Just commands:
# Sync all GitRepositories
just kube sync-git
# Sync all Kustomizations
just kube sync-ks
# Sync all HelmReleases
just kube sync-hr
# Sync all OCIRepositories
just kube sync-ociDeployment Workflow
- Make changes to manifests in the repository
- Create a PR for review (Renovate does this automatically for dependency updates)
- Merge to main - Flux will automatically detect and apply the changes
- Monitor - Check Flux logs or use
kubectl get ks -Ato verify reconciliation
Troubleshooting
Check Kustomization Status
kubectl get kustomizations -AView Flux Logs
kubectl logs -n flux-system deployment/kustomize-controllerCheck HelmRelease Status
kubectl get helmreleases -AForce Immediate Reconciliation
just kube sync-ks