新聞中心
argo云原生簡(jiǎn)介
Argo CD 是一個(gè)開(kāi)源的持續(xù)交付工具,用于在 Kubernetes 集群中實(shí)現(xiàn) CI/CD,它可以幫助開(kāi)發(fā)人員自動(dòng)化應(yīng)用程序的構(gòu)建、測(cè)試和部署過(guò)程,從而提高生產(chǎn)力,Argo CD 支持多種源代碼管理工具,如 Git、GitHub、GitLab 等,以及多種持續(xù)集成/持續(xù)部署(CI/CD)平臺(tái),如 Jenkins、Travis CI、CircleCI 等,Argo CD 使用 Helm 作為包管理器,可以輕松地將應(yīng)用程序打包并部署到 Kubernetes 集群中。

安裝與配置 Argo CD
1、安裝 Helm
需要在計(jì)算機(jī)上安裝 Helm,Helm 是 Kubernetes 的一個(gè)包管理器,用于管理 Kubernetes 應(yīng)用程序的依賴(lài)關(guān)系,可以通過(guò)以下命令安裝 Helm:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
2、添加 Argo CD 倉(cāng)庫(kù)
接下來(lái),需要添加 Argo CD 倉(cāng)庫(kù),以便從中獲取 Argo CD 的 Helm chart,可以通過(guò)以下命令添加倉(cāng)庫(kù):
helm repo add argocd https://argoproj.github.io/argo-cd helm repo update
3、安裝 Argo CD
通過(guò)以下命令安裝 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 的實(shí)例名稱(chēng),v0.7.0 是 Argo CD 的版本號(hào),--create-namespace 和 --namespace argocd 分別表示創(chuàng)建一個(gè)新的命名空間和設(shè)置 Argo CD 實(shí)例所在的命名空間為 argocd,其他參數(shù)用于配置 Argo CD。
使用 Argo CD
1、初始化項(xiàng)目
在 Git 倉(cāng)庫(kù)中運(yùn)行以下命令,初始化 Argo CD:
make init
2、將項(xiàng)目推送到 Git 倉(cāng)庫(kù)
將項(xiàng)目推送到 Git 倉(cāng)庫(kù):
make push-prod || make push-dev || exit 1
根據(jù)需要選擇推送到生產(chǎn)環(huán)境或開(kāi)發(fā)環(huán)境,推送成功后,Argo CD 將自動(dòng)從 Git 倉(cāng)庫(kù)拉取代碼并部署到 Kubernetes 集群中。
3、更新應(yīng)用程序
如果需要更新應(yīng)用程序,可以在 Git 倉(cāng)庫(kù)中修改代碼并重新推送:
git add . && git commit -m "Update application" && git push origin main || git push origin dev && exit 1
再次運(yùn)行 make push-prod 或 make push-dev,Argo CD 將自動(dòng)更新應(yīng)用程序并部署到 Kubernetes 集群中。
相關(guān)問(wèn)題與解答
1、如何刪除 Argo CD?
要?jiǎng)h除 Argo CD,可以先停止 Argo CD 服務(wù),然后刪除 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
文章轉(zhuǎn)載:http://m.5511xx.com/article/cdjijse.html


咨詢
建站咨詢
