# Argocd Gitops

> GitOps workflows with ArgoCD for Kubernetes deployments

- Skill: `agenticdevops/argocd-gitops` (Agent Skill)
- Install (CLI): `npx skillmds@latest add agenticdevops/argocd-gitops`
- Raw SKILL.md: https://api.skillmd.com/api/skills/agenticdevops/argocd-gitops/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: agenticdevops (https://skillmd.com/u/agenticdevops)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/agenticdevops/argocd-gitops

---


# ArgoCD GitOps

GitOps workflows for Kubernetes deployments using ArgoCD.

## When to Use This Skill

Use this skill when:
- Deploying applications via GitOps
- Managing ArgoCD applications
- Syncing or rolling back deployments
- Troubleshooting sync issues

## ArgoCD CLI Setup

### Login

```bash
# Login to ArgoCD server
argocd login argocd.example.com

# With SSO
argocd login argocd.example.com --sso

# Skip TLS verification (dev only)
argocd login argocd.example.com --insecure

# Check current context
argocd context
```

## Application Management

### List Applications

```bash
# All applications
argocd app list

# With output format
argocd app list -o wide
argocd app list -o json

# Filter by project
argocd app list -p myproject

# Filter by label
argocd app list -l team=backend
```

### View Application

```bash
# Application details
argocd app get myapp

# Manifests
argocd app manifests myapp

# Diff against live
argocd app diff myapp

# History
argocd app history myapp
```

### Application Health

```bash
# Check status
argocd app get myapp -o json | jq '.status.health.status'

# Resources status
argocd app resources myapp

# Events
argocd app logs myapp
```

## Sync Operations

### Sync Application

```bash
# Sync (apply Git state to cluster)
argocd app sync myapp

# Sync with prune (remove deleted resources)
argocd app sync myapp --prune

# Sync specific resources
argocd app sync myapp --resource :Deployment:myapp

# Dry run
argocd app sync myapp --dry-run

# Force sync (bypass hooks)
argocd app sync myapp --force

# Wait for sync completion
argocd app wait myapp
```

### Sync Options

```bash
# Skip schema validation
argocd app sync myapp --validate=false

# Apply out-of-sync only
argocd app sync myapp --apply-out-of-sync-only

# Sync with timeout
argocd app sync myapp --timeout 300
```

### Auto-Sync

```bash
# Enable auto-sync
argocd app set myapp --sync-policy automated

# With prune
argocd app set myapp --sync-policy automated --auto-prune

# Self-heal (revert manual changes)
argocd app set myapp --self-heal

# Disable auto-sync
argocd app set myapp --sync-policy none
```

## Rollback

### Rollback to Previous

```bash
# View history
argocd app history myapp

# Rollback to specific revision
argocd app rollback myapp <history-id>

# Rollback to previous Git commit
argocd app rollback myapp --revision HEAD~1
```

### Rollback Strategies

```bash
# 1. Rollback ArgoCD history
argocd app history myapp
argocd app rollback myapp 5

# 2. Revert Git commit and sync
git revert HEAD
git push
argocd app sync myapp

# 3. Manual override then rollback
argocd app set myapp --revision <old-commit>
argocd app sync myapp
```

## Multi-Environment Promotion

### Typical Flow

```bash
# 1. Deploy to dev (auto-sync)
git commit -m "feat: new feature"
git push origin main
# ArgoCD auto-syncs dev

# 2. Promote to staging
argocd app set myapp-staging --revision $(argocd app get myapp-dev -o json | jq -r '.status.sync.revision')
argocd app sync myapp-staging

# 3. Promote to production (manual)
argocd app set myapp-prod --revision <staging-revision>
argocd app sync myapp-prod
```

### Environment-Specific Overrides

```bash
# Set Helm values per environment
argocd app set myapp-prod --values-literal-file values-prod.yaml

# Set Kustomize overlay
argocd app set myapp-staging --kustomize-image nginx=nginx:1.25
```

## Create Applications

### From Git Repository

```bash
argocd app create myapp \
  --repo https://github.com/org/repo.git \
  --path k8s/overlays/production \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace production \
  --project default

# With Helm
argocd app create myapp \
  --repo https://github.com/org/repo.git \
  --path charts/myapp \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace production \
  --helm-set image.tag=v1.2.3
```

### From Helm Repository

```bash
argocd app create myapp \
  --repo https://charts.example.com \
  --helm-chart myapp \
  --revision 1.2.3 \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace production
```

## Troubleshooting

### Sync Failures

```bash
# Check sync status
argocd app get myapp

# View sync errors
argocd app get myapp -o json | jq '.status.conditions'

# Check resource status
argocd app resources myapp

# View logs
argocd app logs myapp
```

### Common Issues

| Issue | Cause | Fix |
|-------|-------|-----|
| OutOfSync | Drift from Git | `argocd app sync myapp` |
| SyncFailed | Invalid manifests | Check `argocd app get myapp` |
| Degraded | Pods unhealthy | Check pod logs |
| Unknown | Can't reach cluster | Check network/auth |

### Force Refresh

```bash
# Refresh from Git
argocd app get myapp --refresh

# Hard refresh (invalidate cache)
argocd app get myapp --hard-refresh
```

### Stuck Sync

```bash
# Terminate current sync
argocd app terminate-op myapp

# Force sync
argocd app sync myapp --force
```

## Project Management

```bash
# List projects
argocd proj list

# Create project
argocd proj create myproject \
  --src https://github.com/org/* \
  --dest https://kubernetes.default.svc,production

# View project
argocd proj get myproject
```

## Clusters

```bash
# List clusters
argocd cluster list

# Add cluster
argocd cluster add my-context

# Remove cluster
argocd cluster rm https://cluster.example.com
```

## Notifications (Status Checks)

```bash
# Get app health for CI/CD
argocd app wait myapp --health --timeout 300

# Exit code for scripting
argocd app get myapp -o json | jq -e '.status.health.status == "Healthy"'
```

## Quick Reference

```bash
# Deploy new version
argocd app set myapp --revision <commit-sha>
argocd app sync myapp --prune

# Check if healthy
argocd app wait myapp --health

# Quick rollback
argocd app history myapp
argocd app rollback myapp <id>

# Force refresh from Git
argocd app get myapp --hard-refresh
argocd app sync myapp
```

## GitOps Best Practices

1. **Never modify cluster directly** - All changes through Git
2. **Use ApplicationSets** - For multi-cluster/environment
3. **Enable auto-prune** - Keep cluster clean
4. **Use sync waves** - For ordered deployments
5. **Separate config repos** - App code vs deployment config
6. **Review before production** - Manual sync gates

## Related Skills

- **k8s-deploy**: For direct Kubernetes deployments
- **git-workflow**: For managing GitOps repos
- **incident-response**: For deployment-related incidents

