argocd + gitlab 自动部署

gitlab 部分

上传gitlab项目

image-20220912095824883

该项目定义了 default 命名空间中的 ingress 配置;

gitlab 配置ssh密钥

image-20220912100012644

这里为了方便以后的配置,gitops 用户配置了 ssh 公钥;方便以后拉取代码;

然后给 gitops 配置拉取代码的相关权限;

argocd 部分

argocd 添加 repo

官方文档链接地址:Argocd repo add - Argo CD - 声明性 GitOps CD for Kubernetes (argo-cd.readthedocs.io)

# 该私钥对应的是 gitops 的公钥;这是一对密钥对;
argocd repo add git@gitlab-hk.xxxx.com:root/default-ingress.git --insecure-ignore-host-key --ssh-private-key-path ~/.ssh/id_rsa

添加完之后,argocd ui界面会有显示;

image-20220912100343149

如果密钥可以拉取代码,这里会显示 successful,否则失败;

argocd 添加应用程序

image-20220912100749509

创建 app 时,指定红色方框内的内容。 path 是 需要部署的yaml 的路径;namespace 是需要在哪个 名称空间下执行;repo url 是 代码的url

image-20220912100843622

创建 app 后,记得点击 sync 让他同步,也可以点击 自动同步,让他实时更新;