Argo CD 是一个开源的持续交付工具,用于在 Kubernetes 集群中实现 CI/CD,它可以帮助开发人员自动化应用程序的构建、测试和部署过程,从而提高生产力,Argo CD 支持多种源代码管理工具,如 Git、GitHub、GitLab 等,以及多种持续集成/持续部署(CI/CD)平台,如 Jenkins、Travis CI、CircleCI 等,Argo CD 使用 Helm 作为包管理器,可以轻松地将应用程序打包并部署到 Kubernetes 集群中。
1、安装 Helm
需要在计算机上安装 Helm,Helm 是 Kubernetes 的一个包管理器,用于管理 Kubernetes 应用程序的依赖关系,可以通过以下命令安装 Helm:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
2、添加 Argo CD 仓库
接下来,需要添加 Argo CD 仓库,以便从中获取 Argo CD 的 Helm chart,可以通过以下命令添加仓库:
helm repo add argocd https://argoproj.github.io/argo-cd helm repo update
3、安装 Argo CD
通过以下命令安装 Argo CD:
helm install my-argocd argocd/argo-cd --version v0.7.0 --create-namespace --namespace argocd --set git.url=https://github.com/my-repo.git,git.branch=main,git.path=charts/my-app,redisPassword=mypassword --set ingress.enabled=true --set ingress.host=myapp.mydomain.com --set ingress.tlsSecretName=my-tls-secret
my-argocd
是 Argo CD 的实例名称,v0.7.0
是 Argo CD 的版本号,--create-namespace
和 --namespace argocd
分别表示创建一个新的命名空间和设置 Argo CD 实例所在的命名空间为 argocd
,其他参数用于配置 Argo CD。
1、初始化项目
在 Git 仓库中运行以下命令,初始化 Argo CD:
make init
2、将项目推送到 Git 仓库
将项目推送到 Git 仓库:
make push-prod || make push-dev || exit 1
根据需要选择推送到生产环境或开发环境,推送成功后,Argo CD 将自动从 Git 仓库拉取代码并部署到 Kubernetes 集群中。
3、更新应用程序
如果需要更新应用程序,可以在 Git 仓库中修改代码并重新推送:
git add . && git commit -m "Update application" && git push origin main || git push origin dev && exit 1
再次运行 make push-prod
或 make push-dev
,Argo CD 将自动更新应用程序并部署到 Kubernetes 集群中。
1、如何删除 Argo CD?
要删除 Argo CD,可以先停止 Argo CD 服务,然后删除 Argo CD Helm chart:
kubectl delete pods --all -n argocd --field-selector status.phase=Pending --timeout=5m || true Wait for all pods to be deleted (including the pending ones) before deleting the namespace and resources created by Argo CD. This is necessary because Argo CD uses a ServiceAccount to manage its resources and if the ServiceAccount is not deleted, the resources will remain in the namespace and cause conflicts when you try to delete the namespace or other resources. After deleting the ServiceAccount and all its associated resources, delete the namespace: kubectl delete namespace argocd; helm uninstall my-argocd; kubectl delete crd myapps.argoproj.io; kubectl delete secret my-tls-secret; kubectl delete configmap my-argocd-cm; kubectl delete clusterrolebinding my-argocd-admin-binding; kubectl delete clusterrole my-argocd-admin-role; kubectl delete serviceaccount default && kubectl delete role default && kubectl delete deployment default && kubectl delete pvc default && kubectl delete statefulset default && kubectl delete persistentvolumeclaim default; helm repo remove argocd; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helmrepo update && kubectl get pods --all -n argocd --field-selector status.phase=Pending --timeout=5m || true Wait for all pods to be deleted (including the pending ones) before deleting the namespace and resources created by Argo CD. This is necessary because Argo CD uses a ServiceAccount to manage its resources and if the ServiceAccount is not deleted, the resources will remain in the namespace and cause conflicts when you try to delete the namespace or other resources. After deleting the ServiceAccount and all its associated resources, delete the namespace: kubectl delete namespace argocd; helm uninstall my-argocd; kubectl delete crd myapps.argoproj.io; kubectl delete secret my-tls-secret; kubectl delete configmap my-argocd-cm; kubectl delete clusterrolebinding my-argocd-admin-binding; kubectl delete clusterrole my-argocd-admin-role; kubectl delete serviceaccount default && kubectl delete role default && kubectl delete deployment default && kubectl delete pvc default && kubectl delete statefulset default && kubectl delete persistentvolumeclaim default; helm repo remove argocd; helm search repo | grep '^argocd+' | xargs helm repo remove; helm search repo | grep '^argocd+' | xargs helmrepo update && kubectl get pods --all -n argocd --field-selector status.phase=Pending --timeout=5m || true Wait for all pods to be deleted (including the pending ones) before deleting the namespace and resources created by Argo CD. This is necessary because Argo CD uses a ServiceAccount to manage its resources and if the ServiceAccount is not deleted, the resources will remain in the namespace and cause conflicts when you try to delete the namespace or other resources. After deleting the ServiceAccount and all its associated resources, delete the namespace: kubectl delete namespace argocd; kubectl get pods --all -n argocd --field-selector status.
网页标题:arccloud
网站地址:http://www.shufengxianlan.com/qtweb/news38/391838.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联
猜你还喜欢下面的内容