蛮子哥 蛮子哥
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)

蛮子哥

业精于勤,荒于嬉
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)
  • ansible系列文章

  • Kubernetes笔记

  • elk

  • jenkins

  • GitLabCI_CD

  • AI编程

  • 提示词

  • ArgoCD

    • argocd部署
    • argocd+gitlab应用自动发布
    • ArgoCD仓库管理
    • ArgoCD集群管理
      • 获取目标集群 kubeconfig
      • 使用 ArgoCD CLI 添加集群
      • 查看集群状态信息
      • 列出集群
      • 查看集群详情
      • 更新集群配置
      • 删除集群
    • ArgoCD项目管理
    • ArgoCD监控
  • 专题
  • ArgoCD
蛮子哥
2024-05-18
目录

ArgoCD集群管理

# 功能介绍

ArgoCD 不仅能管理所在的 k8s 集群,还可以通过添加远程集群Kubeconfig/Token的方式实现管理多个集群,从而实现跨集群的应用部署和 GitOps 自动化。

# 添加集群

假设现在有两套集群,已经在k8s集群部署了gitlab和Argocd,现在需要添加k8s-test集群。

# 获取目标集群 kubeconfig

[root@k8s-test ~]# kubectl config view --minify --flatten > test.conf
1

# 使用 ArgoCD CLI 添加集群

查看 context 信息,更多 context 操作可参考文档:https://www.cuiliangblog.cn/detail/section/175557663

# kubectl config get-contexts --kubeconfig /etc/kubernetes/test.conf
CURRENT   NAME                          CLUSTER      AUTHINFO           NAMESPACE
*         kubernetes-admin@kubernetes   kubernetes   kubernetes-admin
1
2
3

ArgoCD添加集群

# argocd cluster add kubernetes-admin@kubernetes \
  --kubeconfig /etc/kubernetes/test.conf \
  --name k8s-test
WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `kubernetes-admin@kubernetes` with full cluster level privileges. Do you want to continue [y/N]? y
{"level":"info","msg":"ServiceAccount \"argocd-manager\" created in namespace \"kube-system\"","time":"2025-10-23T00:20:21+08:00"}
{"level":"info","msg":"ClusterRole \"argocd-manager-role\" created","time":"2025-10-23T00:20:21+08:00"}
{"level":"info","msg":"ClusterRoleBinding \"argocd-manager-role-binding\" created","time":"2025-10-23T00:20:21+08:00"}
{"level":"info","msg":"Created bearer token secret \"argocd-manager-long-lived-token\" for ServiceAccount \"argocd-manager\"","time":"2025-10-23T00:20:21+08:00"}
{"level":"warning","msg":"Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.","time":"2025-10-23T00:20:22+08:00"}
Cluster 'https://192.168.10.15:6443' added
1
2
3
4
5
6
7
8
9
10

# 查看集群状态信息

image-20260518135208423

# CLI 管理集群

# 列出集群

# 列出所有集群
argocd cluster list

# 使用 grpc-web(如果有连接问题)
argocd cluster list --grpc-web

# 输出格式化
argocd cluster list -o json
argocd cluster list -o yaml
argocd cluster list -o wide
1
2
3
4
5
6
7
8
9
10

# 查看集群详情

# 查看特定集群信息
argocd cluster get <CLUSTER_URL>

# 例如
argocd cluster get https://192.168.10.15:6443
argocd cluster get https://kubernetes.default.svc  # 本地集群
1
2
3
4
5
6

# 更新集群配置

# 更新集群名称
argocd cluster set <CLUSTER_URL> --name new-name

# 更新集群的 namespaces
argocd cluster set <CLUSTER_URL> --namespace ns1,ns2,ns3

# 设置集群为默认集群
argocd cluster set <CLUSTER_URL> --name in-cluster

# 更新 shard(用于集群分片)
argocd cluster set <CLUSTER_URL> --shard 1
1
2
3
4
5
6
7
8
9
10
11

# 删除集群

# 删除集群
argocd cluster rm <CLUSTER_URL>

# 例如
argocd cluster rm https://192.168.10.15:6443

# 强制删除(即使有应用在使用)
argocd cluster rm <CLUSTER_URL> --cascade
1
2
3
4
5
6
7
8

原文链接 (opens new window)

微信 支付宝
上次更新: 2026/05/18, 14:03:08

← ArgoCD仓库管理 ArgoCD项目管理→

最近更新
01
kubernetes证书续签到100年
05-04
02
istio入门
04-29
03
ES故障排查命令
04-29
更多文章>
Theme by Vdoing | Copyright © 2019-2026 | 点击查看十年之约 | 鄂ICP备2024072800号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式