...

/

Create a Simple Helm Chart

Create a Simple Helm Chart

Learn to define all the necessary templates for a simple Helm chart.

The Chart.yaml file

Once all the template files are removed we can proceed with creating our chart from scratch. Firstly, we’ll define the metadata of our chart in the Chart.yaml file. Here is what we should have by default (for clarity, comments are skipped):

Press + to interact
apiVersion: v2
name: app
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"

In the Chart.yaml file, only apiVersion, name, and version properties are required. All others are optional, but it’s a good practice to add more. Let’s replace the default values with a new one, as follows:

Press + to interact
apiVersion: v2
name: app
description: A Helm chart for any application
type: application
version: 0.1.0
appVersion: "0.0.1"

Next, let’s add more information like who’s the creator, where more information about a chart can be found, and some keywords:

Press + to interact
apiVersion: v2
name: app
description: A Helm chart for any application
type: application
version: 0.1.0
appVersion: "0.0.1"
keywords:
- app
- java
- javascript
- angular
home: https://github.com/wkrzywiec/k8s-helm-helmfile/tree/master/helm
maintainers:
- name: John Doe
url: https://github.com/wkrzywiec

We can now leave it as it is. If we need to know what other options are available we can check the official documentation.

Helm templates

After filling in the necessary data in the Chart.yaml file we can move on to defining Kubernetes resources. In this part, we’ll define two resources: Deployment and Service. Later on, we’ll add more of them.

Our goal is to create the following resources using Helm:

Press + to interact
apiVersion: apps/v1
kind: Deployment
metadata:
name: kanban-app
labels:
app: kanban-app
group: backend
spec:
replicas: 1
selector:
matchLabels:
app: kanban-app
template:
metadata:
labels:
app: kanban-app
group: backend
spec:
containers:
- name: kanban-app
image: wkrzywiec/kanban-app:helm-course
ports:
- containerPort: 8080
env:
- name: DB_SERVER
value: postgres
- name: POSTGRES_DB
value: kanban
- name: POSTGRES_USER
value: kanban
- name: POSTGRES_PASSWORD
value: kanban
---
apiVersion: v1
kind: Service
metadata:
name: kanban-app
labels:
group: backend
spec:
type: ClusterIP
selector:
app: kanban-app
ports:
- port: 8080
targetPort: 8080

For the front-end application, both resource definitions would look similar with really small changes.

Since this is a Helm course that focuses primarily on Helm features, most of the time ...