mcpField
A
argocd-cluster-bootstrapping

argocd-cluster-bootstrapping

github.com/julianobarbosa云与 DevOps1468 次安装2 天前更新
代码仓库

关于 argocd-cluster-bootstrapping

argocd-cluster-bootstrapping 是用于将 Kubernetes 集群接入 ArgoCD 多仓库 GitOps 环境的技能,涵盖注册、标签、项目、ApplicationSet 和运维检查。

主要功能

  1. 01向 ArgoCD 注册集群
  2. 02集群密钥标签与模板
  3. 03设置 ArgoCD Project
  4. 04配置多源 ApplicationSet
  5. 05排查连接与同步问题

适用场景

  1. 01接入新建的集群
  2. 02将现有集群注册到中心集群
  3. 03为业务单元设置项目
  4. 04调查集群连接或同步故障

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/julianobarbosa/claude-code-skills --skill argocd-cluster-bootstrapping

安装后在 Claude Code 中输入/argocd-cluster-bootstrapping确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

ArgocdClusterBootstrapping/Workflows/
CreateRootApplication.md
DiagnoseSyncFailure.md
OnboardCluster.md
references/
architecture.md
guidance.md
project-structure.md
summary.md
tools.md
workflow.md
references/templates/
README.md
applicationset-cluster-generator.yaml
applicationset-matrix-generator.yaml
argocd-project.yaml
bootstrap-script.sh
cluster-secret.yaml
external-secret-store.yaml
values-base.yaml
values-dev.yaml
values-prd.yaml

详细介绍

ArgoCD 集群引导技能

在由 ArgoCD 管理的多仓库 GitOps 环境中引导新 Kubernetes 集群的完整指南。

何时使用此技能

  • 配置新的 AKS/EKS/GKE 集群并将其集成到 ArgoCD
  • 将现有集群注册到 ArgoCD 中枢
  • 创建带有正确标签的集群密钥,以用于 ApplicationSet 目标匹配
  • 为新的业务部门设置 ArgoCD 项目
  • 为新集群配置多源 ApplicationSet
  • 排查集群连接或同步问题
  • 了解多仓库 GitOps 架构

快速开始

1. 上线前检查清单
# Verify ArgoCD CLI is installed
argocd version --client

# Verify kubectl access to hub cluster
kubectl config use-context aks-cafehyna-default
kubectl get nodes

# Verify access to target cluster
kubectl config use-context <new-cluster-context>
kubectl get nodes
2. 注册集群(3 个步骤)
# Step 1: Add cluster to ArgoCD
argocd cluster add <cluster-context> --name <developer-friendly-name>

# Step 2: Create cluster secret with labels (GitOps)
# See templates/cluster-secret.yaml

# Step 3: Create ArgoCD Project (GitOps)
# See templates/argocd-project.yaml
3. 部署首个应用程序
# Sync the master ApplicationSet to pick up new cluster
argocd app sync applicationset-master --resource-filter kind=ApplicationSet

架构概览

┌─────────────────────────────────────────────────────────────────────┐
│                        HUB CLUSTER                                  │
│  ┌─────────────────────────────────────────────────────────────┐   │
│  │                    ArgoCD Server                             │   │
│  │  ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐│   │
│  │  │ApplicationSet│ │  Projects   │ │    Cluster Secrets     ││   │
│  │  │  Controller  │ │  (RBAC)     │ │  (Labels for targeting)││   │
│  │  └─────────────┘ └─────────────┘ └─────────────────────────┘│   │
│  └─────────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────────┘
         │                    │                    │
         ▼                    ▼                    ▼
┌─────────────┐      ┌─────────────┐      ┌─────────────┐
│ DEV Cluster │      │ HLG Cluster │      │ PRD Cluster │
│  (Spot OK)  │      │  (Staging)  │      │ (HA Config) │
└─────────────┘      └─────────────┘      └─────────────┘

仓库结构

infra-team/                          # Infrastructure repository
├── applicationset/                  # ApplicationSet definitions
│   ├── kube-addons/                # Add-on ApplicationSets
│   └── applications/               # Business app ApplicationSets
├── argocd-clusters/                # Cluster registration secrets
├── argocd-projects/                # Project definitions (RBAC)
└── applicationset-templates/       # Reusable templates

argo-cd-helm-values/                # Values repository (separate security)
└── kube-addons/
    └── <component>/
        └── <cluster-name>/
            └── values.yaml         # Per-cluster overrides

核心概念

命名约定(重要)
上下文开发者名称Azure AKS 名称
ArgoCDcafehyna-devaks-cafehyna-dev
密钥使用开发者名称-
标签使用开发者名称-
集群标签(必需)
labels:
  argocd.argoproj.io/secret-type: cluster
  environment: dev|hlg|prd|hub
  region: brazilsouth|eastus2
  cluster-name: <developer-friendly-name>
  node-type: spot|standard|mixed
  connection-type: internal|external
  tier: platform|application
环境特征
环境同步策略副本数节点类型修剪
dev自动1可使用 Spot是
hlg手动2混合是
prd手动3标准否

参考文档

常见任务

添加新的开发集群
# Use the bootstrap script
./scripts/bootstrap-cluster.sh \
  --name cafehyna-dev-02 \
  --environment dev \
  --region brazilsouth \
  --node-type spot
排查连接问题
# Check cluster health
argocd cluster get <cluster-name>

# Verify secret labels
kubectl get secret -n argocd -l argocd.argoproj.io/secret-type=cluster

# Test ApplicationSet targeting
argocd appset get <appset-name> --show-params

安全规则

  1. 切勿在受管理的集群上使用 kubectl apply - 所有变更都通过 Git 进行
  2. 提交前务必验证 - 运行 pre-commit run --all-files
  3. 先在 dev 中测试 - 经过 hlg 后再推广到 prd
  4. 保留现有标签 - 它们用于控制 ApplicationSet 的目标匹配
  5. 使用密钥存储凭据 - 切勿将凭据硬编码在 values 文件中

评论

支持 Markdown