Helm Chart

Creating and deploying Helm chart on the OpenShift platform

Analyzing anatomy of Helm chart

We’ll use an example chart provided by IBM to illustrate basics of creating and installing a Helm chart into OpenShift cluster. The chart will deploy guestbook application consisting of front-end application and database back end.
  1. 1.
    Download the sample Helm chart by cloning the following github repo:
git clone https://github.com/IBM/helm101
Navigate to helm101/charts/guestbook sub-directory where we have the following directory structure: ├── Chart.yaml (1) ├── LICENSE (2) ├── README.md (3) ├── templates (4) │ ├── NOTES.txt (5) │ ├── _helpers.tpl │ ├── guestbook-deployment.yaml │ ├── guestbook-service.yaml │ ├── redis-master-deployment.yaml │ ├── redis-master-service.yaml │ ├── redis-slave-deployment.yaml │ └── redis-slave-service.yaml └── values.yaml (6) Chart.yaml (1): file containing information about the chart such as chart name and version LICENSE (2): file containing the license for the chart (optional) README.md (3): README file (optional) templates/ (4): The template directory contains templated definitions (in the form of YAML configuration files) of the various Kubernetes resources constituting your application such as definitions for creating Deployment, Route, Service and other Kubernetes resources. Other resources definitions can be added as needed. During helm install those templates are combined with values definitions in values.yaml (and any command line arguments) to generate manifest for Kubernetes resources. templates/NOTES.txt (5): file containing short usage notes (optional) values.yaml (6): The values.yaml file contains values for all the deployment parameters that need to be provided for your deployment. Values defined in this file can be referenced by their key names from any other configuration file in the template directory providing a convenient way for managing those values in a single place. During the helm deployment those values are automatically substituted into YAML configuration files. In addition values defined in the values.yaml file can be also overridden during deployment by command line options providing a further flexibility 2. Previewing Helm installation
When looking at deployment.yaml or service.yaml definitions (or any other YAML def) in the template directories you will notice parameters defined in values.yaml are references via .Values object. As mentioned before those references are resolved with actual values during helm deployment but it’s also possible to “preview” generated YAMLs before the deployment using the following option:
helm install --dry-run guestbook-release ./guestbook

Deploying Helm chart

1. Deploy guestbook helm chart Prerequisites: Working helm utility with connectivity to OpenShift cluster: Follow the “Configure CPD OpenShift Cluster Remote Access” guide in the Help section to install helm client on your local computer and set it up for access to your OpenShift cluster
helm install guestbook-release ./guestbook
2. Verify the deployment: oc get pods NAME READY STATUS RESTARTS AGE guestbook-release-d66fb5d59-97h27 1/1 Running 0 134m guestbook-release-d66fb5d59-hkl84 1/1 Running 0 134m redis-master-68857cd57c-knqv7 1/1 Running 0 134m redis-slave-bbd8d8545-8f9cj 1/1 Running 0 134m redis-slave-bbd8d8545-t52j5 1/1 Running 0 134m

Helm creation tips

1. To create a “skeleton” structure for your own helm chart use helm create <your-chart-name> this command will create folder structure along with a default set of deployment files that you will be able to adapt and customize for your application ├── Chart.yaml ├── charts ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── ingress.yaml │ ├── service.yaml │ ├── serviceaccount.yaml │ └── tests │ └── test-connection.yaml └── values.yaml You can modify, add and remove resource definitions as needed to suit your needs.
2. Deploying sample-app-chart
helm install my-release ./sample-app-chart

References: