'How to skip templates from being deployed in helm and is it possible for custom properties in Chart.yaml

I have charts defined as below

 my-charts/
  |_  app1
       |
       |_Chart.yaml
       |_ values-dev.yaml
       |_ values.yaml
       |_ .helmignore
       |_ template/
             |_ app1-microservice1-deployment.yaml  (k8s deployment definition)
             |_ app1-microservice1-service-defintion.yaml   (k8s service definition)
             |_ app1-microservice2-deployment.yaml
             |_ app1-microservice2-service-defintion.yaml

Say if i wanted to deploy only the templates

  • app1-microservice1-deployment.yaml
  • app1-microservice1-service-defintion.yaml

Is there any way to achieve it.

  • If i use the .helmignore with the other app1-microservice2*.yaml files will helm install/upgrade ignores these files from being deployed?
  • Is there any best practices around this area.

Also, in helm3 Chart.yaml any custom field/properties can be included in annotation per the documentation.

apiVersion: v2
description: application description
name: app1-microservices
version: 1.0.1

# Is the below possible in helm3
projectNames: microservice1,microservice2
imageRepo:
   microservice1: app1/microservice1
   microservice2: app1/microservice2

What happens if include custom properties in Chart.yaml.

I am exploring helm, apologize if question is not clear enough.



Solution 1:[1]

  • In helm3 Chart.yaml any custom field/properties can be included in annotation per the documentation.
    • Any values, other than specified in the documentation.
    • Below works fine when helm renders, but this projectNames can NOT be used by the templates like .Chart.projectNames.
apiVersion: v2
name: example2
description: A Helm chart for Kubernetes

type: application

version: 0.1.0

appVersion: "1.16.0"

projectNames: ["app1","app2"]

In order to skip a particular deployment from being rendered in helm, we can use wrap the template.yaml with {{- if .Values.enabledForRelease }}...

Solution 2:[2]

You need to add the following line in your .helmignore file.

templates/wapp1-microservice2-*

And then helm should handle the rest.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 user1012513