0
0
Kubernetesdevops~7 mins

Creating custom Helm charts in Kubernetes - Step-by-Step CLI Walkthrough

Choose your learning style9 modes available
Introduction
When you want to deploy applications on Kubernetes repeatedly and consistently, creating a custom Helm chart helps package all the app's settings and files together. This makes deploying and updating your app easier and less error-prone.
When you want to deploy your own application on Kubernetes with custom settings.
When you need to share your app deployment setup with your team or others.
When you want to manage app versions and upgrades smoothly on Kubernetes.
When you want to avoid typing long kubectl commands repeatedly for your app.
When you want to customize app configurations like ports, replicas, or environment variables easily.
Config File - Chart.yaml
Chart.yaml
apiVersion: v2
name: my-app
description: A Helm chart for deploying my custom app
version: 0.1.0
appVersion: "1.0"

apiVersion: Specifies Helm chart version format.

name: The chart's name.

description: A short explanation of what the chart does.

version: The chart's version for tracking changes.

appVersion: The version of the app the chart deploys.

Commands
This command creates a new Helm chart folder named 'my-app' with default files and folders to start customizing your app deployment.
Terminal
helm create my-app
Expected OutputExpected
Creating my-app
This command installs your custom Helm chart named 'my-app' into your Kubernetes cluster, deploying your app with the default settings.
Terminal
helm install my-app ./my-app
Expected OutputExpected
NAME: my-app LAST DEPLOYED: Fri Apr 26 12:00:00 2024 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None
This command lists all Helm releases installed in your Kubernetes cluster to verify your app is deployed.
Terminal
helm list
Expected OutputExpected
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION my-app default 1 2024-04-26 12:00:00.000000 deployed my-app-0.1.0 1.0
This command removes the 'my-app' release from your Kubernetes cluster, cleaning up all deployed resources.
Terminal
helm uninstall my-app
Expected OutputExpected
release "my-app" uninstalled
Key Concept

If you remember nothing else from this pattern, remember: a Helm chart packages all your app's Kubernetes files and settings so you can deploy and manage your app easily with simple commands.

Common Mistakes
Trying to install a Helm chart without creating it first.
Helm needs the chart files and structure to deploy; without creating the chart, the install command fails.
Always run 'helm create my-app' to generate the chart files before installing.
Not updating the Chart.yaml or templates before installing, leading to deploying default or wrong settings.
The default chart files may not match your app's needs, causing deployment errors or misconfiguration.
Edit Chart.yaml and template files to match your app's requirements before running 'helm install'.
Forgetting to uninstall old releases before reinstalling, causing conflicts.
Helm will not install a release with the same name twice without uninstalling or upgrading, leading to errors.
Use 'helm uninstall my-app' to remove old releases before fresh installs or use 'helm upgrade' to update.
Summary
Use 'helm create my-app' to generate a new Helm chart with default files.
Customize the Chart.yaml and templates to fit your app's deployment needs.
Deploy your app with 'helm install my-app ./my-app' and verify with 'helm list'.
Remove your app deployment cleanly with 'helm uninstall my-app' when needed.