k8s-gitops

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Kubernetes GitOps

Kubernetes GitOps

GitOps workflows using Flux and ArgoCD with kubectl-mcp-server tools.
借助kubectl-mcp-server工具,使用Flux和ArgoCD实现GitOps工作流。

When to Apply

适用场景

Use this skill when:
  • User mentions: "Flux", "ArgoCD", "GitOps", "sync", "reconcile"
  • Operations: checking sync status, triggering reconciliation, drift detection
  • Keywords: "out of sync", "deploy from git", "continuous delivery"
在以下场景中使用本技能:
  • 用户提及:"Flux"、"ArgoCD"、"GitOps"、"sync(同步)"、"reconcile(调和)"
  • 操作需求:查看同步状态、触发调和、漂移检测
  • 关键词:"out of sync(不同步)"、"deploy from git(从Git部署)"、"continuous delivery(持续交付)"

Priority Rules

优先级规则

PriorityRuleImpactTools
1Check source readiness before troubleshootingCRITICAL
flux_sources_list_tool
2Verify sync status before deploymentsHIGH
argocd_app_get_tool
3Reconcile after git changesMEDIUM
flux_reconcile_tool
4Suspend before manual changesLOW
flux_suspend_tool
优先级规则影响级别工具
1排查问题前先检查源就绪状态关键
flux_sources_list_tool
2部署前验证同步状态
argocd_app_get_tool
3Git变更后执行调和
flux_reconcile_tool
4手动变更前先暂停
flux_suspend_tool

Quick Reference

快速参考

TaskToolExample
List Flux kustomizations
flux_kustomizations_list_tool
flux_kustomizations_list_tool(namespace)
Reconcile Flux
flux_reconcile_tool
flux_reconcile_tool(kind, name, namespace)
List ArgoCD apps
argocd_apps_list_tool
argocd_apps_list_tool(namespace)
Sync ArgoCD
argocd_sync_tool
argocd_sync_tool(name, namespace)
任务工具示例
列出Flux的kustomizations
flux_kustomizations_list_tool
flux_kustomizations_list_tool(namespace)
执行Flux调和
flux_reconcile_tool
flux_reconcile_tool(kind, name, namespace)
列出ArgoCD应用
argocd_apps_list_tool
argocd_apps_list_tool(namespace)
同步ArgoCD应用
argocd_sync_tool
argocd_sync_tool(name, namespace)

Flux CD

Flux CD

Check Flux Status

检查Flux状态

python
flux_kustomizations_list_tool(namespace="flux-system")
flux_helmreleases_list_tool(namespace)
flux_sources_list_tool(namespace="flux-system")
python
flux_kustomizations_list_tool(namespace="flux-system")
flux_helmreleases_list_tool(namespace)
flux_sources_list_tool(namespace="flux-system")

Reconcile Resources

调和资源

python
flux_reconcile_tool(
    kind="kustomization",
    name="my-app",
    namespace="flux-system"
)

flux_reconcile_tool(
    kind="helmrelease",
    name="my-chart",
    namespace="default"
)
python
flux_reconcile_tool(
    kind="kustomization",
    name="my-app",
    namespace="flux-system"
)

flux_reconcile_tool(
    kind="helmrelease",
    name="my-chart",
    namespace="default"
)

Suspend/Resume

暂停/恢复

python
flux_suspend_tool(kind="kustomization", name="my-app", namespace="flux-system")

flux_resume_tool(kind="kustomization", name="my-app", namespace="flux-system")
See FLUX.md for detailed Flux workflows.
python
flux_suspend_tool(kind="kustomization", name="my-app", namespace="flux-system")

flux_resume_tool(kind="kustomization", name="my-app", namespace="flux-system")
查看FLUX.md获取Flux工作流的详细说明。

ArgoCD

ArgoCD

List Applications

列出应用

python
argocd_apps_list_tool(namespace="argocd")
python
argocd_apps_list_tool(namespace="argocd")

Get App Status

获取应用状态

python
argocd_app_get_tool(name="my-app", namespace="argocd")
python
argocd_app_get_tool(name="my-app", namespace="argocd")

Sync Application

同步应用

python
argocd_sync_tool(name="my-app", namespace="argocd")
python
argocd_sync_tool(name="my-app", namespace="argocd")

Refresh App

刷新应用

python
argocd_refresh_tool(name="my-app", namespace="argocd")
See ARGOCD.md for detailed ArgoCD workflows.
python
argocd_refresh_tool(name="my-app", namespace="argocd")
查看ARGOCD.md获取ArgoCD工作流的详细说明。

GitOps Troubleshooting

GitOps问题排查

Flux Not Syncing

Flux无法同步

SymptomCheckResolution
Source not ready
flux_sources_list_tool()
Check git credentials
Kustomization failed
flux_kustomizations_list_tool()
Check manifest errors
HelmRelease failed
flux_helmreleases_list_tool()
Check values, chart version
症状检查操作解决方法
源未就绪
flux_sources_list_tool()
检查Git凭证
Kustomization执行失败
flux_kustomizations_list_tool()
检查清单文件错误
HelmRelease执行失败
flux_helmreleases_list_tool()
检查配置值、Chart版本

ArgoCD Out of Sync

ArgoCD不同步

SymptomCheckResolution
OutOfSync
argocd_app_get_tool()
Manual sync or check auto-sync
DegradedCheck health statusFix unhealthy resources
UnknownRefresh app
argocd_refresh_tool()
症状检查操作解决方法
不同步(OutOfSync)
argocd_app_get_tool()
手动同步或检查自动同步配置
状态降级(Degraded)检查健康状态修复不健康的资源
状态未知(Unknown)刷新应用
argocd_refresh_tool()

Environment Promotion

环境升级

With Flux Kustomizations

使用Flux Kustomizations

python
flux_reconcile_tool(kind="kustomization", name="staging", namespace="flux-system")

flux_reconcile_tool(kind="kustomization", name="production", namespace="flux-system")
python
flux_reconcile_tool(kind="kustomization", name="staging", namespace="flux-system")

flux_reconcile_tool(kind="kustomization", name="production", namespace="flux-system")

With ArgoCD

使用ArgoCD

python
argocd_sync_tool(name="app-staging", namespace="argocd")

argocd_app_get_tool(name="app-staging", namespace="argocd")

argocd_sync_tool(name="app-production", namespace="argocd")
python
argocd_sync_tool(name="app-staging", namespace="argocd")

argocd_app_get_tool(name="app-staging", namespace="argocd")

argocd_sync_tool(name="app-production", namespace="argocd")

Multi-Cluster GitOps

多集群GitOps

Manage GitOps across clusters:
python
flux_kustomizations_list_tool(namespace="flux-system", context="cluster-1")
flux_kustomizations_list_tool(namespace="flux-system", context="cluster-2")

flux_reconcile_tool(
    kind="kustomization",
    name="apps",
    namespace="flux-system",
    context="production-cluster"
)
跨集群管理GitOps:
python
flux_kustomizations_list_tool(namespace="flux-system", context="cluster-1")
flux_kustomizations_list_tool(namespace="flux-system", context="cluster-2")

flux_reconcile_tool(
    kind="kustomization",
    name="apps",
    namespace="flux-system",
    context="production-cluster"
)

Drift Detection

漂移检测

Compare live state with desired:
python
argocd_app_get_tool(name="my-app", namespace="argocd")

flux_kustomizations_list_tool(namespace="flux-system")
对比实际运行状态与期望状态:
python
argocd_app_get_tool(name="my-app", namespace="argocd")

flux_kustomizations_list_tool(namespace="flux-system")

Prerequisites

前置条件

  • Flux: Required for Flux tools
    bash
    flux install
  • ArgoCD: Required for ArgoCD tools
    bash
    kubectl create namespace argocd
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  • Flux:使用Flux工具前需安装
    bash
    flux install
  • ArgoCD:使用ArgoCD工具前需安装
    bash
    kubectl create namespace argocd
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Related Skills

相关技能

  • k8s-deploy - Standard deployments
  • k8s-helm - Helm chart management
  • k8s-deploy - 标准部署
  • k8s-helm - Helm Chart管理