CodeBlanks Logo Icon CodeBlanks

Chart structure

Learn the Helm chart directory structure.

Chart structure

A chart is a specific folder layout. helm create produces a sample skeleton:

magaza/
  Chart.yaml          # name, version, description
  values.yaml         # default values
  templates/          # YAMLs with Go templates
    deployment.yaml
    service.yaml
    _helpers.tpl      # shared template pieces
    NOTES.txt         # post-install message
  charts/             # dependent charts
# Chart.yaml
apiVersion: v2
name: magaza
version: 0.1.0        # chart version
appVersion: "1.4.2"   # application version

Templates

The files under templates/ use the Go template language. {{ .Values.x }} reads from values.yaml, {{ .Release.Name }} from the release name, {{ .Chart.AppVersion }} from Chart.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-web
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    spec:
      containers:
        - name: web
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"

Practice A chart skeleton

Two steps: write the command creating a chart skeleton named magaza; then write the Chart.yaml contents: apiVersion: v2, name: magaza, version: 0.1.0, appVersion: "1.4.2".

Starter code

terminal
# buraya yaz

Sample solution

terminal
helm create magaza

# Chart.yaml
apiVersion: v2
name: magaza
version: 0.1.0
appVersion: "1.4.2"

Expected output

Creating magaza

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the difference between version and appVersion in Chart.yaml?

  • appVersion is the Kubernetes version
  • version is the Helm version
  • version is the chart package's version, appVersion the application inside it Correct answer
  • They are the same

Explanation: When the templates change, version goes up; when the image changes, appVersion.

2 Read the value from values.yaml.

Question
  replicas: {{ .____.replicaCount }}
Answer
  replicas: {{ .Values.replicaCount }}

Explanation: .Values is values.yaml and --set values.

3 Match.

Term Meaning
Chart.yaml Chart information
values.yaml Default values
templates/ Templated YAML
.Release.Name Release name

All lessons in Advanced