Using Helm Chart

Tram Ho

Setting:

#Bash Complete for helm

P1: Getting to know Helm Chart

1.1 Download helm chart from ArtifactHub

https://artifacthub.io/ contains a lot of helm shared from the community.

1.2 Run helm chart

1.3 Test Chart

We have 3 ways to check if the helm config is correct:

1.4 Show chart information on ArtifactHub

1.5 List which charts are running

P2: Create your own Helm Chart

2.1 Create a self-chart

2.2 Upgrade Chart

If the yaml Chart has an update (eg add a variable in the configmap, change the image deployment), we run the following:

2.3 Rollback Chart

P3: .Values ​​/ .Chart

To prepare for the tests from part 3, 4… onwards, we delete the following folders

Example1: Load parameter .Values ​​from values.yaml

B1: Prepare values.yaml

Step 2: Edit deployment.yaml

B3: Result

Replicas were overwritten from 2 to 5 when running helm template (or install/upgrade)

Example2: Load parameter .Chart from Chart.yaml

B1: values.yaml

Step 2: Edit deployment.yaml

B3: Result

In addition, we also have some Values, chart build-ins available or used:

P4: Function and Pipeline

The helm functions can be found here:https://helm.sh/docs/chart_template_guide/function_list/#string-functions

VD1: Function

B1: Edit values.yaml and Chart.yaml files

Step 2: Edit deployment.yaml. Apply function: upper, title, replace, camelcase…

B3: Result

VD2: Pipeline

Pipeline has the same result as function, we can see the example below about upper, title, replace, camelcase…

Result:

Part 5: IF

Function: (1) compare, (2) If exist will print out

Example1: Check existence by if

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

Example2: Comparative examples of IF

P6: With

Function:

  • Used to shorten Chart.
  • Check exists, if yes, insert., if not, delete (like IF).
  • Used to load a list of strings into Chart.

Example1: Shorten Chart

B1: File values.yaml

B2: File configmap.yaml when not edited

B3: Edit configmap.yaml to shorten “.Values.app.” put in with

B4: Result

Example2: check if exists, insert., if not, delete (same as IF)

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

P7: Range (for i)

Range is almost like with for loading values, but used for array values. You can see the following example

Example1: Range is used to fill array list

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

Example2: Range with multi values

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

Example3: Range without $val

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

P8: Include/Template

B1: File _helper.tpl

B2: In deployment.yaml call include

B3: Result

P9: Print function

B1: File values.yaml

Step 2: Edit configmap.yaml

B3: Result

P10: Default

B1: File values.yaml

Step 2: Edit deployment.yaml

B3: Result

P11: Push Helm Chart to ArtifactHub or Local registry

(updating…)

The article is within the knowledge of the writer, maybe you have a better idea, please guide. Thanks!

Share the news now

Source : Viblo