Install the Harness Kubernetes Delegate

Updated 1 month ago by Michael Cretzman

The Harness Delegate is a service you run in your deployment target environment, such as your local network, VPC, or cluster. The Delegate connects all of your artifact, infrastructure, collaboration, verification and other providers with the Harness Manager.

Most importantly, the Delegate performs all deployment operations.

There are several types of Delegates. This topic describes how to install the Kubernetes Delegate.

If you want to run multiple Delegates on the same or different clusters, see Automate Harness Kubernetes Delegate Setup.

In this topic:

Before You Begin

Visual Summary

The following diagram shows how the Delegate enables Harness to integrate with all of your deployment resources:

Step 1: Download the Kubernetes Delegate

  1. Log into Harness.
  2. In the Harness Manager, click Setup, and then click Harness Delegates.
  3. In the Delegate tab, click Install Delegate.
  4. In Download Type, select Kubernetes YAML.
  5. In Name, enter a name for your Delegate.
  6. In Profile, select a Delegate Profile. See Run Scripts on the Delegate using Profiles.
A Delegate Profile is mandatory. The Primary Profile is the default and contains no script. You can add a script to it, or create and apply new Profiles for your Delegate.
  1. Click Download or Copy Download Link.

Step 2: Apply the Delegate Spec

  1. Ensure the host where you run the Delegate meets the Delegate Requirements and Limitations.
  2. Open a terminal and navigate to where the Delegate file is located.
  3. If you downloaded the Delegate, extract the YAML file's folder from the download and then navigate to the harness-delegate-kubernetes folder that you extracted:
tar -zxvf harness-delegate-kubernetes.tar.gz

cd harness-delegate-kubernetes

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

  1. Log into your Kubernetes cluster.
  2. Let's quickly confirm that the cluster you created can connect to the Harness platform. Enter the following command:
    wget -p https://app.harness.io/ -O /dev/null
    A successful connection will display the following:
    HTTP request sent, awaiting response... 200 OK
  3. 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
    If you are not using your terminal to connect to your cluster, just copy the harness-delegate.yaml file to the cluster and run the command.
  4. Run this command to verify that the Delegate pod was created:
    kubectl get pods -n harness-delegate
    It will take a moment for the Delegate to appear in Harness Delegates page.

The Delegates page provides a list of installed Delegates. The information displayed includes:

  • Hostname.
  • IP Address.
  • Status.
  • Last heartbeat. This is the last time the Delegate communicated with the Harness Manager. The Delegate pings the Manager once per minute.
  • Available Versions
  • Selectors
  • Profiles
  • Scopes

Now you're ready to connect Harness to your artifact servers, clusters, and so on.

When you onboard your own applications, you might need to install multiple Delegates, depending on their workloads, network segmentation, and firewall zones. Typically, you will need one Delegate for every 300-500 service instances across your applications, and will need one Delegate in each subnet or zone.

Installation Example: Google Cloud Platform

The following steps describe how to install the Kubernetes Delegate in a Kubernetes cluster in Google Cloud Platform. The steps assume you have Google Cloud SDK installed, as it is used to execute gcloud command-line commands. For more information on installing the Google Cloud SDK, see Install the Latest Cloud SDK version from Google.

A Kubernetes cluster in Google Cloud Platform has a variety of settings that are different from other vendors. For example, when creating your cluster in Google Cloud Platform, you might need to add more or less CPUs or RAM to your nodes than you would with another cloud vendor or an Internal cluster.
  1. Sign up for a free tier Google Cloud Platform account.
  2. In Google Cloud Platform, create a Kubernetes cluster.
    1. In Kubernetes Engine, click CREATE CLUSTER.
    2. Choose the Standard cluster template.
    3. Customize the template:
      Name: Enter the name for the cluster.
      Location type: Select Zonal for this example.
      Zone: Select the default Compute Engine compute zone, as the location type is Zonal.
    4. For Node pools, do the following:
      Number of nodes: Enter 3 nodes.
      Machine type: Enter 4vCPU, and click Customize. In Memory, enter 12GB. 8GB is for the Delegate. The remaining memory is for Kubernetes.
    5. Click the Advanced edit button.
    6. In the Edit node pool panel, below Size, click Enable autoscaling.
    7. Enter a Minimum of 3 and a Maximum of 8.
      When you are done, your setting will look something like this:
    8. Click Save.
    9. Click Create to create the cluster. It will take a few minutes to create the Kubernetes cluster.
  3. When the cluster is created, click the Connect button.
  4. In the Connect to the cluster dialog, copy the Command-line access command.
  5. On your local machine, open a Terminal, and paste the command, and press Enter. You are now connected to the Kubernetes cluster.

    By default, your cluster should be able to connect to the Internet. If you run into errors, ensure the GCE firewall isn’t blocking port 22 to your VMs. For more information, see SSH troubleshooting from Kubernetes.
    1. Let's quickly confirm that the cluster you created can connect to the Harness platform. Enter the following command:

      wget -p https://app.harness.io/ -O /dev/null
      A successful connection will display the following output:
      Resolving app.harness.io (app.harness.io)... 35.197.53.196
      Connecting to app.harness.io (app.harness.io)|35.197.53.196|:443... connected.
      HTTP request sent, awaiting response... 200 OK
  6. Download the Kubernetes Delegate from Harness as described above.
  7. Install the Delegate in your cluster,
    1. In the Terminal you used to connect to the Kubernetes cluster, navigate to the folder where you downloaded the Harness Delegate YAML file.
      For example, cd ~/Downloads.
    2. Extract the YAML file: tar -zxvf harness-delegate-kubernetes.tar.gz.
    3. Navigate to the harness-delegate folder that was created:
      cd harness-delegate-kubernetes
    4. Paste the following installation command into the Terminal and press enter:
      kubectl apply -f harness-delegate.yaml
      You will see the following output (this delegate is named k8s-test):
      namespace/harness-delegate created
      clusterrolebinding.rbac.authorization.k8s.io/harness-delegate-cluster-admin created
      statefulset.apps/k8s-test-vutpmk created
    5. Run this command to verify that the Delegate pod was created:
      kubectl get pods -n harness-delegate

      You will see output with the status Pending. The Pending status simply means that the cluster is still loading the pod.
  8. Wait a few moments for the cluster to finish loading the pod and for the Delegate to connect to Harness Manager.
  9. In Harness Manager, in the Harness Delegates page, the new Delegate will appear. You can refresh the page if you like.
StatefulSets is used for the the Kubernetes Delegate to ensure the same pod name is used each time a pod is scheduled.

You can also open a shell session to a Delegate pod using the following command:

kubectl exec -n harness-delegate <pod_name> -it -- /bin/bash

See Also


How did we do?