Native Helm Quickstart

Updated 1 month ago by Michael Cretzman

Currently, this feature is behind the Feature Flag NG_NATIVE_HELM. Contact Harness Support to enable the feature.

This quickstart shows you how to perform Native Helm deployments using Harness.

Harness includes both Kubernetes and Native Helm deployments, and you can use Helm charts in both. Here's the difference:

  • Kubernetes with Helm: Harness Kubernetes deployments allow you to use your own Helm values.yaml or Helm chart (remote or local), and Harness executes the Kubernetes kubectl calls to build everything without Helm and Tiller needing to be installed in the target cluster. You can perform all deployment strategies (Rolling, Canary, Blue Green).
    See Kubernetes CD Quickstart, Helm Chart CD Quickstart.
  • Native Helm: For Harness Native Helm V2 deployments, you must always have Helm and Tiller running on one pod in your target cluster and Tiller makes the API calls to Kubernetes. You can perform a Rolling deployment strategy only (no Canary or Blue Green). For Harness Native Helm v3 deployments, you no longer need Tiller, but you are still limited to the Rolling deployment strategy.
    • Versioning: Harness Kubernetes deployments version all objects, such as ConfigMaps and Secrets. Native Helm does not.
    • Rollback: Harness Kubernetes deployments will roll back to the last successful version. Native Helm will not. If you did 2 bad Native Helm deployments, the 2nd one will just rollback to the 1st. Harness will roll back to the last successful version.
Harness supports Helm v2 and v3.

Objectives

You'll learn how to:

  • Install and launch a Harness Kubernetes Delegate in your target cluster.
  • Set up a Native Helm Pipeline.
  • Run the new Native Helm Pipeline and deploy a Docker image to your target cluster.

Before You Begin

Review Harness Key Concepts to establish a general understanding of Harness.

You will need a target Kubernetes cluster where you will deploy NGINX:

Set up your Kubernetes cluster

You'll need a target Kubernetes cluster for Harness. Ensure your cluster meets the following requirements:

  • Number of nodes: 3.
  • Machine type: 4vCPU
  • Memory: 4vCPUs, 16GB memory, 100GB disk. In GKE, the e2-standard-4 machine type is enough for this quickstart.
  • Networking: outbound HTTPS for the Harness connection to app.harness.io, github.com, and hub.docker.com. Allow TCP port 22 for SSH.
  • Kubernetes service account with permission to create entities in the target namespace is required. The set of permissions should include listgetcreate, and delete permissions. In general, the cluster-admin permission or namespace admin permission is enough.
    For more information, see User-Facing Roles from Kubernetes.

Step 1: Create the Deploy Stage

Pipelines are collections of stages. For this quickstart, we'll create a new Pipeline and add a single stage.

Create a Project for your new CD Pipeline: if you don't already have a Harness Project, create a Project for your new CD Pipeline. Ensure that you add the Continuous Delivery module to the Project. See Create Organizations and Projects.

In your Harness Project, click Deployments, and then click Create a Pipeline.

Enter the name Native Helm Example and click Start.

Your Pipeline appears.

Click Add Stage and select Deploy.

Enter the name quickstart, make sure Service is selected, and then click Set Up Stage.

The new stage settings appear.

In About the Service, click New Service.

Let's take a moment and review Harness Services and Service Definitions (which are explained below). Harness Services represent your microservices/apps logically. You can add the same Service to as many stages are you need. Service Definitions represent your artifacts, manifests, and variables physically. They are the actual files and variable values.

By separating Services and Service Definitions, you can propagate the same Service across stages while changing the artifacts, manifests, and variables with each stage.

Give the Service the name quickstart and click Save.

Once you have created a Service, it is persistent and can be used throughout the stages of this or any other Pipeline in the Project.

In Deployment Type, click Native Helm. Now your Service looks like this:

Next, we'll add the NGINX Helm chart for the deployment.

Step 2: Add the Helm Chart and Delegate

You can add a Harness Delegate inline when you configure the first setting that needs it. For example, when we add a Helm chart, we will add a Harness Connector to the HTTP server hosting the chart. This Connector uses a Delegate to verify credentials and pull charts, so we'll install the Delegate, too.

In Manifests, click Add Manifest. The manifest types appear.

You can select a Helm Values YAML file or a Helm chart. For this quickstart, we'll use a publicly available Helm chart.

The process isn't very different between these options. For Values YAML, you simply provide the Git branch and path to the Values YAML file.

Click Helm Chart and then click Continue.

In Specify Helm Chart Store, click HTTP Helm.

We're going to be pulling a Helm chart for NGINX from the Bitnami repo at https://charts.bitnami.com/bitnami. You don't need any credentials for pulling the public chart.

Click New HTTP Helm Repo Connector.

In the HTTP Helm Repo Connector, in Name, enter helm-chart-repo, and click Continue.

In Helm Repository URL, enter https://charts.bitnami.com/bitnami.

In Authentication, select Anonymous.

Click Continue.

Now we'll install and register a new Harness Delegate in your target cluster.

In Set Up Delegates, click Install new Delegate.

The Delegate wizard appears.

Click Kubernetes, and then click Continue.

Enter a name for the Delegate, like quickstart, click the Small size.

Click Continue.

Click Download YAML file. The YAML file for the Kubernetes Delegate will download to your computer as an archive.

Open a terminal and navigate to where the Delegate file is located.

You will connect to your cluster using the terminal so you can simply run the YAML file on the cluster.

In the same terminal, log into your Kubernetes cluster. In most platforms, you select the cluster, click Connect, and copy the access command.

Next, install the Harness Delegate using the harness-delegate.yaml file you just downloaded. In the terminal connected to your cluster, run this command:

kubectl apply -f harness-delegate.yaml

You can find this command in the Delegate wizard:

The successful output is something like this:

% kubectl apply -f harness-delegate.yaml
namespace/harness-delegate unchanged
clusterrolebinding.rbac.authorization.k8s.io/harness-delegate-cluster-admin unchanged
secret/k8s-quickstart-proxy unchanged
statefulset.apps/k8s-quickstart-sngxpn created
service/delegate-service unchanged

In Harness, click Verify. It will take a few minutes to verify the Delegate. Once it is verified, close the wizard.

Back in Set Up Delegates, you can select the new Delegate.

In the list of Delegates, you can see your new Delegate and its tags.

Select the Connect using Delegates with the following Tags option.

Enter the tag of the new Delegate and click Save and Continue.

When you are done, the Connector is tested. If it fails, your Delegate might not be able to connect to https://charts.bitnami.com/bitnami. Review its network connectivity and ensure it can connect.

Click Continue.

In Manifest Details, enter the following settings can click Submit.

  • Manifest Identifier: enter nginx.
  • Helm Chart Name: enter nginx.
  • Helm Chart Version: enter 8.8.1.
  • Helm Version: select Version 3.

The Helm chart is added to the Service Definition.

Next, we can target your Kubernetes cluster for deployment.

Step 3: Define Your Target Cluster

In Infrastructure, in Environment, click New Environment.

In Name, enter quickstart, select Non-Production, and click Save.

In Infrastructure Definition, select the Kubernetes.

In Cluster Details, click Select Connector. We'll create a new Kubernetes Connector to your target platform. We'll use the same Delegate you installed earlier.

Click New Connector.

Enter a name for the Connector and click Continue.

In Details, select Use the credentials of a specific Harness Delegate, and then click Continue.

In Set Up Delegates, select the Delegate you added earlier by entering one of its Tags.

Click Save and Continue. The Connector is tested. Click Finish.

Select the new Connector and click Apply Selector.

In Namespace, enter default or the namespace you want to use in the target cluster.

In Release Name, enter quickstart.

Click Next. The deployment strategy options appear.

Step 4: Add a Helm Deployment Step

We're going to use a Rolling deployment strategy, so click Rolling, and click Apply.

The Helm Deployment step is added to Execution.

That's it. Now you're ready to deploy.

Step 5: Deploy and Review

Click Save to save your Pipeline.

Click Run.

Click Run Pipeline.

Harness verifies the connections and then runs the Pipeline.

Toggle Console View to watch the deployment with more detailed logging.

Click the Helm Deployment step and expand Wait for Steady State.

You can see Status : quickstart-quickstart deployment "quickstart-quickstart" successfully rolled out.

Congratulations! The deployment was successful.

In your Project's Deployments, you can see the deployment listed.

Review: Spec Requirements for Steady State Check and Versioning

Harness requires that the release label be used in every Kubernetes spec to ensure that Harness can identify a release, check its steady state, and perform verification and rollback on it.

Ensure that the release label is in every Kubernetes object's manifest. If you omit the release label from a manifest, Harness cannot track it.

The Helm built-in Release object describes the release and allows Harness to identify each release. For this reason, the release: {{ .Release.Name }} label must be used in your Kubernetes spec.

See these Service and Deployment object examples:
{{- if .Values.env.config}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "todolist.fullname" . }}
labels:
app: {{ template "todolist.name" . }}
chart: {{ template "todolist.chart" . }}
release: "{{ .Release.Name }}"
harness.io/release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "todolist.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "todolist.name" . }}
release: {{ .Release.Name }}
harness.io/release: {{ .Release.Name }}
spec:
{{- if .Values.dockercfg}}
imagePullSecrets:
- name: {{.Values.name}}-dockercfg
{{- end}}
containers:
- name: {{ .Chart.Name }}
image: {{.Values.image}}
imagePullPolicy: {{ .Values.pullPolicy }}
{{- if or .Values.env.config .Values.env.secrets}}
envFrom:
{{- if .Values.env.config}}
- configMapRef:
name: {{.Values.name}}
{{- end}}
{{- if .Values.env.secrets}}
- secretRef:
name: {{.Values.name}}
{{- end}}
{{- end}}
...
apiVersion: v1
kind: Service
metadata:
name: {{ template "todolist.fullname" . }}
labels:
app: {{ template "todolist.name" . }}
chart: {{ template "todolist.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ template "todolist.name" . }}
release: {{ .Release.Name }}

The Release name setting in the stage Infrastructure is used as the Helm Release Name to identify and track the deployment per namespace:

Next Steps

See Kubernetes How-tos for other deployment features.


Please Provide Feedback