本文介绍如何在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若使用容器镜像服务ACR企业版的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,然后选择 。
该文章对您有帮助吗?