Create a Simple Helm Chart
Learn to define all the necessary templates for a simple Helm chart.
We'll cover the following...
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):
apiVersion: v2name: appdescription: A Helm chart for Kubernetestype: applicationversion: 0.1.0appVersion: "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:
apiVersion: v2name: appdescription: A Helm chart for any applicationtype: applicationversion: 0.1.0appVersion: "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:
apiVersion: v2name: appdescription: A Helm chart for any applicationtype: applicationversion: 0.1.0appVersion: "0.0.1"keywords:- app- java- javascript- angularhome: https://github.com/wkrzywiec/k8s-helm-helmfile/tree/master/helmmaintainers:- name: John Doeurl: 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:
apiVersion: apps/v1kind: Deploymentmetadata:name: kanban-applabels:app: kanban-appgroup: backendspec:replicas: 1selector:matchLabels:app: kanban-apptemplate:metadata:labels:app: kanban-appgroup: backendspec:containers:- name: kanban-appimage: wkrzywiec/kanban-app:helm-courseports:- containerPort: 8080env:- name: DB_SERVERvalue: postgres- name: POSTGRES_DBvalue: kanban- name: POSTGRES_USERvalue: kanban- name: POSTGRES_PASSWORDvalue: kanban---apiVersion: v1kind: Servicemetadata:name: kanban-applabels:group: backendspec:type: ClusterIPselector:app: kanban-appports:- port: 8080targetPort: 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 ...