BetaRide
BetaRide

Reputation: 16834

How to add custom templates to bitnami helm chart?

I'm deploying a spring cloud data flow cluster on kubernetes with helm and the chart from bitnami. This works fine.

Now I need an additional template to add a route. Is there a way to somehow add this or inherit from the bitnami chart and extend it? Of course I'd like to reuse all of the variables which are already defined for the spring cloud data flow deployment.

Upvotes: 1

Views: 6842

Answers (2)

David Maze
David Maze

Reputation: 158714

That chart has a specific extension point for doing things like this. The list of "Common parameters" in the linked documentation includes a line

Name: extraDeploy; Description: Array of extra objects to deploy with the release; Value: []

The implementation calls through to a helper in the Bitnami Common Library Chart that calls the Helm tpl function on the value, serializing it to YAML first if it's not a string, so you can use Helm templating within that value.

So specifically for the Bitnami charts, you can include an extra object in your values.yaml file:

extraDeploy:
  - apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: '{{ include "common.names.fullname" . }}'
    ...

As a specific syntactic note, the value of extraDeploy is a list of either strings or dictionaries, but any templating is rendered after the YAML is parsed; this is different from the normal Helm template flow. In the example above I've included a YAML object, but then quoted a string value that begins with a {{ ... }} template, lest it otherwise be parsed as a YAML mapping. You could also force the whole thing to be a string, though it might be harder to work with in an IDE.

extraDeploy:
  - |-
      metadata:
        name: {{ include "common.names.fullname" . }}

Upvotes: 6

Harsh Manvar
Harsh Manvar

Reputation: 30083

You can just create the YAML template file in the templates folder and it will get deployed with the chart.

You can also edit the existing YAML template accordingly and extend it no need to inherit or much things.

For example, if you are looking forward to adding the ingress into your chart, add ingress template and respective values block in values.yaml file

You can add this whole YAML template in folder : https://github.com/helm/charts/blob/master/stable/ghost/templates/ingress.yaml

and specific values.yaml block for ingress.

Or for example your chart dont have any deployment and you want to add deployment you can write your own template or use form internet.

Deployment : https://github.com/helm/charts/tree/master/stable/ghost/templates

there is deployment.yaml file template and you can get specific variables that the template uses into values.yaml and you have extended the chart successfully.

Upvotes: 0

Related Questions