Harness supports Kustomize kustomizations in your Kubernetes deployments. You can use overlays, multibase, plugins, sealed secrets, etc, just as you would in any native kustomization.
This Kustomize quickstart will deploy multiple variants of a simple public Hello World server using a rolling update strategy in Harness.
You'll learn how to:
- Install and launch a Harness Kubernetes Delegate in your target cluster.
- Set up a Kustomize Pipeline.
- Run the new Kustomize Pipeline and deploy an NGINX Docker image to your target cluster.
Before You Begin
Make sure you have the following set up before you begin this quickstart:
- GitHub account: this quickstart uses a publicly available kustomization and Docker image. DockerHub allows anonymous connections, but GitHub requires that you log into your account to access their repos.
Set up your Kubernetes Cluster
You'll need a target Kubernetes cluster for the Harness Delegate and deployment. Ensure your cluster meets the following requirements:
- Number of nodes: 2.
- vCPUs, Memory, Disk Size: 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
deletepermissions. 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.
In your Harness Project, click Deployments, and then click Create a Pipeline.
Enter the name Kustomize Quickstart and click Start.
Your Pipeline appears.
Click Add Stage and select Deploy.
Enter the name Kustomize, make sure Service is selected, and then click Set Up Stage.
The new stage settings appear.
In About the Service, click New Service.
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.
Step 2: Add the Kustomization
Now we can connect Harness to the repo containing the kustomization. We'll use a publicly available hellword kustomization cloned from Kustomize.
All connections and operations are performed by Harness Delegates. So we'll also add a Harness Delegate to your target cluster. We can add the Delegate inline as part of adding the kustomization files.
In Service Definition, in Deployment Type, click Kubernetes.
In Manifests, click Add Manifest.
image: <+artifact.image>). See Add Container Images as Artifacts for Kubernetes Deployments.
In Specify Manifest Type, click Kustomize, and click Continue.
In Specify Kustomize Store, select GitHub.
Click New GitHub Connector.
The Git Connector settings appear. Enter the following settings.
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.
In Delegate Configurations, select Primary Configuration. This is simply a default. In the future, you can add Delegate Configuration to run scripts on your Delegates and scope them to different Environments.
Click Download Script. 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
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.
In Manifest Details, enter the following settings, test the connection, and click Submit. We are going to provide connection and path information for a manifest located at
This is the path from the repo root.
The kustomization is now listed.
Click Next at the bottom of the Service tab.
Now that the kustomization is defined, you can define the target cluster for your deployment.
Step 3: Define Your Target Cluster
The target cluster is your own Kubernetes cluster, hosted in your cloud environment. This is where we will deploy the kustomization and its Docker image.
In Infrastructure Details, in Specify your environment, click New Environment. Just like with a Service, you can create a new Environment or selecting an existing one. We'll create a new one.
In New Environment, enter a name, select Non-Production, and click Save. The new Environment appears.
In Infrastructure Definition, click Kubernetes.
By separating Environments and Infrastructure Definitions, you can use the same Environment in multiple stages while changing the target infrastructure settings with each stage.
An Infrastructure Definition is where you specify the target for your deployment. In this case, your Kubernetes cluster and namespace.
In Cluster details, in Connector, click Select a connector.
Click New Connector.
The Kubernetes Cluster Connector appears.
The Kubernetes Cluster Connector is covered in detail here, but let's quickly walk through it.
Let's look at the steps:
In Kubernetes Cluster Connector, in Name, enter Kustomize Quickstart, and click Continue.
In Details, select Use the credentials of a specific Harness Delegate. We will select the Delegate next.
Select the Kubernetes Delegate you added earlier using its Tags, and then click Save and Continue.
Harness verifies the Connector.
Select the new Connector and then click Apply Selected.
Back in Cluster Details, in Namespace, enter the target namespace for the deployment. For example, default. You can use any namespace in your target cluster.
When you are done, Cluster Details will look something like this:
The target infrastructure is complete. Now we can add our stage steps.
Step 4: Add a Rollout Deployment Step
When you click Next the deployment strategy options are provided:
Click Rolling, and then click Apply.
The Rollout Deployment step is added. There's nothing to set up. Harness will perform a Kubernetes rolling update in your target cluster automatically.
Step 5: Deploy and Review
Click Save and then Run.
Click Run Pipeline. Harness will verify the Pipeline and Connectors and then run the Pipeline.
There are no artifacts to select because the NGINX artifact is hardcoded in the kustomization.
You can see the status of the deployment, and pause or abort it.
Click the Rollout Deployment step.
Expand Fetch Files to see Harness fetch the repo, including the kustomization files.
In Initialize you can see the manifest rendered using the kustomization and then validated with a
kubectl dry run.
Expand Wait for Steady State. You will the pods reach steady state:
Status : "the-deployment" successfully rolled out
Congratulations! The deployment was successful.
In your Project's Deployments, you can see the deployment listed:
In this tutorial, you learned how to:
- Install and launch a Harness Kubernetes Delegate in your target cluster.
- Connect Harness to your Kubernetes cluster and Git provider.
- Add your kustomization files to Harness.
- Create an Infrastructure Definition that targets your cluster and namespace.
- Add a Kubernetes rolling update.
- Deploy your Kustomize Pipeline to your target cluster.
Next, try the following quickstarts:
- Kubernetes CD Quickstart
- Helm CD Quickstart
- Harness Continuous Integration to build a codebase, upload it to a repo, and run unit and integrations tests: CI Pipeline Quickstart.
To delete the Harness Delegate from your Kubernetes cluster, you delete the StatefulSet for the Delegate. Once created, the StatefulSet ensures that the desired number of pods are running and available at all times. Deleting the pod without deleting the StatefulSet will result in the pod being recreated.
For example, if you have the Delegate pod name
quickstart-vutpmk-0, you can delete the StatefulSet with the following command:
$ kubectl delete statefulset -n harness-delegate quickstart-vutpmk
Note that the
-0 suffix in the pod name is removed for the StatefulSet name.