Business Scenario
Live Environment
Prerequisites
Once you have the Helm CLI installed, you can create a Helm chart for your deployment. The Helm CLI provides a command to create a Helm chart for you. This will create a few sample files for you to get started with. However, in this approach, we will create the Helm chart manually from scratch.
Task 1: Create, customize and deploy a Helm chart for a deployment
Steps
Create a new directory for your Helm chart. Call it hello-kyma-chart and change into it.
Create a new file called Chart.yaml and specify information about the chart, such as the name, version, description, and so on. Add the following content to the file:
12345
apiVersion: v2
name: hello-kyma-chart
description: A Helm chart for the Hello Kyma example application
type: application # A chart can be either an 'application' or a 'library' chart.
version: 0.1.0 # This is the chart version.
Create a new file called values.yaml and specify the default configuration values like replicaCount and image.tag. Add the following content to the file:
123
replicaCount: 1
image:
tag: "1.0.0"
Create a new directory called templates and change into it.
In this directory, you can add all the templates for your Helm chart. For now, we will only add a template for the Deployment.
Create a new file called deployment.yaml and specify the Kubernetes Deployment's definition and use your configuration values. Add the following content to the file:
123456789101112131415161718192021222324
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- name: hello-kyma
image: ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:{{ .Values.image.tag }}
ports:
- containerPort: 8080
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
Hint
Take advantage of the {{ .Release.Name }}
and {{ .Values.replicaCount }}
placeholders to make use of the configuration values that you specified in the values.yaml
file. The {{ Release.Name }}
placeholder will be replaced with the name of the Helm release. The {{ .Chart.AppVersion }}
placeholder will be replaced with the version of the application that you specified in the Chart.yaml
file.
To perform a dry-run of your Helm chart to see if it is valid, run the following command inside the hello-kyma-chart directory:
1
helm template hello-kyma .
You should now see a rendered output of your Helm chart.
Install the Helm chart in your cluster.
Run the following command inside the hello-kyma-chart directory:
1
helm install hello-kyma-helm .
You should now see the following output:
123456
NAME: hello-kyma-helm
LAST DEPLOYED: Tue Jun 8 11:25:00 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
To see the Deployment in your cluster, run the following command:
You should now see the following output:
12
NAME READY UP-TO-DATE AVAILABLE AGE
hello-kyma-helm 1/1 1 1 2m
Update the values.yaml file and change the replicaCount to 2.
Update the Helm chart in your cluster.
Run the following command inside the hello-kyma-chart directory:
1
helm upgrade hello-kyma-helm .
You should now see the following output:
1234567
Release "hello-kyma-helm" has been upgraded. Happy Helming!
NAME: hello-kyma-helm
LAST DEPLOYED: Tue Jun 8 11:25:00 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
List the Deployments using kubectl:
You should now see the following output:
12
NAME READY UP-TO-DATE AVAILABLE AGE
hello-kyma-helm 2/2 2 2 4m
View the Helm release in Kyma dashboard.
Open Kyma dashboard in your browser.
Go to Apps → Helm Releases and choose the hello-kyma-helm release.
You should now see the following output:
Note
Once you discover other Kubernetes objects later in this course, you will be able, for example, to extend your helm chart with other manifests for services, ingresses, and more.
Result
You have successfully created a Helm chart for your deployment and deployed it to your cluster.