本文介紹如何在GitOps系統中,通過ArgoCD CLI和ArgoCD控制台方式添加、查看及刪除Git源倉庫和Helm源倉庫。
前提條件
已登入GitOps系統。具體操作,請參見登入GitOps系統。
添加倉庫
添加Git源倉庫
可通過以下幾種方式添加Git源倉庫。
添加樣本應用的Git源倉庫到GitOps系統中。
argocd repo add https://github.com/AliyunContainerService/gitops-demo.git預期輸出:
Repository 'https://github.com/AliyunContainerService/gitops-demo.git' added使用使用者名稱和密碼,通過HTTPS添加私人Git源倉庫。
argocd repo add https://git.example.com/repos/repo --username git --password secret使用私密金鑰認證,通過SSH協議添加Git源倉庫並忽略伺服器憑證校正。
argocd repo add git@git.example.com:repos/repo --insecure-ignore-host-key --ssh-private-key-path ~/id_rsa
查看更多參數的使用說明。
argocd repo add --help添加Helm源倉庫
可通過以下幾種方式添加Helm源倉庫。
通過HTTPS添加公用Helm倉庫並命名。
argocd repo add https://charts.helm.sh/stable --type helm --name <本地倉庫名稱>使用使用者名稱和密碼,通過HTTPS添加私人Helm倉庫並命名。
argocd repo add https://charts.helm.sh/stable --type helm --name <本地倉庫名稱> --username test --password test若使用Container RegistryACR企業版的Helm Chart,請填寫完整的倉庫路徑。
argocd repo add https://<執行個體名稱>-chart.<region-id>.cr.aliyuncs.com/<命名空間>/<Chart倉庫> --type helm --name <本地倉庫名稱> --username test --password test通過HTTPS添加私人Helm OCI-based倉庫並命名。
argocd repo add helm-oci-registry.cn-zhangjiakou.cr.aliyuncs.com --type helm --name <本地倉庫名稱> --enable-oci --username test --password test
查看倉庫列表
執行以下命令,查看倉庫列表。
argocd repo list預期輸出:
TYPE NAME REPO INSECURE OCI LFS CREDS STATUS MESSAGE PROJECT
helm mystable https://charts.helm.sh/stable false false false false Successful
git https://github.com/AliyunContainerService/gitops-demo.git true false false false Successful default刪除倉庫
執行以下命令,刪除Git源倉庫。若需要刪除Helm倉庫,將命令中的Git倉庫地址替換為Helm倉庫地址即可。
argocd repo rm https://github.com/AliyunContainerService/gitops-demo.git預期輸出:
Repository 'https://github.com/AliyunContainerService/gitops-demo.git' removed相關操作
除了ArgoCD CLI方式,您也可以通過ArgoCD控制台管理倉庫源,操作入口如下:
登入ArgoCD UI,在左側導覽列選擇Settings,然後選擇 。