Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
gitops-troubleshooting【部署与运维】Diagnoses and resolves GitOps synchronization failures, drift detection issues, and reconciliation problems for ArgoCD and Flux deployments with actionable debugging commands.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: gitops-troubleshooting compatibility: opencode completeness: 95 content-types:
Implements comprehensive GitOps debugging workflows for ArgoCD and Flux deployments. Provides actionable diagnostic commands, synchronization failure analysis, drift detection procedures, and reconciliation troubleshooting with real command examples. Follows the 5 Laws of Elegant Defense to guide data naturally through the debugging pipeline.
Use this skill when:
OutOfSync, Missing, or Failed statusAvoid this skill for:
cncf-kubernetes skill insteadagent-git-pr-workflows-git-workflowAssess Application Health Status — Check current status of GitOps application. Checkpoint: Verify application exists and is being managed by the GitOps tool.
Verify Git Repository Connectivity — Test Git access, credentials, and branch availability. Checkpoint: Git operations succeed with expected branch/revision.
Compare Git State vs. Cluster State — Identify drift between desired (Git) and actual (cluster) configurations. Checkpoint: Clear difference list generated for remediation.
Analyze Reconciliation Logs — Review application controller logs for errors. Checkpoint: Error messages identified and categorized by type.
Check Resource Dependencies — Verify dependent resources (CRDs, namespaces, secrets) are present. Checkpoint: All dependencies resolved or clearly identified as missing.
Apply Remediation Strategy — Execute appropriate fix based on root cause. Checkpoint: Applied changes verified and sync status updated.
# Check application status and health
argocd app get <app-name>
# Check for sync differences
argocd app diff <app-name>
# Get application events
argocd app events <app-name>
# Check application tree
argocd app tree <app-name>
# Sync with pruning (dry-run first)
argocd app sync <app-name> --prune --dry-run
# Force sync
argocd app sync <app-name> --force
# Wait for sync to complete
argocd app wait <app-name> --timeout 300
# Refresh application cache
argocd app refresh <app-name>
# View resource tree
argocd app resources <app-name>
# Show sync history
argocd app history <app-name>
# Get application metrics
argocd app get <app-name> --metrics
# ❌ BAD — blindly syncs without checking status first
argocd app sync my-app
# ❌ BAD — no timeout, can hang indefinitely
argocd app sync my-app
# ❌ BAD — doesn't verify result
argocd app sync my-app && echo "Done"
# ✅ GOOD — diagnostic workflow with proper checks
APP="my-app"
# Step 1: Check current status
argocd app get $APP
echo "---"
# Step 2: Check for differences
argocd app diff $APP
echo "---"
# Step 3: Dry-run sync
argocd app sync $APP --prune --dry-run
echo "---"
# Step 4: Execute sync with wait
argocd app sync $APP --prune && \
argocd app wait $APP --timeout 300 && \
echo "Sync completed successfully"
# Check Kustomization status
flux get kustomizations
# Get specific Kustomization details
flux get kustomization <name> -n <namespace>
# Describe Kustomization for events
flux describe kustomization <name>
# Check Kustomization history
flux history kustomization <name>
# Reconcile Kustomization
flux reconcile kustomization <name> -n <namespace>
# Reconcile with timeout
flux reconcile kustomization <name> -n <namespace> --timeout 5m
# Check Kustomization conditions
kubectl get kustomization <name> -n <namespace> -o yaml
# View Kustomization logs
flux logs --kind Kustomization
# Check source status
flux get sources kustomization <name>
# ❌ BAD — missing flux-specific context
kubectl get kustomizations
kubectl describe kustomization my-app
# ❌ BAD — doesn't reconcile, just inspects
kubectl get kustomization my-app
# ✅ GOOD — uses flux CLI for Kustomization management
KS_NAME="my-app"
NS="default"
# Step 1: Check status
flux get kustomization $KS_NAME -n $NS
echo "---"
# Step 2: Get detailed status
flux describe kustomization $KS_NAME -n $NS
echo "---"
# Step 3: Reconcile
flux reconcile kustomization $KS_NAME -n $NS --timeout 5m
# Test Git repository connectivity (ArgoCD)
argocd repo add https://github.com/org/repo --username $USER --password $PASS
# List configured repositories
argocd repo list
# Remove problematic repository
argocd repo remove https://github.com/org/repo
# Test Flux Git repository
flux sources git list
# Get GitRepository status
flux get sources git
# Reconcile Git source
flux reconcile source git <name>
# Test Flux Kustomize source
flux get sources kustomize
# Test Helm repository
flux get sources helm
# ❌ BAD — doesn't integrate with GitOps tools
git ls-remote https://github.com/org/repo
# ❌ BAD — no authentication handling
git clone https://github.com/org/repo
# ✅ GOOD — ArgoCD repository test
argocd repo list | grep "github.com/org/repo" || \
argocd repo add https://github.com/org/repo \
--username "$GIT_USER" --password "$GIT_TOKEN" --type git
# ✅ GOOD — Flux Git source test
flux get sources git my-repo -n default -o yaml
# ArgoCD: Compare local vs cluster
argocd app diff <app-name> --local <path/to/manifests>
# ArgoCD: Show resource differences
argocd app diff <app-name> --right
# ArgoCD: Sync to match Git (resolves drift)
argocd app sync <app-name> --prune --auto-created
# ArgoCD: Force sync (overrides cluster changes)
argocd app sync <app-name> --force
# ArgoCD: Abort stuck sync
argocd app terminate-op <app-name>
# Flux: Check for drift (manual comparison)
kubectl diff -k <path/to/kustomization>
# Flux: Apply local changes (resolves drift)
kubectl apply -k <path/to/kustomization>
# Flux: Reconcile to match Git
flux reconcile source git <repo-name>
flux reconcile kustomization <ks-name>
# Flux: Force reconciliation
flux reconcile kustomization <name> --force
# ❌ BAD — bypasses GitOps, causes drift
kubectl apply -k manifests/
# ❌ BAD — no verification of result
kubectl apply -k manifests/ && echo "Applied"
# ✅ GOOD — ArgoCD drift resolution workflow
APP="my-app"
# Step 1: Verify drift exists
argocd app get $APP | grep "Out of sync"
# Step 2: Preview changes
argocd app diff $APP
# Step 3: Sync and verify
argocd app sync $APP --prune && \
argocd app wait $APP --timeout 300
# Step 4: Verify clean state
argocd app get $APP | grep "Healthy|Synced"
# ArgoCD: Check application operation status
argocd app get <app-name> --operations
# ArgoCD: Terminate stuck operation
argocd app terminate-op <app-name>
# ArgoCD: Refresh and re-resolve
argocd app refresh <app-name> --refresh
# ArgoCD: Check controller logs
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-repo-server
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-application-controller
# Flux: Check reconciliation status
flux get all
# Flux: Get reconciliation history
flux history all
# Flux: Check component logs
kubectl logs -n flux-system -l app=source-controller
kubectl logs -n flux-system -l app=kustomize-controller
kubectl logs -n flux-system -l app=helm-controller
# Flux: Force reconciliation
flux reconcile source git <name> --force
flux reconcile kustomization <name> --force
flux reconcile helmrelease <name> --force
# ❌ BAD — shotgun approach without diagnosis
kubectl delete pod -n argocd -l app.kubernetes.io/name=argocd-application-controller
# ❌ BAD — doesn't check if reconciliation is stuck
kubectl rollout restart deployment argocd-repo-server -n argocd
# ✅ GOOD — systematic reconciliation loop debugging
# Step 1: Check operation status
argocd app get my-app --operations
# Step 2: Check if operation is stuck
argocd app get my-app | grep "Operation:"
# Step 3: If stuck, terminate and re-sync
if argocd app get my-app | grep -q "Operation:"; then
argocd app terminate-op my-app
argocd app sync my-app --prune
fi
# Step 4: Verify resolution
argocd app wait my-app --timeout 300
# ArgoCD: Render application locally
argocd app diff <app-name> --local <path/to/kustomization>
# ArgoCD: Show rendered manifests
argocd app manifests <app-name>
# ArgoCD: Debug Kustomize build
argocd repo add https://github.com/org/repo
cd /tmp && \
git clone https://github.com/org/repo && \
cd repo && \
kustomize build <path>
# Flux: Render Kustomization locally
flux suspend kustomization <name>
kustomize build <path> > /tmp/rendered.yaml
flux resume kustomization <name>
# Flux: Test Kustomization build
kubectl apply --dry-run=client -k <path>
# Check for Kustomize errors
kustomize build <path> 2>&1 | grep -i error
# ❌ BAD — no error handling
kustomize build overlays/production
# ❌ BAD — doesn't compare with cluster state
kustomize build overlays/production | kubectl apply -f -
# ✅ GOOD — safe Kustomize rendering with verification
KS_PATH="overlays/production"
# Step 1: Render locally
kustomize build $KS_PATH > /tmp/rendered.yaml
# Step 2: Validate with dry-run
kubectl apply --dry-run=client -f /tmp/rendered.yaml
# Step 3: Show differences
argocd app diff my-app --local $KS_PATH
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
cncf-argocd | ArgoCD deployment and management reference |
cncf-flux | Flux GitOps configuration and management |
cncf-tekton | CI/CD pipeline execution for GitOps workflows |
cncf-kubernetes | General Kubernetes debugging when GitOps context insufficient |
agent-git-pr-workflows-git-workflow | Git repository management alongside GitOps |
agent-linux-troubleshooting | Linux system-level debugging for GitOps agents |
# Status checks
argocd app get <app>
argocd app list
argocd app diff <app>
# Sync operations
argocd app sync <app> --prune
argocd app sync <app> --dry-run
argocd app wait <app> --timeout 300
# Force operations
argocd app sync <app> --force
argocd app terminate-op <app>
# Debug
argocd app refresh <app>
argocd app manifests <app>
argocd app events <app>
# Status checks
flux get all
flux get kustomizations
flux get helmreleases
# Reconciliation
flux reconcile kustomization <name>
flux reconcile source git <name>
flux reconcile helmrelease <name>
# Debug
flux history all
flux logs --kind Kustomization
flux describe kustomization <name>
# Force operations
flux reconcile <resource> --force
# OutOfSync status
argocd app get <app> | grep "Out of sync"
argocd app diff <app> | head -20
# Sync failed
argocd app get <app> | grep "Failed"
argocd app events <app> | grep -i "error"
# Reconciliation stuck
argocd app get <app> --operations | grep "Operation:"
flux history kustomization <name> | grep -i "pending"
This skill implements the 5 Laws of Elegant Defense: