Skip to main content

kubernetes-quickstart

Last updated on

Before You Start

Cluster, Delegate, and Metrics Server Requirements

Kubernetes cluster requirements

You need a target Kubernetes cluster for the Harness Delegate and deployment. Make sure 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.
  • Kubernetes service account with permission to create entities in the target namespace is required. The set of permissions should include list, get, create, and delete permissions. In general, the cluster-admin permission or namespace admin permission is enough. For more information, see User-Facing Roles from Kubernetes.
warning

You must not rename the cluster. If you're setting up a new connector with this cluster, it is identified by the clustername. Renaming the cluster results in duplicate entries in the dashboard.

Delegate size requirements

Your Kubernetes cluster must have unallocated resources required to run the Harness Delegate workload.

Baseline Configuration: For clusters with up to 200 nodes and 4000 pods, each delegate should be configured with:

  • 2 vCPUs
  • 8 GB of memory

Incremental Scaling: For every additional 50 nodes and 1000 pods, the delegate capacity should be increased by 0.5 vCPUs and 2 GB of memory This scaling ensures that the delegate can handle the increased load and continue to collect metrics efficiently.

Single replica requirement:

  • All specified resource requirements pertain to a single replica of the delegate.
  • Instead of utilizing Horizontal Pod Autoscaler (HPA) to increase the number of smaller-sized replicas Harness recommends provisioning each delegate with the necessary resources to handle the specified number of nodes and pods.
warning
  • These sizing requirements are for the Delegate only. Your cluster will require more memory for Kubernetes, the operating system, and other services. Ensure that the cluster has enough memory, storage, and CPU for all of its resource consumers.
  • We recommend using one delegate per cluster and Large size delegates for production clusters for optimal performance.

Metrics server requirements

Metrics Server must be running on the Kubernetes cluster where your Harness Kubernetes Delegate is installed. Before enabling CCM for Kubernetes, you must make sure the utilization data for pods and nodes is available.

The Metrics Server is a cluster-wide aggregator of resource usage data. It collects resource metrics from kubelets and exposes them in the Kubernetes API server through Metrics API. CCM polls the utilization data every minute on the Delegate. The metrics are aggregated for 20 minutes and then CCM keeps one data point per 20 minutes. For more information, see Installing the Kubernetes Metrics Server from AWS.

Metrics Server is installed by default on GKE and AKS clusters; however, you need to install it on the AWS EKS cluster.

To install the metrics server on your EKS clusters, run the following command:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml

Resources can be adjusted proportionally based on number of nodes in the cluster.

For clusters exceeding 100 nodes, allocate the following additional resources:

  • 1m core per node
  • 2MiB memory per node

Install delegate

Install a Harness Kubernetes delegate in the cluster.

Delegate permission requirements

You can choose one of the following permissions for the delegate for CCM:

  • Install Delegate with cluster-wide read/write access: Creates a new namespace called "harness-delegate-ng" with the service account bound to Cluster Admin role. This Delegate will be able to read tasks (capture change events etc., needed for Harness Cloud Cost Management) anywhere on the K8s cluster where the Delegate is installed.
  • Install Delegate with cluster-wide read access: (Requires read-only Cluster Admin role) Creates a new namespace called "harness-delegate-ng" with the service account bound to Cluster Admin role. This Delegate will be able to perform read-only tasks (capture change events etc., needed for Harness Cloud Cost Management) anywhere on the K8s cluster where the Delegate is installed.

Delegate role requirements for CCM visibility features and recommendations:

The YAML provided for the Harness Delegate defaults to the cluster-admin role. If you can't use cluster-admin because you are using a cluster in your company, you'll need to edit the delegate YAML to include the role below. If you deployed your delegate with Helm, you can also set the value ccm.visibility: true to have this role and binding created.

Delegate ClusterRole YAML
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ce-clusterrole
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- nodes/proxy
- events
- namespaces
- persistentvolumes
- persistentvolumeclaims
verbs:
- get
- list
- watch
- apiGroups:
- apps
- extensions
resources:
- statefulsets
- deployments
- daemonsets
- replicasets
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- get
- list
- watch
- apiGroups:
- metrics.k8s.io
resources:
- pods
- nodes
verbs:
- get
- list
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch

Quick Create Method

info

The following entities are created in this process:

  • A Kubernetes delegate of medium size with cluster admin permissions.
  • A Kubernetes connector which can also be used for other Harness modules such as CI, CD, and so on.
  • Cost Visibility is enabled on this Kubernetes connector.

Step-by-Step Guide

Step 1: Overview

  1. Launch the wizard and select Kubernetes as the cloud provider. Click on Quick Create.
  2. Enter a name for your connector. Please note, this is the name with which the Kubernetes Cluster will be identified in Harness Cloud Cost Management. Also you need to have Cluster Admin Role to the Cluster you would like to add
  3. Click Continue.

Step 2: Download and Apply YAML

To grant Harness the required cluster permissions, apply the delegate YAML.

What this YAML does

  • Creates a Harness Delegate.
  • Grants the Delegate the cluster-admin role.

How to apply

  1. In the wizard, click Download YAML (you can preview the file).
  2. Run the following command:
kubectl apply -f harness-delegate.yml
  1. After the command succeeds, return to the wizard and click Continue. Harness will create a Kubernetes Connector.
note

For Amazon EKS clusters, make sure the Kubernetes Metrics Server is installed in the cluster where the Harness Delegate runs.


Step 3: Create and Test Connection

After the successful creation of delegate and the connectors, and verification of permissions, select Finish. The connector is now listed in the Kubernetes clusters table.


🎉 You’ve now connected your Kubernetes cluster and enabled cost visibility in Harness.


Next Steps

Explore these features to enhance your cloud cost management:

Turn visibility into action and unlock cost efficiency across your Azure cloud infrastructure.


FAQs

Details

How can we report on which connectors are stale? If clusters are decommissioned, no heartbeat will be received from the delegate, and this will be reflected directly on the connector. On the Cloud Integration page, the Reporting tab shows whether events are being received. If events are not being received, the status will appear in red, indicating a stale connector.