Application是由清单定义的一组 Kubernetes 资源
A group of Kubernetes resources as defined by a manifest. This is a Custom Resource Definition (CRD).
前提:有一个可用的Kubernetes集群。
实验环境:
访问Argo server的方式有两种:
本次使用argocd 客户端工具
kubectl port-forward svc/argocd-server -n argocd 8080:443
$argocd login localhost:8080
argocd repo add https://github.com/argoproj/argocd-example-apps.git --username --password
kubectl config set-context --current --namespace=argocd
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
$ 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
argocd app sync guestbook
默认每3分钟自动同步
https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/
argocd app set guestbook --sync-policy automated
同步后,就会部署到k8s
删除path中资源文件后,argocd默认情况不删除相应的资源
--path guestbook
可通过以下命令设置自动删除
argocd app set guestbook --auto-prune
下一次同步时,删除K8s资源
页面更新:2024-04-26
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号