2

I have an application which is hosted on multiple environments and helm chart is used to deploy the application. I have values.yaml-

app:
  component: mobile
  type: web 
  env: prd --> (It will override with external parameters while deployment like dev / stg / uat)


image:
  repository: ********.dkr.ecr.ap-south-1.amazonaws.com/mobile
  pullPolicy: IfNotPresent
  versions:
    v1:
      name: stable
      replicaCount: 2
      tag: latest
    v2:
      name: release
      replicaCount: 1
      tag: latest

Based on version v1 and v2(canary fashion), Deployment will iterate over loop. Canary deployment will be perform only on PRD environment. So on DEV / STG / UAT, only one version will be deployed and therefore loop will needed to iterate only one time for such environment.

{{- range $version, $val := $.Values.image.versions }}
---
apiVersion: apps/v1
kind: Deployment

I can set number of required pods for v2 as 0 but it create unnecessary metadata (deployemnt, replicaset).

So is there any method to break loop in helm template with condition (env: prd) to avoid loop iteration over v2.

Ashish Kumar
  • 524
  • 6
  • 18
  • am I right that your question is "how to deploy v1 and v2 on prod, and only v1 on uat/stg" ? – Nick Apr 03 '20 at 13:11
  • yes @Nick. I achieved the above requirement using IF and ELSE. But helm chart is lacking of BREAK method, it should have this functionality specially when range(loop) functionality is available. – Ashish Kumar Apr 03 '20 at 18:07
  • It'll be good if you can post your solution as an answer. It might be useful for someone. – Nick Jun 16 '20 at 10:41

0 Answers0