Search code examples
kuberneteskubernetes-helm

How did you learn all the various fields specified in helm templates of k8s resources?


I am trying to learn K8S, currently dealing with helm charts. I do not understand how to learn what to put into my helm template files in a generalist way. There are just so many different fields... How did you learn to write k8s resource templates on your own?

I am just trying to, from scratch, setup a simple kind cluster with 2 pods that talk to each other.

As far as I can tell the official helm docs only explain the workings of helm charts themselves. So, the syntax and the cli. They do not show how to "write a template for a k8s deployment" for example. The only way I have found to write a simple template of my own is to take a template from some tutorial on the internet (or the one generated by helm create) and hack it into what I need. I think this is not a good approach since I have no way of knowing what else I could specify in that template or what the meaning of each line is.

Any thoughts would be much appreciated!


Solution

  • https://helm.sh/docs/helm/helm_create/ offers exactly that, the files/folder structure and what can be there..

    For example, 'helm create foo' will create a directory structure that looks something like this:

    foo/
    ├── .helmignore   # Contains patterns to ignore when packaging Helm charts.
    ├── Chart.yaml    # Information about your chart
    ├── values.yaml   # The default values for your templates
    ├── charts/       # Charts that this chart depends on
    └── templates/    # The template files
       └── tests/    # The test files
    

    https://helm.sh/docs/topics/charts/ & https://helm.sh/docs/chart_template_guide/getting_started/ further explains the contents for each..

    And there are plenty of tutorials on how to "create your first Chart", few examples:

    There also a lot of already chreated Charts on Github, if you want to copy+modify one for your needs, but first would be very helpful for you to go through the first links and understand the bases of how they are created and what should or should not be within the charts.