Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

helm getting subchart service names

Whats the best way to get the helm subchart service names to reference into my ingress controller that will sit in the parent chart

values.yaml
---
ingress:
  paths:
    - serviceName: app-1
      path: /app-1/*
      port: 8080
    - serviceName: app-2
      path: /app-2/*
      port: 8080


ingress.yaml 
---
{{- range .Values.ingress.paths }}
          - path: {{ .path }}
            backend:
              {{- $subchart := .serviceName -}}
              serviceName: {{- include "$subchart.fullname" .}}
              servicePort: {{ .port }}
        {{- end }}

template: no template "$subchart.fullname" associated with template "gotpl"

like image 277
doe1331 Avatar asked Mar 07 '18 00:03

doe1331


People also ask

Is Helm being deprecated?

helm/charts has been deprecated and will be obsolete by Nov 13 2020. For this reason, the datawire team as retaken ownership of this chart. The Ambassador Chart is now hosted at datawire/ambassador-chart.

What is Subchart in Helm?

A subchart is considered "stand-alone", which means a subchart can never explicitly depend on its parent chart. For that reason, a subchart cannot access the values of its parent. A parent chart can override values for subcharts. Helm has a concept of global values that can be accessed by all charts.

What does {{- mean in Helm?

{{- (with the dash and space added) indicates that whitespace should be chomped left, while -}} means whitespace to the right should be consumed.


2 Answers

helm 3.7 version has solved the problem https://github.com/helm/helm/pull/9957.
You can use like this

{{ template "bar.fullname" .Subcharts.bar }}
like image 136
amao Avatar answered Sep 20 '22 06:09

amao


If the subchart uses the fullname function from _helpers.tpl (provided by helm by default for new charts) you can use this (replace postgresql with the name of the subchart):

{{- $fullName := include "postgresql.fullname" (mustMerge (dict "Chart" (dict "Name" "postgresql") "Values" .Values.postgresql) (deepCopy .)) -}}
like image 38
fnkr Avatar answered Sep 20 '22 06:09

fnkr