Argo CD安装之客户端使用

安装argocd

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

暴露argocd ui

kubectl patch service -n argocd argocd-server -p '{"spec": {"type": "NodePort"}}'

获取admin登陆密码

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

cli端安装

https://github.com/argoproj/argo-cd/releases/download/v2.2.5/argocd-linux-amd64
mv argocd-linux-amd64 /usr/local/bin/argocd

cli端操作 登陆 argocd login ArgoCD_Address:Port

argocd login 192.168.8.68:30004

在这里插入图片描述

  • .从git仓库创建一个Application
  • 创建一个test-guesT app,指定仓库地址、应用路径、目标apiserver地址、目标namespace
argocd app create test-guest --repo http://git.rapha.top/jbjb/argo-cd.git --path test00 --dest-server https://kubernetes.default.svc --dest-namespace default
  • 列出所有app和指定app
argocd app list
argocd app get test-guest

在这里插入图片描述
在这里插入图片描述

  • 手动从git仓库同步指定app
argocd app sync test-guest

在这里插入图片描述
登录UI
在这里插入图片描述

在这里插入图片描述

删除

argocd app delete test-guest
注意!!!删除的话pod也跟着删除

更多指令

https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_app/

添加默认一个repo解决需要用户密码登录的git仓库

argocd repo add http://git.rapha.top/jbjb/test01.git --username admin  --password 123456

再添加需要发布的项目像之前一样

argocd app create test01  --repo http://git.rapha.top/jbjb/test01.git  --path test --dest-server https://kubernetes.default.svc --dest-namespace default

查看

[root@gitlan ~]# argocd repo list
TYPE  NAME  REPO                                  INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git         http://git.rapha.top/jbjb/test01.git  false     false  false  true   Successful

手动同步

#查看app
[root@gitlan ~]# argocd app list
NAME    CLUSTER                         NAMESPACE  PROJECT  STATUS     HEALTH   SYNCPOLICY  CONDITIONS  REPO                                  PATH  TARGET
test01  https://kubernetes.default.svc  default    default  OutOfSync  Missing  <none>      <none>      http://git.rapha.top/jbjb/test01.git  test

[root@gitlan ~]# argocd app sync test01
TIMESTAMP                  GROUP        KIND   NAMESPACE                  NAME    STATUS    HEALTH        HOOK  MESSAGE
2022-02-13T02:34:21+08:00            Service     default              nginx-v1  OutOfSync  Missing
2022-02-13T02:34:21+08:00   apps  Deployment     default              nginx-v1  OutOfSync  Missing
2022-02-13T02:34:21+08:00            Service     default              nginx-v1  OutOfSync  Missing              service/nginx-v1 created
2022-02-13T02:34:21+08:00   apps  Deployment     default              nginx-v1  OutOfSync  Missing              deployment.apps/nginx-v1 created2022-02-13T02:34:21+08:00            Service     default              nginx-v1    Synced  Healthy                  service/nginx-v1 created
2022-02-13T02:34:21+08:00   apps  Deployment     default              nginx-v1    Synced  Progressing              deployment.apps/nginx-v1 created

Name:               test01
Project:            default
Server:             https://kubernetes.default.svc
Namespace:          default
URL:                https://192.168.8.68:30004/applications/test01
Repo:               http://git.rapha.top/jbjb/test01.git
Target:
Path:               test
SyncWindow:         Sync Allowed
Sync Policy:        <none>
Sync Status:        Synced to  (898fa24)
Health Status:      Progressing

Operation:          Sync
Sync Revision:      898fa24a27981fb23a5f6e154fed9796e1d7937e
Phase:              Succeeded
Start:              2022-02-13 02:34:21 +0800 CST
Finished:           2022-02-13 02:34:21 +0800 CST
Duration:           0s
Message:            successfully synced (all tasks run)

GROUP  KIND        NAMESPACE  NAME      STATUS  HEALTH       HOOK  MESSAGE
       Service     default    nginx-v1  Synced  Healthy            service/nginx-v1 created
apps   Deployment  default    nginx-v1  Synced  Progressing        deployment.apps/nginx-v1 created

删除一个repo源

[root@gitlan ~]# argocd repo list
TYPE  NAME  REPO                                 INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git         http://git.rapha.top/jbjb/rook-ceph  false     false  false  true   Successful

[root@gitlan ~]# argocd repo rm http://git.rapha.top/jbjb/rook-ceph
Repository 'http://git.rapha.top/jbjb/rook-ceph' removed
[root@gitlan ~]# argocd repo list
TYPE  NAME  REPO  INSECURE  OCI  LFS  CREDS  STATUS  MESSAGE  PROJECT

更多命令参考链接: 点击官网连接.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值