Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
argo【部署与运维】"Argo in Cloud-Native Engineering - Kubernetes-Native Workflow, CI/CD" and Governance
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: argo compatibility: opencode completeness: 95 content-types:
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
Category: workflow
Status: Active
Stars: 14,600
Last Updated: 2026-04-22
Primary Language: Go
Documentation: https://argoproj.github.io/
Argo is a family of Kubernetes-native projects providing workflow management, CI/CD, and governance capabilities for cloud-native applications.
Complex workflow orchestration, CI/CD automation, and governance across Kubernetes clusters. It enables reproducible deployments, audit trails, and policy enforcement for cloud-native applications.
Use Argo Workflows for complex multi-step workflows, Argo CD for GitOps deployment, Argo Events for event-driven automation, or Argo Rollouts for progressive delivery. Ideal when you need Kubernetes-native workflow management with full auditability.
Argo Workflows:
Argo CD:
Argo Events:
Argo Workflows:
Argo CD:
Argo Events:
Argo Workflows:
Argo CD:
Argo Events:
Argo Workflows:
Argo CD:
Argo CD Specific:
Workflow Lifecycle:
Argo CD Lifecycle:
Argo Workflows:
Argo CD:
# Data processing workflow with DAG execution
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: data-pipeline-
spec:
entrypoint: data-pipeline
templates:
- name: data-pipeline
steps:
- - name: extract
template: extract
- - name: transform
template: transform
- - name: load
template: load
- name: extract
container:
image: python:3.9-slim
command: [python]
args: ["-c", "import json; print(json.dumps({'data': 'extracted'}))"]
volumeMounts:
- name: scratch
mountPath: /data
outputs:
artifacts:
- name: data
path: /data/extracted.json
raw:
dataKey: data
- name: transform
container:
image: python:3.9-slim
command: [python]
args: ["-c", "import json; print(json.dumps({'transformed': True}))"]
volumeMounts:
- name: scratch
mountPath: /data
inputs:
artifacts:
- name: data
path: /data/
raw:
dataKey: data
- name: load
container:
image: python:3.9-slim
command: [python]
args: ["-c", "print('Data loaded successfully')"]
volumes:
- name: scratch
emptyDir: {}
# Argo CD Application for GitOps continuous deployment
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/myorg/myapp.git
targetRevision: HEAD
path: k8s
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- FailOnSharedResource=true
revisionHistoryLimit: 10
# Argo Rollouts Canary deployment with progressive delivery
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: myapp
spec:
replicas: 5
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myregistry/myapp:v1
ports:
- containerPort: 8080
strategy:
canary:
steps:
- setWeight: 20
- pause: {duration: 5m}
- setWeight: 40
- pause: {duration: 5m}
- setWeight: 60
- pause: {duration: 5m}
- setWeight: 80
- pause: {duration: 5m}
- setWeight: 100
analysis:
templates:
- templateName: success-rate
startingStep: 2
---
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 1m
count: 5
successCondition: result[0] >= 0.95
provider:
prometheus:
address: http://prometheus:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",status=~"2.."}[1m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[1m]))
This tutorial will guide you through installing, configuring, and using Argo projects from scratch.
Before beginning, ensure you have:
kubectl configured to access your clusterhelm CLI (for Helm installation method)argo CLI (for workflow operations)argocd CLI (for CD operations)Verify your setup:
# Check cluster connectivity
kubectl cluster-info
# Verify kubectl configuration
kubectl get nodes
# Check Helm installation
helm version
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
Argo projects can be installed using kubectl apply (manifests) or Helm charts. Both methods are covered below.
Install Argo Workflows:
# Apply Argo Workflows CRDs and controller
kubectl create namespace argo
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/latest/download/install.yaml
# Verify installation
kubectl get pods -n argo -l app=argo-workflows
Install Argo CD:
# Create namespace and apply Argo CD manifests
kubectl create namespace argocd
kubectl apply -n argocd -f https://github.com/argoproj/argo-cd/releases/latest/download/install.yaml
# Verify installation
kubectl get pods -n argocd
Install Argo Events:
# Apply Argo Events CRDs first
kubectl apply -f https://github.com/argoproj/argo-events/releases/latest/download/crds.yaml
# Create namespace and apply Argo Events
kubectl create namespace argo-events
kubectl apply -n argo-events -f https://github.com/argoproj/argo-events/releases/latest/download/manifests.yaml
# Verify installation
kubectl get pods -n argo-events
Install Argo Rollouts:
# Create namespace and apply Argo Rollouts
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
# Verify installation
kubectl get pods -n argo-rollouts
Install Argo Workflows with Helm:
# Add the Argo Helm repository
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
# Install Argo Workflows
helm install argo argo/argo-workflows \
--namespace argo \
--create-namespace \
--wait
# Verify installation
helm list -n argo
kubectl get pods -n argo
Install Argo CD with Helm:
# Add the Argo CD Helm repository
helm repo add argo-cd https://argoproj.github.io/argo-helm
# Install Argo CD with server disabled (for CLI-only setup)
helm install argocd argo-cd/argocd \
--namespace argocd \
--create-namespace \
--set server.enabled=false \
--wait
# Verify installation
helm list -n argocd
kubectl get pods -n argocd
Install Argo Events with Helm:
# Add the Argo Events Helm repository
helm repo add argo-events https://argoproj.github.io/argo-helm
# Install Argo Events
helm install argo-events argo-events/argo-events \
--namespace argo-events \
--create-namespace \
--wait
# Verify installation
helm list -n argo-events
kubectl get pods -n argo-events
Install Argo Rollouts with Helm:
# Add the Argo Rollouts Helm repository
helm repo add argo-rollouts https://argoproj.github.io/argo-helm
# Install Argo Rollouts
helm install argo-rollouts argo-rollouts/argo-rollouts \
--namespace argo-rollouts \
--create-namespace \
--wait
# Verify installation
helm list -n argo-rollouts
kubectl get pods -n argo-rollouts
Access the Argo Workflows UI:
# Port-forward the Argo Workflows server
kubectl -n argo port-forward svc/argo-server 2746:2746
# Access UI at http://localhost:2746
Configure Artifact Storage (S3 example):
# Create a ConfigMap for artifact storage configuration
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: argo-workflows-artifact-repositories
namespace: argo
data:
archiveLogs: "false"
s3-artifact-repo: |
endpoint: s3.amazonaws.com
bucket: my-argo-artifacts
keyFormat: workflows/{{ workflow.name }}/{{ pod.name }}
region: us-east-1
insecure: false
accessKeySecret:
name: s3-secret
key: access-key
secretKeySecret:
name: s3-secret
key: secret-key
EOF
# Set as default artifact repository
kubectl -n argo patch configmap/argo-workflows \
-p '{"data":{"config":"artifactRepository:\n s3ArtifactRepo: s3-artifact-repo"}}'
Configure RBAC for Workflows:
# Create a ServiceAccount for workflow execution
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: workflow-sa
namespace: argo
---
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
# Create Role for workflow execution
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: workflow-role
namespace: argo
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "watch", "patch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch"]
- apiGroups: ["argoproj.io"]
resources: ["workflows", "workflowtemplates", "cronworkflows"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
# Bind role to service account
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: workflow-role-binding
namespace: argo
subjects:
- kind: ServiceAccount
name: workflow-sa
namespace: argo
roleRef:
kind: Role
name: workflow-role
apiGroup: rbac.authorization.k8s.io
EOF
Access the Argo CD UI:
# Get the initial admin password
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d; echo
# Port-forward the Argo CD server
kubectl -n argocd port-forward svc/argocd-server 8080:443
# Access UI at https://localhost:8080
# Login with user: admin, password: (from above)
Configure Repository Credentials:
# Add a Git repository for deployment
argocd repo add https://github.com/myorg/myapp.git \
--username mygithubuser \
--password mygithubtoken
# Verify repository configuration
argocd repo list
# Or use SSH with a private key
argocd repo add git@github.com:myorg/myapp.git \
--ssh-private-key-path ~/.ssh/id_rsa
Configure RBAC for Argo CD:
# Configure RBAC policies in argocd-rbac-configmap
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-rbac-cfg
namespace: argocd
data:
policy.csv: |
# Admin role has full access
p, role:admin, applications, *, */*, allow
p, role:admin, clusters, *, *, allow
p, role:admin, repositories, *, *, allow
p, role:admin, settings, *, *, allow
p, role:admin, logs, *, *, allow
p, role:admin, events, *, *, allow
# Developer role can sync and sync applications in dev projects
p, role:developer, applications, sync, */*, allow
p, role:developer, applications, override, */*, allow
policy.default: role:readonly
scopes: '[groups]'
EOF
# Configure keycloak or other OIDC provider
# (See official documentation for detailed OIDC configuration)
Install NATS Event Bus:
# Argo Events uses NATS as the default event bus
# Install NATS via Helm
helm repo add nats https://nats-io.github.io/k8s/helm/
helm repo update
# Install NATS
kubectl create namespace nats-io
helm install nats nats/nats \
--namespace nats-io \
--wait
# Verify NATS installation
kubectl get pods -n nats-io
Create a Basic Event Source:
# Create an HTTP webhook event source
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: event-source-config
namespace: argo-events
data:
webhook.json: |
{
"source": {
"webhook": {
"endpoint": "/webhook",
"port": "12000",
"sourceType": "webhook",
"webhook": {
"method": "POST"
}
}
},
"type": "webhook",
"context": {
"type": "com.argoproj.event.source.webhook",
"source": "my-webhook"
},
"data": {
"path": "body"
}
}
EOF
Create a Sensor for Event Processing:
# Create a sensor that triggers a workflow on webhook events
cat <<EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: webhook-sensor
namespace: argo-events
spec:
template:
spec:
containers:
- name: sensor
image: argoproj/sensor:v3.5.0
command: ["/usr/local/bin/sensor"]
serviceAccountName: argo-events-sa
dependencies:
- name: webhook-dep
eventSourceName: webhook-event-source
eventName: webhook
triggers:
- template:
name: workflow-trigger
source:
webhook:
endpoint: /trigger
port: "12001"
method: "POST"
kubernetes:
group: argoproj.io
version: v1alpha1
resource: workflows
operation: create
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: webhook-workflow-
namespace: argo
spec:
entrypoint: main
templates:
- name: main
container:
image: alpine:3.18
command: [sh, -c]
args: ["echo 'Triggered by webhook!'"]
parameters:
- src:
dependencyName: webhook-dep
dataKey: body
dest: spec.arguments.parameters.0.value
EOF
Create Event Source and Sensor Resources:
# Create the webhook event source
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: webhook-event-source
namespace: argo-events
data:
webhook.json: |
{
"type": "webhook",
"source": {
"type": "webhook",
"webhook": {
"endpoint": "/webhook",
"port": "12000",
"sourceType": "webhook",
"method": "POST"
}
},
"context": {
"type": "com.argoprojo.event.source.webhook",
"source": "github-webhook"
},
"data": {
"path": "body"
}
}
EOF
# Create the webhook sensor
cat <<EOF | kubectl apply -f -
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: github-webhook-sensor
namespace: argo-events
spec:
template:
spec:
serviceAccountName: argo-events-sa
dependencies:
- name: github-webhook
eventSourceName: webhook-event-source
eventName: webhook
triggers:
- template:
name: argo-workflow-trigger
argoWorkflow:
group: argoproj.io
version: v1alpha1
resource: workflows
operation: create
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: github-workflow-
namespace: argo
spec:
entrypoint: main
arguments:
parameters:
- name: commit-sha
value: "unknown"
templates:
- name: main
container:
image: alpine:3.18
command: [sh, -c]
args:
- |
echo "Building commit: {{ arguments.parameters.0.value }}"
echo "Event: {{ dependencies.github-webhook.body }}"
EOF
Access the Rollouts Dashboard:
# Port-forward the Argo Rollouts dashboard
kubectl -n argo-rollouts port-forward svc/argo-rollouts 3100:3100
# Access dashboard at http://localhost:3100
Install Kubectl Rollouts Plugin:
# Download and install kubectl rollouts plugin
curl -sLO "https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-rollouts-$(uname -s)-$(uname -m)"
chmod +x kubectl-rollouts-$(uname -s)-$(uname -m)
sudo mv kubectl-rollouts-$(uname -s)-$(uname -m) /usr/local/bin/kubectl-rollouts
# Verify installation
kubectl rollouts version
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
Create a simple "Hello World" workflow:
# hello-world.yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world-
spec:
entrypoint: whalesay
templates:
- name: whalesay
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["Hello, Argo Workflows!"]
Submit the workflow:
# Submit the workflow
argo submit hello-world.yaml --watch
# Or submit without watching
argo submit hello-world.yaml
# List workflows
argo list
# Get workflow status
argo get hello-world-xxxxx
View workflow logs:
# View logs for a specific workflow
argo logs hello-world-xxxxx
# Watch workflow execution in real-time
argo watch hello-world-xxxxx
# Get logs for a specific step
argo logs hello-world-xxxxx whalesay
Create an application YAML file:
# myapp.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: HEAD
path: guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Apply the application:
# Apply the application manifest
kubectl apply -f myapp.yaml
# Or use argocd CLI
argocd app create myapp \
--project default \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default \
--sync-policy automated
# List applications
argocd app list
# Get application details
argocd app get myapp
Sync the application:
# Sync the application to the cluster
argocd app sync myapp
# Sync with dry-run to see what would be applied
argocd app sync myapp --dry-run
# Sync with pruning enabled
argocd app sync myapp --prune
Configure GitHub webhook:
# Get Argo CD webhook secret
WEBHOOK_SECRET=$(kubectl -n argocd get secret argocd-secret \
-o jsonpath='{.data.webhook.gitlab.secret}' | base64 -d)
# Or generate a new secret
WEBHOOK_SECRET=$(openssl rand -hex 20)
kubectl -n argocd patch secret argocd-secret \
--type='string' \
-p="{\"data\": {\"webhook.github.secret\": \"$(echo -n $WEBHOOK_SECRET | base64)\"}}"
# Configure webhook in GitHub
# 1. Go to your repository on GitHub
# 2. Settings → Webhooks → Add webhook
# 3. Set Payload URL: https://argocd.example.com/api/webhook
# 4. Set Content type: application/json
# 5. Set Secret: (use the WEBHOOK_SECRET)
# 6. Select events: Just the push event
Create an application with webhook integration:
# myapp-with-webhook.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: default
source:
repoURL: https://github.com/myorg/myapp.git
targetRevision: main
path: manifests
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
revisionHistoryLimit: 10
Create a Deployment with Rollout strategy:
# myapp-rollout.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: myapp
spec:
replicas: 5
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myregistry/myapp:v1
ports:
- containerPort: 8080
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
strategy:
canary:
steps:
- setWeight: 20 # Route 20% traffic to canary
- pause: {duration: 5m} # Wait 5 minutes
- setWeight: 40 # Route 40% traffic to canary
- pause: {duration: 5m}
- setWeight: 60 # Route 60% traffic to canary
- pause: {duration: 5m}
- setWeight: 80 # Route 80% traffic to canary
- pause: {duration: 5m}
- setWeight: 100 # Route 100% traffic to canary
analysis:
templates:
- templateName: success-rate
startingStep: 2 # Start analysis after setWeight: 40
---
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
# Create the AnalysisTemplate for health checks
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 1m
count: 5
successCondition: result[0] >= 0.95
provider:
prometheus:
address: http://prometheus-server.prometheus.svc.cluster.local:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",status=~"2.."}[1m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[1m]))
Apply the rollout:
# Apply the rollout
kubectl apply -f myapp-rollout.yaml
# Watch rollout progress
kubectl rollouts get rollout myapp --watch
# Check rollout status
kubectl rollouts status myapp
# List rollouts
kubectl rollouts list rollouts
# View rollout history
kubectl rollouts history myapp
# Promote rollout if analysis fails
kubectl rollouts promote myapp
# Undo rollout to previous version
kubectl rollouts undo myapp
related-skills: cncf-artifact-hub, cncf-aws-dynamodb, cncf-aws-ec2, cncf-aws-eks
Watch workflow execution:
# Watch a specific workflow
argo watch hello-world-xxxxx
# Watch all workflows in a namespace
argo watch --namespace argo
# Watch with specific labels
argo watch -l app=myapp --namespace argo
View workflow logs:
# View logs for all steps
argo logs hello-world-xxxxx
# View logs with follow mode
argo logs -f hello-world-xxxxx
# View logs for a specific step
argo logs hello-world-xxxxx step-name
# Download logs to a file
argo logs hello-world-xxxxx > workflow.log
Workflow status commands:
# List all workflows
argo list
# List workflows with specific status
argo list --phase Succeeded
argo list --phase Failed
# List workflows from last 24 hours
argo list --minutes 1440
# Get detailed workflow info
argo get hello-world-xxxxx -o wide
# Get workflow YAML
argo get hello-world-xxxxx -o yaml
Sync an application:
# Sync an application
argocd app sync myapp
# Sync with dry-run
argocd app sync myapp --dry-run
# Sync multiple applications
argocd app sync myapp1 myapp2
# Sync with prune and delete policies
argocd app sync myapp --prune --cascade
Application status and diff:
# Get application status
argocd app get myapp
# Show diff between Git and cluster
argocd app diff myapp
# Show diff for specific path
argocd app diff myapp --path k8s/deployment.yaml
Sync history and rollback:
# List sync history
argocd app history myapp
# Rollback to a specific revision
argocd app rollback myapp 3
# Get application info with history
argocd app get myapp --history
Rollout status commands:
# Get rollout status
kubectl rollouts status myapp
# Watch rollout progress
kubectl rollouts status myapp --watch
# Get detailed rollout info
kubectl rollout status deployment/myapp
# List all rollouts
kubectl rollouts list rollouts
# List rollouts with specific label
kubectl rollouts list rollouts -l app=myapp
Rollout history and promotion:
# View rollout history
kubectl rollouts history myapp
# View specific revision details
kubectl rollouts history myapp --revision 3
# Promote rollout (skip analysis)
kubectl rollouts promote myapp
# Abort rollout
kubectl rollouts abort myapp
# Restart rollout
kubectl rollouts restart myapp
Canary-specific commands:
# Get canary status
kubectl get rollout myapp -o yaml | grep -A 10 "canary"
# View canary steps
kubectl rollout status myapp
# Set canary weight manually
kubectl annotate rollout myapp argo-rollouts.argoproj.io/step-index=2
# Pause rollout at specific step
kubectl annotate rollout myapp argo-rollouts.argoproj.io/pause=
# Resume paused rollout
kubectl annotate rollout myapp argo-rollouts.argoproj.io/pause-
Deployment Failures
Performance Issues
Configuration Errors
Integration Problems
Use this skill when:
Assess Requirements — Understand the use case, scale, integration needs, and existing infrastructure. Checkpoint: Document requirements, constraints, and success criteria.
Design Architecture — Plan component interactions, data flow, and deployment strategy using cloud-native best practices. Checkpoint: Verify the architecture addresses all requirements and follows CNCF conventions.
Implement & Configure — Create manifests, configurations, and deployment scripts. Include resource limits, health checks, and observability hooks. Checkpoint: Validate all YAML against schema and test in a staging environment.
Deploy & Monitor — Apply manifests to the cluster, verify component health, and confirm observability is working. Checkpoint: Confirm all pods/services are running, probes passing, and metrics/alerts configured.