Flux CD Deep-Dive Skill
Advanced analysis of Flux CD GitOps sources, reconciliation, and deployment pipelines.
MANDATORY: Discovery-First Pattern
Always check Flux installation and source health before inspecting reconciliation.
Phase 1: Discovery
#!/bin/bash
echo "=== Flux Components ==="
kubectl get deployment -n flux-system -o custom-columns='NAME:.metadata.name,READY:.status.readyReplicas,IMAGE:.spec.template.spec.containers[0].image' 2>/dev/null
echo ""
echo "=== Flux Version ==="
kubectl get deployment source-controller -n flux-system -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null
echo ""
echo ""
echo "=== GitRepositories ==="
kubectl get gitrepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,REVISION:.status.artifact.revision,AGE:.metadata.creationTimestamp' 2>/dev/null | head -15
echo ""
echo "=== HelmRepositories ==="
kubectl get helmrepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,URL:.spec.url' 2>/dev/null | head -15
echo ""
echo "=== OCIRepositories ==="
kubectl get ocirepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status' 2>/dev/null | head -10
echo ""
echo "=== Kustomizations ==="
kubectl get kustomizations --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,REVISION:.status.lastAppliedRevision' 2>/dev/null | head -15
Phase 2: Analysis
#!/bin/bash
echo "=== HelmReleases ==="
kubectl get helmreleases --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,CHART:.spec.chart.spec.chart,VERSION:.spec.chart.spec.version' 2>/dev/null | head -15
echo ""
echo "=== Failed Reconciliations ==="
kubectl get kustomizations,helmreleases --all-namespaces -o json 2>/dev/null | jq -r '
.items[] |
select(.status.conditions[]? | select(.type == "Ready" and .status != "True")) |
"\(.kind)/\(.metadata.name)\t\(.status.conditions[] | select(.type == "Ready") | .reason): \(.message // "")[0:80]"
' | head -15
echo ""
echo "=== Source Errors ==="
kubectl get gitrepositories,helmrepositories --all-namespaces -o json 2>/dev/null | jq -r '
.items[] |
select(.status.conditions[]? | select(.type == "Ready" and .status != "True")) |
"\(.kind)/\(.metadata.name)\t\(.status.conditions[] | select(.type == "Ready") | .message // "unknown")[0:80]"
' | head -10
echo ""
echo "=== Image Policies ==="
kubectl get imagepolicies --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,LATEST:.status.latestImage' 2>/dev/null | head -10
echo ""
echo "=== Image Update Automations ==="
kubectl get imageupdateautomations --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,LAST_RUN:.status.lastAutomationRunTime' 2>/dev/null | head -10
echo ""
echo "=== Notification Providers ==="
kubectl get providers --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,TYPE:.spec.type' 2>/dev/null | head -10
echo ""
echo "=== Alerts ==="
kubectl get alerts --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,SEVERITY:.spec.summary' 2>/dev/null | head -10
echo ""
echo "=== Suspended Resources ==="
kubectl get kustomizations,helmreleases --all-namespaces -o json 2>/dev/null | jq -r '
.items[] | select(.spec.suspend == true) |
"\(.kind)/\(.metadata.namespace)/\(.metadata.name)\tSUSPENDED"
'
echo ""
echo "=== Source Controller Logs (errors) ==="
kubectl logs deployment/source-controller -n flux-system --tail=15 2>/dev/null | grep -i "error\|fail" | head -5
Output Format
- Target ≤50 lines per output
- Use
-o custom-columns for CRD resource listings
- Show Ready status and last applied revision for quick health check
- Group HelmReleases by namespace for organized view
- Never dump full Kustomization patches -- show source ref and status only
Anti-Hallucination Rules
- NEVER assume resource names — always discover via CLI/API in Phase 1 before referencing in Phase 2.
- NEVER fabricate metric names or dimensions — verify against the service documentation or
--help output.
- NEVER mix CLI commands between service versions — confirm which version/API you are targeting.
- ALWAYS use the discovery → verify → analyze chain — every resource referenced must have been discovered first.
- ALWAYS handle empty results gracefully — an empty response is valid data, not an error to retry.
Counter-Rationalizations
| Shortcut |
Counter |
Why |
| "I'll skip discovery and check known resources" |
Always run Phase 1 discovery first |
Resource names change, new resources appear — assumed names cause errors |
| "The user only asked for a quick check" |
Follow the full discovery → analysis flow |
Quick checks miss critical issues; structured analysis catches silent failures |
| "Default configuration is probably fine" |
Audit configuration explicitly |
Defaults often leave logging, security, and optimization features disabled |
| "Metrics aren't needed for this" |
Always check relevant metrics when available |
API/CLI responses show current state; metrics reveal trends and intermittent issues |
| "I don't have access to that" |
Try the command and report the actual error |
Assumed permission failures prevent useful investigation; actual errors are informative |
Common Pitfalls
- Dependency ordering: Kustomizations support
dependsOn -- circular dependencies cause deadlocks
- Suspend flag:
spec.suspend: true stops reconciliation -- check before assuming failures
- Source interval:
spec.interval controls how often sources are checked -- too frequent causes rate limits
- HelmRelease remediation:
spec.install.remediation and spec.upgrade.remediation control retry behavior
- Drift detection: Enable
spec.force on Kustomizations to correct drift -- but may cause disruption
- Multi-tenancy: Use
spec.serviceAccountName on Kustomizations for RBAC scoping per tenant
- Image automation: Requires image-reflector and image-automation controllers -- not installed by default
- Prune:
spec.prune: true on Kustomizations deletes resources removed from Git -- use with caution
- Health checks: Custom health checks in Kustomizations can delay Ready status -- check
spec.healthChecks
1---2name: managing-k8s-flux-deep3description: Use when working with K8S Flux Deep — flux CD deep-dive management for Kubernetes GitOps delivery. Covers GitRepository sources, Kustomization reconciliation, HelmRelease status, HelmRepository health, ImagePolicy automation, notification providers, and multi-tenancy configurations. Use when debugging reconciliation failures, analyzing Flux source health, reviewing Helm release drift, or auditing image automation pipelines.4---56# Flux CD Deep-Dive Skill78Advanced analysis of Flux CD GitOps sources, reconciliation, and deployment pipelines.910## MANDATORY: Discovery-First Pattern1112**Always check Flux installation and source health before inspecting reconciliation.**1314### Phase 1: Discovery1516```bash17#!/bin/bash1819echo "=== Flux Components ==="20kubectl get deployment -n flux-system -o custom-columns='NAME:.metadata.name,READY:.status.readyReplicas,IMAGE:.spec.template.spec.containers[0].image' 2>/dev/null2122echo ""23echo "=== Flux Version ==="24kubectl get deployment source-controller -n flux-system -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null25echo ""2627echo ""28echo "=== GitRepositories ==="29kubectl get gitrepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,REVISION:.status.artifact.revision,AGE:.metadata.creationTimestamp' 2>/dev/null | head -153031echo ""32echo "=== HelmRepositories ==="33kubectl get helmrepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,URL:.spec.url' 2>/dev/null | head -153435echo ""36echo "=== OCIRepositories ==="37kubectl get ocirepositories --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status' 2>/dev/null | head -103839echo ""40echo "=== Kustomizations ==="41kubectl get kustomizations --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,REVISION:.status.lastAppliedRevision' 2>/dev/null | head -1542```4344### Phase 2: Analysis4546```bash47#!/bin/bash4849echo "=== HelmReleases ==="50kubectl get helmreleases --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,CHART:.spec.chart.spec.chart,VERSION:.spec.chart.spec.version' 2>/dev/null | head -155152echo ""53echo "=== Failed Reconciliations ==="54kubectl get kustomizations,helmreleases --all-namespaces -o json 2>/dev/null | jq -r '55 .items[] |56 select(.status.conditions[]? | select(.type == "Ready" and .status != "True")) |57 "\(.kind)/\(.metadata.name)\t\(.status.conditions[] | select(.type == "Ready") | .reason): \(.message // "")[0:80]"58' | head -155960echo ""61echo "=== Source Errors ==="62kubectl get gitrepositories,helmrepositories --all-namespaces -o json 2>/dev/null | jq -r '63 .items[] |64 select(.status.conditions[]? | select(.type == "Ready" and .status != "True")) |65 "\(.kind)/\(.metadata.name)\t\(.status.conditions[] | select(.type == "Ready") | .message // "unknown")[0:80]"66' | head -106768echo ""69echo "=== Image Policies ==="70kubectl get imagepolicies --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,LATEST:.status.latestImage' 2>/dev/null | head -107172echo ""73echo "=== Image Update Automations ==="74kubectl get imageupdateautomations --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,LAST_RUN:.status.lastAutomationRunTime' 2>/dev/null | head -107576echo ""77echo "=== Notification Providers ==="78kubectl get providers --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,TYPE:.spec.type' 2>/dev/null | head -107980echo ""81echo "=== Alerts ==="82kubectl get alerts --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,SEVERITY:.spec.summary' 2>/dev/null | head -108384echo ""85echo "=== Suspended Resources ==="86kubectl get kustomizations,helmreleases --all-namespaces -o json 2>/dev/null | jq -r '87 .items[] | select(.spec.suspend == true) |88 "\(.kind)/\(.metadata.namespace)/\(.metadata.name)\tSUSPENDED"89'9091echo ""92echo "=== Source Controller Logs (errors) ==="93kubectl logs deployment/source-controller -n flux-system --tail=15 2>/dev/null | grep -i "error\|fail" | head -594```9596## Output Format9798- Target ≤50 lines per output99- Use `-o custom-columns` for CRD resource listings100- Show Ready status and last applied revision for quick health check101- Group HelmReleases by namespace for organized view102- Never dump full Kustomization patches -- show source ref and status only103104## Anti-Hallucination Rules1051061. **NEVER assume resource names** — always discover via CLI/API in Phase 1 before referencing in Phase 2.1072. **NEVER fabricate metric names or dimensions** — verify against the service documentation or `--help` output.1083. **NEVER mix CLI commands between service versions** — confirm which version/API you are targeting.1094. **ALWAYS use the discovery → verify → analyze chain** — every resource referenced must have been discovered first.1105. **ALWAYS handle empty results gracefully** — an empty response is valid data, not an error to retry.111112## Counter-Rationalizations113114| Shortcut | Counter | Why |115|----------|---------|-----|116| "I'll skip discovery and check known resources" | Always run Phase 1 discovery first | Resource names change, new resources appear — assumed names cause errors |117| "The user only asked for a quick check" | Follow the full discovery → analysis flow | Quick checks miss critical issues; structured analysis catches silent failures |118| "Default configuration is probably fine" | Audit configuration explicitly | Defaults often leave logging, security, and optimization features disabled |119| "Metrics aren't needed for this" | Always check relevant metrics when available | API/CLI responses show current state; metrics reveal trends and intermittent issues |120| "I don't have access to that" | Try the command and report the actual error | Assumed permission failures prevent useful investigation; actual errors are informative |121122## Common Pitfalls123124- **Dependency ordering**: Kustomizations support `dependsOn` -- circular dependencies cause deadlocks125- **Suspend flag**: `spec.suspend: true` stops reconciliation -- check before assuming failures126- **Source interval**: `spec.interval` controls how often sources are checked -- too frequent causes rate limits127- **HelmRelease remediation**: `spec.install.remediation` and `spec.upgrade.remediation` control retry behavior128- **Drift detection**: Enable `spec.force` on Kustomizations to correct drift -- but may cause disruption129- **Multi-tenancy**: Use `spec.serviceAccountName` on Kustomizations for RBAC scoping per tenant130- **Image automation**: Requires image-reflector and image-automation controllers -- not installed by default131- **Prune**: `spec.prune: true` on Kustomizations deletes resources removed from Git -- use with caution132- **Health checks**: Custom health checks in Kustomizations can delay Ready status -- check `spec.healthChecks`