Bil*_*ill 9 gitlab kubernetes gitops argocd cicd
我已经通过 ArgoCD 成功部署了应用程序,并且可以通过其入口 url 访问它
应用程序使用带有最新标签的图像名称,例如
image: <private_registry>/app_1_service:latest
Run Code Online (Sandbox Code Playgroud)
我还管理同一标签上的其他标签latest,例如image:<commit_id> or image:<1.0.xxx>
现在,开发人员将更新代码,提交更改后,gitlab 管道会自动运行并构建新映像并覆盖以latest使用其他标签进行标记并推送到私有 docker 注册表
那么 ArgoCD 的下一步是什么?
argocd 如何知道应用程序已更改,需要重新部署,以及image:latest需要再次拉取?
Adi*_*iii 12
您可以使用ArgoCD 图像更新程序
但在使用image-updater之前,您需要安装并设置适当的权限
helm repo add argo https://argoproj.github.io/argo-helm
helm install argocd-image-updater argo/argocd-image-updater
Run Code Online (Sandbox Code Playgroud)
一旦 image-updator 启动并运行,那么您需要在 Argocd 应用程序中设置一些注释,因为更新工作人员采用不同的策略
semver - 考虑语义版本控制约束,更新到映像的最新版本 latest - 更新到注册表
摘要中找到的最新构建的映像- 使用标签的 SHA 摘要
名称更新到给定版本(标签)的最新版本- 排序按字母顺序标记并更新为基数最高的标记
latest在某些正则表达式下进行标记的策略效果非常好,并且digest更适合测试环境。
您也可以从 gitlab 拉取私有镜像。
这是 helm-release 的工作示例
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'
argocd-image-updater.argoproj.io/image-alias.force-update: 'true'
argocd-image-updater.argoproj.io/image-alias.pull-secret: 'pullsecret:develop-namespace/develop-app-gitlab-secrets'
argocd-image-updater.argoproj.io/image-alias.update-strategy: latest
argocd-image-updater.argoproj.io/image-list: >-
image-alias=registry.gitlab.com/myorg/my-test-image
finalizers:
- resources-finalizer.argocd.argoproj.io
labels:
app.kubernetes.io/instance: develop-platform
name: develop-app
namespace: argocd
spec:
destination:
namespace: develop-app
server: 'https://kubernetes.default.svc'
project: develop-app-west6-b
source:
helm:
releaseName: develop-app
valueFiles:
- develop-platform/values.yaml
path: helm-chart/helm-chart
repoURL: 'https://gitlab.com/my-org/develop-app.git'
targetRevision: staging
syncPolicy:
automated:
prune: true
selfHeal: true
Run Code Online (Sandbox Code Playgroud)
如果您需要digest或只是最新的,请删除此
argocd-image-updater.argoproj.io/image-alias.allow-tags: 'regexp:^1.3.0-SNAPSHOT.[0-9]+$'
Run Code Online (Sandbox Code Playgroud)
这是基于正则表达式的工作。所以在你的情况下<1.0.xxx>
有可能'regexp:^1.0.[0-9]+$'
如果一切配置正确并且图像更新程序工作正常,那么您应该能够看到像这样的图像更新程序日志
time="2022-04-27T15:18:36Z" level=info msg="Successfully updated image 'registry.gitlab.com/test-image:0.3.0-SNAPSHOT.115' to 'registry.gitlab.com/test-image:0.3.0-SNAPSHOT.118'
Run Code Online (Sandbox Code Playgroud)
ArgoCD 支持 2 种类型的应用程序同步策略:
以下是自动从 Jfrog 工件注册表部署 helm 的示例:
project: default
source:
repoURL: 'https://abc.jfrog.io/artifactory/helm'
targetRevision: '*.*.*' # set your regex pattern here
helm:
parameters:
- name: image.tag
env: dev
chart: frontend-chart
destination:
server: 'https://kubernetes.default.svc'
namespace: default
syncPolicy:
automated: {} # enables auto syncing
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15223 次 |
| 最近记录: |