argocd部署cli工具并添加k8s集群

先决条件:
1.已经有k8s集群,(网上一万种部署方式,这里我使用的是kubekey部署的),也埋了个坑,后面说明.
2.已经部署好argocd,并验证web已经可以访问.参见k8s部署argocd-CSDN博客
部署客户端工具,

这里我是从web页面上直接下载的对应版本的cli工具.

打开已经部署好的argocd的web页面,点击doc,

下载linux(AMD64),这里其实就是从已经部署好的server端下载的argocdcli工具.版本直接是匹配的.

如果不想从这里下载可以从github上下载,地址如下:https://github.com/argoproj/argo-cd/releases/tag/v2.4.2

这里选择下载的二进制包如下,

将下载好的包上传到服务器这里(具体操作步骤省略)

这里我直接上传到了/usr/local/bin/

添加可执行权限
Go 复制代码
[root@module /usr/local/bin]$chmod +x argocd-linux-amd64
重命名(方便后面使用)
Go 复制代码
[root@module /usr/local/bin]$mv argocd-linux-amd64  argocd
查看基本信息
Go 复制代码
[root@module /usr/local/bin]$argocd version
argocd: v2.4.2+c6d0c8b
  BuildDate: 2022-06-21T20:42:05Z
  GitCommit: c6d0c8baaa291cd68465acd7ad6bef58b2b6f942
  GitTreeState: clean
  GoVersion: go1.18.3
  Compiler: gc
  Platform: linux/amd64
WARN[0000] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
argocd-server: v2.4.2+c6d0c8b
  BuildDate: 2022-06-21T20:42:05Z
  GitCommit: c6d0c8baaa291cd68465acd7ad6bef58b2b6f942
  GitTreeState: clean
  GoVersion: go1.18.3
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: v4.4.1 2021-11-11T23:36:27Z
  Helm Version: v3.8.1+g5cb9af4
  Kubectl Version: v0.23.1
  Jsonnet Version: v0.18.0

这里表示已经将cli工具部署成功.接下来就是添加k8s集群.

添加k8s集群

说明一下:

这里我因为使用的是kubekey创建的k8s集群,所以在k8s的config文件中的地址无法在argocd中解析出来.导致无法添加成功,将

Go 复制代码
将/root/.kube/config文件中的server字段修改成master主机的ip地址就可以.

因为个人的环境有所差异,所以这里不做过多解释.


使用cli工具添加k8s集群.
查看集群context的name,
Go 复制代码
[root@module ~/.kube]$kubectl config get-contexts -o name
kubernetes-admin@cluster.local
#这里的集群名称是
kubernetes-admin@cluster.local
使用cli工具添加集群到argocd中
添加集群到 Argo CD(使用 gRPC Web 模式,也可以不用这个非必选项)
Go 复制代码
#添加k8s集群到argocd

[root@module ~/.kube]$argocd cluster add kubernetes-admin@cluster.local --kubeconfig ~/.kube/config --grpc-web
WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `kubernetes-admin@cluster.local` with full cluster level privileges. Do you want to continue [y/N]? y
INFO[0003] ServiceAccount "argocd-manager" already exists in namespace "kube-system"
INFO[0003] ClusterRole "argocd-manager-role" updated
INFO[0003] ClusterRoleBinding "argocd-manager-role-binding" updated
Cluster 'https://192.168.59.100:6443' added
查看添加集群结果
Go 复制代码
[root@module ~/.kube]$argocd cluster list
WARN[0000] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
SERVER                          NAME                            VERSION  STATUS   MESSAGE                                                  PROJECT
https://192.168.59.100:6443     kubernetes-admin@cluster.local           Unknown  Cluster has no applications and is not being monitored.
https://kubernetes.default.svc  in-cluster                               Unknown  Cluster has no applications and is not being monitored
登陆web页面查看结果

settings-->cluster

验证完成,添加成功

相关推荐
运维栈记1 天前
如何排错运行在Kubernetes集群中的服务?
云原生·容器·kubernetes
海鸥811 天前
in argocd ‘/tmp/_argocd-repo/../.git/index.lock‘: No space left on
git·argocd
Linux编程用C1 天前
Docker+Vscode搭建(本地/远程)开发环境
vscode·后端·docker
林疏safe1 天前
灯塔部署云服务器docker 部署方式,以及忘记密码如何查找
运维·服务器·docker
木卫二号Coding1 天前
affine+docker+postgresql+备份数据库
数据库·docker·容器
檀越剑指大厂1 天前
查看 Docker 镜像详情的几种常用方法
docker·容器·eureka
java_logo1 天前
Webtop Docker 容器化部署指南:基于浏览器的Linux桌面环境
linux·docker·容器·webtop·webtop部署教程·docker部署webtop·linux桌面
技术小李...1 天前
docker下mysql更改密码后WordPress提示无法连接数据库问题
运维·docker·容器
JPX-NO1 天前
windows下编程IDE使用docker搭建的rust开发环境(Linux)
ide·windows·docker·rust
快乐就去敲代码@!1 天前
Boot Cache Star ⭐(高性能两级缓存系统)
spring boot·redis·后端·缓存·docker·压力测试