Helm chart deployments
This quickstart shows you how to deploy a publicly available Docker image to your Kubernetes cluster using Helm charts and a Rolling deployment strategy in Harness.
All you'll need is a small target cluster to run the Harness Delegate and receive the deployed image.
This quickstart should only take about 15 minutes.
Objectives
You'll learn how to:
- Install and launch a Harness Kubernetes Delegate in your target cluster.
- Set up a Helm Pipeline.
- Run the new Helm Pipeline and deploy a Docker image to your target cluster.
Before you begin
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.
You will need a target Kubernetes cluster where you will deploy NGINX:
Set up your Kubernetes clusterYou'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.
- A Kubernetes service account with permission to create entities in the target namespace is required. The set of permissions should include
list
,get
,create
, anddelete
permissions. In general, the cluster-admin permission or namespace admin permission is enough.
For more information, see User-Facing Roles from Kubernetes.
Visual summary
Here's a quick walkthrough of creating a Helm deployment Pipeline in Harness:
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 Helm Quickstart and click Start. Your Pipeline appears.
Click Add Stage and select Deploy.
Enter the name Deploy Service, make sure Service is selected, and then click Set Up Stage. The new stage settings appear.
In About the Service, click New Service.
noteLet'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 nginx 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 Kubernetes.
Next, we'll add the NGINX Helm chart for the deployment.
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.
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.
In Connect to the provider, select Connect through a Harness Delegate, and then select Continue. We don't recommend using the Connect through Harness Platform option here because you'll need a delegate later for connecting to your target cluster. Typically, the Connect through Harness Platform option is a quick way to make connections without having to use delegates.
Expand the section below to learn more about installing delegates.
Install a new delegate
In Delegates Setup, select Install new Delegate. The delegate wizard appears.
In the New Delegate dialog, in Select where you want to install your Delegate, select Kubernetes.
In Install your Delegate, select Kubernetes Manifest.
Enter a delegate name.
- Delegate names must be unique within a namespace and should be unique in your cluster.
- A valid name includes only lowercase letters and does not start or end with a number.
- The dash character (“-”) can be used as a separator between letters.
At a terminal, run the following cURL command to copy the Kuberntes YAML file to the target location for installation.
curl -LO https://raw.githubusercontent.com/harness/delegate-kubernetes-manifest/main/harness-delegate.yaml
Open the
harness-delegate.yaml
file. Find and specify the following placeholder values as described.Value Description PUT_YOUR_DELEGATE_NAME
Name of the delegate. PUT_YOUR_ACCOUNT_ID
Harness account ID. PUT_YOUR_MANAGER_ENDPOINT
URL of your cluster. See the following table of Harness clusters and endpoints. PUT_YOUR_DELEGATE_TOKEN
Delegate token. To find it, go to Account Settings > Account Resources, select Delegate, and select Tokens. For more information on how to add your delegate token to the harness-delegate.yaml file, go to Secure delegates with tokens. Your Harness manager endpoint depends on your Harness SaaS cluster location. Use the following table to find the Harness manager endpoint in your Harness SaaS cluster.
Harness cluster location Harness Manager endpoint SaaS prod-1 https://app.harness.io SaaS prod-2 https://app.harness.io/gratis SaaS prod-3 https://app3.harness.io Install the delegate by running the following command:
kubectl apply -f harness-delegate.yaml
The successful output looks like this.
namespace/harness-delegate-ng unchanged
clusterrolebinding.rbac.authorization.k8s.io/harness-delegate-cluster-admin unchanged
secret/cd-doc-delegate-account-token created
deployment.apps/cd-doc-delegate created
service/delegate-service configured
role.rbac.authorization.k8s.io/upgrader-cronjob unchanged
rolebinding.rbac.authorization.k8s.io/upgrader-cronjob configured
serviceaccount/upgrader-cronjob-sa unchanged
secret/cd-doc-delegate-upgrader-token created
configmap/cd-doc-delegate-upgrader-config created
cronjob.batch/cd-doc-delegate-upgrader-job createdSelect Verify to make sure that the delegate is installed properly.
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: leave this empty.
- Helm Version: select Version 3.
The Helm chart is added to the Service Definition.
Next, we can target your Kubernetes cluster for deployment.
Define your target cluster
- In Infrastructure, in Environment, click New Environment.
- In Name, enter quickstart, 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.
Add a Rollout Deployment step
We're going to use a Rolling deployment strategy, so click Rolling, and click Apply.
The Rollout Deployment step is added to Execution.
That's it. Now you're ready to deploy.
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 Rollout Deployment step and expand Wait for Steady State.
You can see Status : quickstart-nginx deployment "quickstart-nginx" successfully rolled out.
Congratulations! The deployment was successful.
In your Project's Deployments, you can see the deployment listed.
If you run into any errors, it is typically because the cluster does meet the requirements from Before You Begin or the cluster's network settings do not allow the Delegate to connect to the chart or image repos.
In this quickstart, you learned how to:
- Install and launch a Harness Kubernetes Delegate in your target cluster.
- Set up a Helm Pipeline.
- Run the new Helm Pipeline and deploy a Docker image to your target cluster.
Next steps
- See CD tutorials for other deployment features.
- Trigger Pipelines on New Helm Chart.