From 74040a33b923046cf43749e59102ba6f5aed940b Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 22 Feb 2024 17:18:33 +0100 Subject: [PATCH] Kargo: Refactoring to use v0.4.0 (#4934) * feat(kargo): bump to v0.4.0 Signed-off-by: Nicolas Lamirault * feat(demo): use Kargo v0.4.0 features Signed-off-by: Nicolas Lamirault --------- Signed-off-by: Nicolas Lamirault --- .../demo/podinfo-dev/templates/kargo.yaml | 73 ------------------- .../templates/kargoanalysistemplate.yaml | 41 +++++++++++ .../podinfo-dev/templates/kargoproject.yaml | 30 ++++++++ .../podinfo-dev/templates/kargostage.yaml | 38 ++++++++++ .../podinfo-dev/templates/kargowarehouse.yaml | 25 +++++++ .../charts/demo/podinfo-dev/values.yaml | 22 ++++-- .../demo/podinfo-prod/templates/kargo.yaml | 22 ++---- .../demo/podinfo-uat/templates/kargo.yaml | 19 ++--- .../charts/demo/podinfo-uat/values.yaml | 3 - gitops/argocd/charts/gitops/kargo/Chart.yaml | 2 +- 10 files changed, 166 insertions(+), 109 deletions(-) delete mode 100644 gitops/argocd/charts/demo/podinfo-dev/templates/kargo.yaml create mode 100644 gitops/argocd/charts/demo/podinfo-dev/templates/kargoanalysistemplate.yaml create mode 100644 gitops/argocd/charts/demo/podinfo-dev/templates/kargoproject.yaml create mode 100644 gitops/argocd/charts/demo/podinfo-dev/templates/kargostage.yaml create mode 100644 gitops/argocd/charts/demo/podinfo-dev/templates/kargowarehouse.yaml diff --git a/gitops/argocd/charts/demo/podinfo-dev/templates/kargo.yaml b/gitops/argocd/charts/demo/podinfo-dev/templates/kargo.yaml deleted file mode 100644 index 4546a04a71..0000000000 --- a/gitops/argocd/charts/demo/podinfo-dev/templates/kargo.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (C) Nicolas Lamirault -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -{{- if .Values.kargo.enabled -}} ---- -apiVersion: kargo.akuity.io/v1alpha1 -kind: Warehouse -metadata: - name: {{ .Values.kargo.warehouse.name }} - namespace: {{ .Release.Namespace }} -spec: - subscriptions: - - git: - repoURL: {{ .Values.kargo.warehouse.repoURL }} - branch: {{ .Values.kargo.warehouse.branch }} - - chart: - registryURL: oci://ghcr.io/stefanprodan/charts - name: podinfo - # semverConstraint: ^6.0.0 - - image: - repoURL: ghcr.io/stefanprodan/podinfo - tagSelectionStrategy: NewestBuild ---- -apiVersion: kargo.akuity.io/v1alpha1 -kind: PromotionPolicy -metadata: - name: {{ .Values.kargo.promotionPolicy.name }} - namespace: {{ .Release.Namespace }} -stage: {{ .Values.kargo.stage.name}} -enableAutoPromotion: {{ .Values.kargo.promotionPolicy.enableAutoPromotion }} ---- -apiVersion: kargo.akuity.io/v1alpha1 -kind: Stage -metadata: - annotations: - kargo.akuity.io/color: green - argocd.argoproj.io/sync-wave: "5" - name: {{ .Values.kargo.stage.name }} - namespace: {{ .Release.Namespace }} -spec: - subscriptions: - warehouse: {{ .Values.kargo.warehouse.name }} - promotionMechanisms: - gitRepoUpdates: - - repoURL: {{ .Values.kargo.stage.repoURL }} - readBranch: {{ .Values.kargo.stage.branch }} - writeBranch: kargo/pod-info-dev - helm: - images: - - image: ghcr.io/stefanprodan/podinfo - valuesFilePath: {{ .Values.kargo.stage.path }} - key: image.tag # Update this key to reference the new image version - value: 'Tag' - argoCDAppUpdates: - - appName: {{ .Values.kargo.argoCD.appName }} - appNamespace: {{ .Values.kargo.argoCD.appNamespace }} - sourceUpdates: - - repoURL: {{ .Values.kargo.stage.repoURL }} - updateTargetRevision: true -{{- end }} diff --git a/gitops/argocd/charts/demo/podinfo-dev/templates/kargoanalysistemplate.yaml b/gitops/argocd/charts/demo/podinfo-dev/templates/kargoanalysistemplate.yaml new file mode 100644 index 0000000000..b12da682a9 --- /dev/null +++ b/gitops/argocd/charts/demo/podinfo-dev/templates/kargoanalysistemplate.yaml @@ -0,0 +1,41 @@ +--- +# Copyright (C) Nicolas Lamirault +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +{{- if .Values.kargo.analysistemplate.enabled -}} +apiVersion: argoproj.io/v1alpha1 +kind: AnalysisTemplate +metadata: + name: {{ .Values.kargo.analysistemplate.name }}-{{ .Values.kargo.stage.name }} + namespace: {{ .Release.Namespace }} +spec: + metrics: + - name: test + provider: + job: + metadata: + spec: + backoffLimit: 1 + template: + spec: + containers: + - name: test + image: alpine:latest + command: + - sleep + - "20" + restartPolicy: Never +{{- end }} diff --git a/gitops/argocd/charts/demo/podinfo-dev/templates/kargoproject.yaml b/gitops/argocd/charts/demo/podinfo-dev/templates/kargoproject.yaml new file mode 100644 index 0000000000..8dbac035e1 --- /dev/null +++ b/gitops/argocd/charts/demo/podinfo-dev/templates/kargoproject.yaml @@ -0,0 +1,30 @@ +--- +# Copyright (C) Nicolas Lamirault +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +{{- if .Values.kargo.project.enabled -}} +apiVersion: kargo.akuity.io/v1alpha1 +kind: Project +metadata: + name: {{ .Values.kargo.project.name }} + namespace: {{ .Release.Namespace }} +spec: + promotionPolicies: + - stage: test + autoPromotionEnabled: true + - stage: uat + autoPromotionEnabled: true +{{- end }} diff --git a/gitops/argocd/charts/demo/podinfo-dev/templates/kargostage.yaml b/gitops/argocd/charts/demo/podinfo-dev/templates/kargostage.yaml new file mode 100644 index 0000000000..9886ab9d5d --- /dev/null +++ b/gitops/argocd/charts/demo/podinfo-dev/templates/kargostage.yaml @@ -0,0 +1,38 @@ +--- +# Copyright (C) Nicolas Lamirault +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: kargo.akuity.io/v1alpha1 +kind: Stage +metadata: + annotations: + kargo.akuity.io/color: green + argocd.argoproj.io/sync-wave: "5" + name: {{ .Values.kargo.stage.name }} + namespace: {{ .Release.Namespace }} +spec: + subscriptions: + warehouse: {{ .Values.kargo.warehouse.name }} + promotionMechanisms: + argoCDAppUpdates: + - appName: podinfo-dev + sourceUpdates: + - repoURL: https://stefanprodan.github.io/podinfo + chart: podinfo + updateTargetRevision: true # Update Application to reference the new chart version + verification: + analysisTemplates: + - name: {{ .Values.kargo.analysistemplate.name }}-{{ .Values.kargo.stage.name }} diff --git a/gitops/argocd/charts/demo/podinfo-dev/templates/kargowarehouse.yaml b/gitops/argocd/charts/demo/podinfo-dev/templates/kargowarehouse.yaml new file mode 100644 index 0000000000..b997e8d3e8 --- /dev/null +++ b/gitops/argocd/charts/demo/podinfo-dev/templates/kargowarehouse.yaml @@ -0,0 +1,25 @@ +# Copyright (C) Nicolas Lamirault +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: kargo.akuity.io/v1alpha1 +kind: Warehouse +metadata: + name: {{ .Values.kargo.warehouse.name }} + namespace: {{ .Release.Namespace }} +spec: + subscriptions: + {{- toYaml .Values.kargo.warehouse.subscriptions | nindent 4 }} diff --git a/gitops/argocd/charts/demo/podinfo-dev/values.yaml b/gitops/argocd/charts/demo/podinfo-dev/values.yaml index 2352bac79f..f2092f05f0 100644 --- a/gitops/argocd/charts/demo/podinfo-dev/values.yaml +++ b/gitops/argocd/charts/demo/podinfo-dev/values.yaml @@ -26,14 +26,24 @@ podinfo: monitoring: portefaix kargo: - enabled: true - promotionPolicy: - name: podinfo-dev - enableAutoPromotion: true + project: + enabled: true + name: podinfo + analysistemplate: + name: podinfo warehouse: name: podinfo - repoURL: https://github.com/portefaix/portefaix-kubernetes - branch: master + subscriptions: + # - git: + # repoURL: {{ .Values.kargo.warehouse.repoURL }} + # branch: {{ .Values.kargo.warehouse.branch }} + - chart: + registryURL: https://stefanprodan.github.io/podinfo + name: podinfo + semverConstraint: ^6.0.0 + - image: + repoURL: ghcr.io/stefanprodan/podinfo + tagSelectionStrategy: NewestBuild stage: name: podinfo-dev repoURL: https://github.com/portefaix/portefaix-kubernetes diff --git a/gitops/argocd/charts/demo/podinfo-prod/templates/kargo.yaml b/gitops/argocd/charts/demo/podinfo-prod/templates/kargo.yaml index 47ad3a5cce..f36ae5f356 100644 --- a/gitops/argocd/charts/demo/podinfo-prod/templates/kargo.yaml +++ b/gitops/argocd/charts/demo/podinfo-prod/templates/kargo.yaml @@ -1,3 +1,4 @@ +--- # Copyright (C) Nicolas Lamirault # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +15,6 @@ # # SPDX-License-Identifier: Apache-2.0 -{{- if .Values.kargo.enabled -}} ---- -apiVersion: kargo.akuity.io/v1alpha1 -kind: PromotionPolicy -metadata: - name: {{ .Values.kargo.promotionPolicy.name }} - namespace: {{ .Release.Namespace }} -stage: {{ .Values.kargo.stage.name}} -enableAutoPromotion: {{ .Values.kargo.promotionPolicy.enableAutoPromotion }} ---- apiVersion: kargo.akuity.io/v1alpha1 kind: Stage metadata: @@ -38,9 +29,12 @@ spec: {{- toYaml .Values.kargo.stage.upstreamStages | nindent 4 }} promotionMechanisms: argoCDAppUpdates: - - appName: {{ .Values.kargo.argoCD.appName }} - appNamespace: {{ .Values.kargo.argoCD.appNamespace }} + - appName: podinfo-prod sourceUpdates: - - repoURL: {{ .Values.kargo.stage.repoURL }} - updateTargetRevision: true + - repoURL: https://stefanprodan.github.io/podinfo + chart: podinfo + updateTargetRevision: true # Update Application to reference the new chart version + verification: + analysisTemplates: + - name: {{ .Values.kargo.analysistemplate.name }}-{{ .Values.kargo.stage.name }} {{- end }} diff --git a/gitops/argocd/charts/demo/podinfo-uat/templates/kargo.yaml b/gitops/argocd/charts/demo/podinfo-uat/templates/kargo.yaml index c1793713da..496f49bd5b 100644 --- a/gitops/argocd/charts/demo/podinfo-uat/templates/kargo.yaml +++ b/gitops/argocd/charts/demo/podinfo-uat/templates/kargo.yaml @@ -1,3 +1,4 @@ +--- # Copyright (C) Nicolas Lamirault # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +15,6 @@ # # SPDX-License-Identifier: Apache-2.0 -{{- if .Values.kargo.enabled -}} ---- -apiVersion: kargo.akuity.io/v1alpha1 -kind: PromotionPolicy -metadata: - name: {{ .Values.kargo.promotionPolicy.name }} - namespace: {{ .Release.Namespace }} -stage: {{ .Values.kargo.stage.name}} -enableAutoPromotion: {{ .Values.kargo.promotionPolicy.enableAutoPromotion }} ---- apiVersion: kargo.akuity.io/v1alpha1 kind: Stage metadata: @@ -41,6 +32,10 @@ spec: - appName: {{ .Values.kargo.argoCD.appName }} appNamespace: {{ .Values.kargo.argoCD.appNamespace }} sourceUpdates: - - repoURL: {{ .Values.kargo.stage.repoURL }} - updateTargetRevision: true + - repoURL: https://stefanprodan.github.io/podinfo + chart: podinfo + updateTargetRevision: true # Update Application to reference the new chart version + verification: + analysisTemplates: + - name: {{ .Values.kargo.analysistemplate.name }}-{{ .Values.kargo.stage.name }} {{- end }} diff --git a/gitops/argocd/charts/demo/podinfo-uat/values.yaml b/gitops/argocd/charts/demo/podinfo-uat/values.yaml index 42a14d9f4f..3f83fd362f 100644 --- a/gitops/argocd/charts/demo/podinfo-uat/values.yaml +++ b/gitops/argocd/charts/demo/podinfo-uat/values.yaml @@ -27,9 +27,6 @@ podinfo: kargo: enabled: true - promotionPolicy: - name: podinfo-uat - enableAutoPromotion: true stage: name: podinfo-uat repoURL: https://github.com/portefaix/portefaix-kubernetes diff --git a/gitops/argocd/charts/gitops/kargo/Chart.yaml b/gitops/argocd/charts/gitops/kargo/Chart.yaml index 8186a5e439..2f7a701c35 100644 --- a/gitops/argocd/charts/gitops/kargo/Chart.yaml +++ b/gitops/argocd/charts/gitops/kargo/Chart.yaml @@ -23,4 +23,4 @@ appVersion: 1.0.0 dependencies: - name: kargo repository: oci://ghcr.io/akuity/kargo-charts - version: 0.3.0 + version: 0.4.0