跳到正文
Skillpedia
部署与云(DevOps)48k · #4755

gitops-workflow

它能做什么

这个技能可以帮你搭建一套名为 GitOps 的系统,用来管理 Kubernetes 环境中的软件部署。它以 Git 作为主要的可信来源,自动完成应用的更新流程。

适用场景

  • ✓第一次在 Kubernetes 集群中搭建 GitOps 时。
  • ✓当你希望从 Git 仓库自动部署新版本应用时。
  • ✓当你需要分阶段或逐步更新应用时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gitops-workflow/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gitops-workflow/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“帮我用 ArgoCD 为 Kubernetes 集群搭建 GitOps,并让应用从 GitHub 仓库“my-repo”自动部署。”

每周 5 个新技能,1 分钟读完。

工作原理

系统会监控保存应用配置的 Git 仓库。当你更新 Git 时,系统会检测到变化,并自动把更新应用到你的 Kubernetes 集群中。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

GitOps Workflow

Complete guide to implementing GitOps workflows with ArgoCD and Flux for automated Kubernetes deployments.

Purpose

Implement declarative, Git-based continuous delivery for Kubernetes using ArgoCD or Flux CD, following OpenGitOps principles.

Use this skill when

  • Set up GitOps for Kubernetes clusters
  • Automate application deployments from Git
  • Implement progressive delivery strategies
  • Manage multi-cluster deployments
  • Configure automated sync policies
  • Set up secret management in GitOps

Do not use this skill when

  • You need a one-off manual deployment
  • You cannot manage cluster access or repo permissions
  • You are not deploying to Kubernetes

Instructions

  1. Define repo layout and desired-state conventions.
  2. Install ArgoCD or Flux and connect clusters.
  3. Configure sync policies, environments, and promotion flow.
  4. Validate rollbacks and secret handling.

Safety

  • Avoid auto-sync to production without approvals.
  • Keep secrets out of Git and use sealed or external secret managers.

OpenGitOps Principles

  1. Declarative - Entire system described declaratively
  2. Versioned and Immutable - Desired state stored in Git
  3. Pulled Automatically - Software agents pull desired state
  4. Continuously Reconciled - Agents reconcile actual vs desired state

ArgoCD Setup

1. Installation

# Create namespace
kubectl create namespace argocd

# Install ArgoCD
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# Get admin password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

Reference: See references/argocd-setup.md for detailed setup

2. Repository Structure

gitops-repo/
├── apps/
│   ├── production/
│   │   ├── app1/
│   │   │   ├── kustomization.yaml
│   │   │   └── deployment.yaml
│   │   └── app2/
│   └── staging/
├── infrastructure/
│   ├── ingress-nginx/
│   ├── cert-manager/
│   └── monitoring/
└── argocd/
    ├── applications/
    └── projects/

3. Create Application

# argocd/applications/my-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/org/gitops-repo
    targetRevision: main
    path: apps/production/my-app
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
    - CreateNamespace=true

4. App of Apps Pattern

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: applications
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/org/gitops-repo
    targetRevision: main
    path: argocd/applications
  destination:
    server: https://kubernetes.default.svc
    namespace: argocd
  syncPolicy:
    automated: {}

Flux CD Setup

1. Installation

# Install Flux CLI
brew install fluxcd/tap/flux

# Alternative: download the official installer, inspect it, then execute it
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSLo "$tmpdir/flux-install.sh" https://fluxcd.io/install.sh
cat "$tmpdir/flux-install.sh"  # review the full installer before sudo
sudo bash "$tmpdir/flux-install.sh"

# Bootstrap Flux
flux bootstrap github \
  --owner=org \
  --repository=gitops-repo \
  --branch=main \
  --path=clusters/production \
  --personal

2. Create GitRepository

apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: my-app
  namespace: flux-system
spec:
  interval: 1m
  url: https://github.com/org/my-app
  ref:
    branch: main

3. Create Kustomization

apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: my-app
  namespace: flux-system
spec:
  interval: 5m
  path: ./deploy
  prune: true
  sourceRef:
    kind: GitRepository
    name: my-app

Sync Policies

Auto-Sync Configuration

ArgoCD:

syncPolicy:
  automated:
    prune: true      # Delete resources not in Git
    selfHeal: true   # Reconcile manual changes
    allowEmpty: false
  retry:
    limit: 5
    backoff:
      duration: 5s
      factor: 2
      maxDuration: 3m

Flux:

spec:
  interval: 1m
  prune: true
  wait: true
  timeout: 5m

Reference: See references/sync-policies.md

…

常见问题

什么是 GitOps?

GitOps 是一种借助 Git 来管理基础设施和应用的方式。所有内容都以声明式文件的形式描述并存放在 Git 中,环境中的一个代理程序会自动应用这些配置。

ArgoCD 和 Flux 是什么?

ArgoCD 和 Flux 是两款热门工具,可以帮助你实现 GitOps。它们会监控 Git 仓库,并确保环境(例如 Kubernetes)与 Git 中定义的内容保持一致。

如何用 GitOps 管理机密信息(密码、密钥)?

关键是不要把机密信息直接放进 Git。通常会使用 “External Secrets” 或 “Sealed Secrets” 等工具对机密信息进行加密,或在主仓库之外安全地管理它们。

详情

作者的原始描述

Complete guide to implementing GitOps workflows with ArgoCD and Flux for automated Kubernetes deployments.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4755
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能