arc cloud

argo云原生简介

Argo CD 是一个开源的持续交付工具,用于在 Kubernetes 集群中实现 CI/CD,它可以帮助开发人员自动化应用程序的构建、测试和部署过程,从而提高生产力,Argo CD 支持多种源代码管理工具,如 Git、GitHub、GitLab 等,以及多种持续集成/持续部署(CI/CD)平台,如 Jenkins、Travis CI、CircleCI 等,Argo CD 使用 Helm 作为包管理器,可以轻松地将应用程序打包并部署到 Kubernetes 集群中。

安装与配置 Argo CD

1、安装 Helm

arc cloud

需要在计算机上安装 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。

arc cloud

使用 Argo CD

1、初始化项目

在 Git 仓库中运行以下命令,初始化 Argo CD:

make init

2、将项目推送到 Git 仓库

将项目推送到 Git 仓库:

make push-prod || make push-dev || exit 1

根据需要选择推送到生产环境或开发环境,推送成功后,Argo CD 将自动从 Git 仓库拉取代码并部署到 Kubernetes 集群中。

3、更新应用程序

arc cloud

如果需要更新应用程序,可以在 Git 仓库中修改代码并重新推送:

git add . && git commit -m "Update application" && git push origin main || git push origin dev && exit 1

再次运行 make push-prodmake 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.

原创文章,作者:酷盾叔,如若转载,请注明出处:https://www.kdun.com/ask/114631.html

(0)
酷盾叔的头像酷盾叔订阅
上一篇 2023-12-25 09:42
下一篇 2023-12-25 09:45

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

云产品限时秒杀。精选云产品高防服务器,20M大带宽限量抢购  >>点击进入