Helm Chart: Create And Upload a Helm Chart On Artifact Servers

Piyush Panchariya
6 min readSep 20, 2021

--

Introduction

Helm charts are one of the best practices for building efficient clusters in Kubernetes. It is a form of packaging that uses a collection of Kubernetes resources. Helm charts use those resources to define an application.

Helm charts use a template approach to deploy applications. Templates give structure to projects and are suitable for any type of application.

This article provides step-by-step instructions to create and deploy a Helm chart.

Prerequisites

Note: To confirm Helm installed properly, run which helm in the terminal. The output should return a path to Helm.

Create Helm Chart

Creating a Helm chart involves creating the chart itself, configuring the image pull policy, and specifying additional details in the values.yaml file.

Step 1: Create a New Helm Chart

1. To create a new Helm chart, use:

helm create <chart name>

For example:

helm create phoenixnap

2. Using the ls command, list the chart structure:

ls <chart name>

The Helm chart directory contains:

  • Directory charts — Used for adding dependent charts. Empty by default.
  • Directory templates — Configuration files that deploy in the cluster.
  • YAML file — Outline of the Helm chart structure.
  • YAML file — Formatting information for configuring the chart.

Step 2: Configure Helm Chart Image Pull Policy

1. Open the values.yaml file in a text editor. Locate the image values:

There are three possible values for the pullPolicy:

  • IfNotPresent – Downloads a new version of the image if one does not exist in the cluster.
  • Always – Pulls the image on every restart or deployment.
  • Latest – Pulls the most up-to-date version available.

2. Change the image pullPolicy from IfNotPresent to Always:

Step 3: Helm Chart Name Override

To override the chart name in the values.yaml file, add values to the nameOverride and fullnameOverride:

For example:

Overriding the Helm chart name ensures configuration files also change.

Step 4: Specify Service Account Name

The service account name for the Helm chart generates when you run the cluster. However, it is good practice to set it manually.

The service account name makes sure the application is directly associated with a controlled user in the chart.

1. Locate the serviceAccount value in the values.yaml file:

2. Specify the name of the service account:

Step 5: Change Networking Service Type

The recommended networking service type for Minikube is NodePort.

1. To change the networking service type, locate the service value:

2. Change the type from ClusterIP to NodePort:

Deploy Helm Chart

After configuring the values.yaml file, check the status of your Minikube cluster and deploy the application using Helm commands.

Step 1: Check minikube Status

If Minikube isn’t running, the install Helm chart step returns an error.

1. Check Minikube status with:

minikube status

The status shows up as Running.

2. If the status shows Stopped, run:

minikube start

The output shows Done and the status changes to Running.

Step 2: Install the Helm Chart

Install the Helm chart using the helm install command:

helm install <full name override> <chart name>/ --values <chart name>/values.yaml

For example:

helm install phoenix-chart phoenixnap/ --values phoenixnap/values.yaml

The helm install command deploys the app. The next steps are printed in the NOTES section of the output.

Step 3: Export the Pod Node Port and IP Address

1. Copy the two export commands from the helm install output.

2. Run the commands to get the Pod node port and IP address:

Step 4: View the Deployed Application

1. Copy and paste the echo command and run it in the terminal to print the IP address and port:

2. Copy the link and paste it into your browser, or press CTRL+click to view the deployed application:

Note: Learn how to delete a Helm deployment and namespace to get rid of unwanted or multiple copies of Helm deployments.

Add Helm Repository Artifact Servers

You can add a Helm Chart Repository as an Artifact Server and then use it in Harness Kubernetes and Helm Services. See Kubernetes Deployments and Helm Deployments.

A Helm chart repository is an HTTP server that houses an index.yaml file and, if needed, packaged charts. For details, see The Chart Repository Guide from Helm.

From Helm:

Note: For Helm 2.0.0, chart repositories do not have any intrinsic authentication. There is an issue tracking progress in GitHub.

Because a chart repository can be any HTTP server that can serve YAML and tar files and can answer GET requests, you have a plethora of options when it comes down to hosting your own chart repository. For example, you can use a Google Cloud Storage (GCS) bucket, Amazon S3 bucket, Github Pages, or even create your own web server.

In this topic:

Before You Begin

Visual Summary

Here’s an example of Helm Repository Artifact Source configuration.

The Helm Repository dialog has the following fields.

Step 1: Select Helm Repository

To connect to an artifact server, do the following:

  1. Click Setup.
  2. Click Connectors.
  3. Click Artifact Servers.
  4. Click Add Artifact Server.
  5. In Type, click Helm Repository.

Step 2: Display Name

This is the name you will use to select this Artifact Server in you Kubernetes and Helm Services.

Step 3: Hosting Platform

The type of server where the repo is hosted.

Step 4: Repository URL

The URL of the chart repo.

Helm Hub at https://hub.helm.sh is not a Helm repo. It is a website for discovery and documentation. While it does list charts for deployments such cluster-autoscaler, the actual Helm repo for this and most charts is https://kubernetes-charts.storage.googleapis.com.

Step 5: Username and Password

If the charts are backed by HTTP basic authentication, you can also supply the username and password. See Share your charts with others from Helm.

For Amazon S3 and GCS, the Base Path setting has moved to the Harness Service Chart Specification settings.

For secrets and other sensitive settings, select or create a new Harness Encrypted Text secret.

Usage Scope is determined by the secret you selected.

Click Submit.

Source: phoenixnap.com,docs.harness.io

--

--