Argo CD实践-创建App

创建App

Application是由清单定义的一组 Kubernetes 资源

A group of Kubernetes resources as defined by a manifest. This is a Custom Resource Definition (CRD).

手顺

前提:有一个可用的Kubernetes集群。

实验环境:

访问Argo server的方式有两种:

1.登录argo cd

本次使用argocd 客户端工具

kubectl port-forward svc/argocd-server -n argocd 8080:443
$argocd login localhost:8080

2.添加私有git

argocd repo add https://github.com/argoproj/argocd-example-apps.git --username  --password 

3.从 Git 存储库创建app

  1. 需要将当前命名空间设置为argocd
kubectl config set-context --current --namespace=argocd
  1. 通过CLI创建App
argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default

参数说明:

--repo: 指定 Git 仓库
 --path:指定部署文件在 Git 仓库中的相对路径
 --dest-server: 集群的访问地址
 --dest-namespace:部署到哪个命名空间

仓库为空时,会出现以下错误,必须先提交代码,才能创建app

FATA[0005] rpc error: code = InvalidArgument desc = application spec for test-daoservice is invalid: InvalidSpecError: Unable to generate manifests in build-config/test/eks: rpc error: code = Unknown desc = build-config/test/eks: app path does not exist

  1. test

4.同步Application

$ argocd app get guestbook
Name:               guestbook
Server:             https://kubernetes.default.svc
Namespace:          default
URL:                https://10.97.164.88/applications/guestbook
Repo:               https://github.com/argoproj/argocd-example-apps.git
Target:
Path:               guestbook
Sync Policy:        
Sync Status:        OutOfSync from  (1ff8a67)
Health Status:      Missing

GROUP  KIND        NAMESPACE  NAME          STATUS     HEALTH
apps   Deployment  default    guestbook-ui  OutOfSync  Missing
       Service     default    guestbook-ui  OutOfSync  Missing
  1. 手动同步
argocd app sync guestbook
  1. 通过设置策略自动同步

默认每3分钟自动同步

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

argocd app set guestbook --sync-policy automated

同步后,就会部署到k8s

  1. 通过用户界面同步

参考


注意

删除path中资源文件后,argocd默认情况不删除相应的资源

--path guestbook

可通过以下命令设置自动删除

argocd app set guestbook --auto-prune

下一次同步时,删除K8s资源

展开阅读全文

页面更新:2024-04-26

标签:中资   集群   应用程序   仓库   客户端   命令   状态   工具   资源   空间

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top