Altinn / app-template-dotnet

Altinn Studio application template
BSD 3-Clause "New" or "Revised" License
2 stars 8 forks source link

chore: bump helm dependency deployment chart v3.2.0 #222

Closed bengtfredh closed 1 month ago

bengtfredh commented 1 month ago

Description

Related Issue(s)

Verification

Documentation

bengtfredh commented 1 month ago

Pipeline code to patch deployment for apps which use old version until they have upgraded to 3.2.0. This only in "Helm Upgrade Test" for now:

@@ -9,20 +9,40 @@ catch {
 helm plugin install https://github.com/helm/helm-mapkubeapis
 # Define the new mapping to append
 $NewItem = @"
+
   - deprecatedAPI: "apiVersion: autoscaling/v2beta2\nkind: HorizontalPodAutoscaler\n"
     newAPI: "apiVersion: autoscaling/v2\nkind: HorizontalPodAutoscaler\n"
     deprecatedInVersion: "v1.23"
     removedInVersion: "v1.26"
+  - deprecatedAPI: "apiVersion: traefik.containo.us/v1alpha1\nkind: IngressRoute\n"
+    newAPI: "apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\n"
+    deprecatedInVersion: "v1.23"
+    removedInVersion: "v1.26"
+  - deprecatedAPI: "apiVersion: traefik.containo.us/v1alpha1\nkind: Middleware\n"
+    newAPI: "apiVersion: traefik.io/v1alpha1\nkind: Middleware\n"
+    deprecatedInVersion: "v1.23"
+    removedInVersion: "v1.26"
+  - deprecatedAPI: "apiVersion: traefik.containo.us/v1alpha1\nkind: TLSOption\n"
+    newAPI: "apiVersion: traefik.io/v1alpha1\nkind: TLSOption\n"
+    deprecatedInVersion: "v1.23"
+    removedInVersion: "v1.26"
+  - deprecatedAPI: "apiVersion: traefik.containo.us/v1alpha1\nkind: TLSStore\n"
+    newAPI: "apiVersion: traefik.io/v1alpha1\nkind: TLSStore\n"
+    deprecatedInVersion: "v1.23"
+    removedInVersion: "v1.26"
 "@

 $MAP_PATH = "/home/vsts/.local/share/helm/plugins/helm-mapkubeapis/config/Map.yaml"
@@ -51,9 +71,21 @@ $ai_instr_key = (Get-AzApplicationInsights -ResourceGroupName $resourceGroupName
 # Run helm mapkubeapis with the modified YAML file
 helm mapkubeapis $(RELEASE_NAME)

+# Content in helm-post-renderer.sh
+$HelmPostRenderer = @"
+#!/bin/bash
+## Read the entire Helm output (rendered templates) from stdin
+## Replace the apiVersion and output the result
+sed 's/apiVersion: traefik.containo.us\/v1alpha1/apiVersion: traefik.io\/v1alpha1/g'
+"@
+# Add content to post-renderer script
+Add-Content -Path helm-post-renderer.sh -Value $HelmPostRenderer
+chmod +x helm-post-renderer.sh
+
 helm upgrade $(RELEASE_NAME) $(APP_COMMIT_ID)/deployment --install `
--f overrides.yaml --atomic
+-f overrides.yaml --set deployment.image.pullSecrets="" --set deployment.ingressRoute.tls="" --post-renderer ./helm-post-renderer.sh --atomic

 if(!$?) {
bengtfredh commented 1 month ago

Yes, ready to merge - everything is in place. We even patch on deploy apps that use old template.