Search code examples
kuberneteskubernetes-helm

Is it possible to disable chart located in charts folder in kubernetes?


I have a subchart in charts/ directory. I would like to disable it for some deployments.

Is it possible somehow? Currently i see the only way to add condition to all templates like below:

deployment.yaml

{{- if .Values.isDev }}
deployment code
{{- end }}

service.yaml

{{- if .Values.isDev }}
service code
{{- end }}

Solution

  • As a general rule of thumb I always have

    {{- if .Values.enabled }}
    ...
    {{- end }}
    

    in every file in every subchart. Depending on situation the default value will be either true for regular components or false for dev related, or simply false for everything if I want to enable these in completely selective manner. A typical values for deployment for this approach looks like ie.:

    api:
      enabled: true
      database:
        host: mysql-dev
    
    mysql:
      enabled: false
    
    mysql-dev:
      enabled: true