2 - Connectors and Providers Setup

Updated 2 weeks ago by Michael Cretzman

In this section, we will add a Harness Artifact Server and Cloud Provider to your account.

Permissions

You connect Docker registries and Kubernetes clusters with Harness using the accounts you have with those providers. The following list covers the permissions required for the Docker and Kubernetes components.

  • Docker:
    • Read permissions for the Docker repository - The Docker registry you use as an Artifact Server in Harness must have Read permissions for the Docker repository.
    • List images and tags, and pull images - The user account you use to connect the Docker registry must be able to perform the following operations in the registry: List images and tags, and pull images. If you have a Docker Hub account, you can access the NGINX Docker image we use in this guide.
  • Kubernetes Cluster:
    • Please see Add Cloud Providers to see the permissions required for your Kubernetes cluster or Cloud Platform. For a cluster or provider such as OpenShift, please see Kubernetes Cluster.

For a list of all of the permissions and network requirements for connecting Harness to providers, see Delegate Connection Requirements.

Add the Artifact Server

For this guide, we will use a publicly-available Docker image of NGINX. Harness supports all of the common artifact servers. You can learn about the different Artifact Servers in Add Artifact Servers.

Docker Artifact Server

You can add a Docker repository, such as Docker Hub, as an Artifact Server in Harness. Then, when you create a Harness service, you specify the Artifact Server and artifact(s) to use for deployment.

For this guide, we will be using a publicly available Docker image of NGINX, hosted on Docker Hub at hub.docker.com/_/nginx/. You will need to set up or use an existing Docker Hub account to use Docker Hub as a Harness Artifact Server. To set up a free account with Docker Hub, see Docker Hub.

To specify a Docker repository as an Artifact Server, do the following:

  1. In Harness, click Setup.
  2. Click Connectors. The Connectors page appears.
  3. Click Artifact Servers, and then click Add Artifact Server. The Artifact Servers dialog appears.
  4. In Type, click Docker Registry. The dialog changes for the Docker Registry account.
  5. In Docker Registry URL, enter the URL for the Docker Registry (for Docker Hub, https://registry.hub.docker.com/v2/).
  6. Enter a username and password for the provider (for example, your Docker Hub account).
  7. Click SUBMIT. The artifact server is displayed.

Docker Registry Across Multiple Projects

In this document, we perform a simple set up using Docker Registry. Another common artifact server for Kubernetes deployments is GCR (Google Container Registry), also supported by Harness.

An important note about using GCR is that if your GCR and target GKE Kubernetes cluster are in different GCP projects, Kubernetes might not have permission to pull images from the GCR project. For information on using a single GCR Docker registry across projects, see Using single Docker repository with multiple GKE projects from Medium and the Granting users and other projects access to a registry section from Configuring access control by Google.

Add the Cloud Provider

For a Cloud Provider in Harness, you can specify a Kubernetes cluster or a Kubernetes-supporting Cloud platform, such as Google Cloud Platform (GCP) and OpenShift, and then define the deployment environment for Harness to use.

For this guide, we will use a simple connection to the Kubernetes cluster that uses the same credentials as the Harness Delegate installed in the same cluster.

If you do not have a Kubernetes cluster, the default configuration for a Kubernetes cluster in GCP will provide you with what you need for this guide. For information on setting up a Kubernetes cluster on GCP, see Creating a Cluster from Google.

The specs for the Kubernetes cluster you create will depend on the microservices or apps you will deploy to it. To give you guidance on the specs for the Kubernetes cluster machines, here is the node pool created for a Kubernetes cluster in GCP:

For Harness deployments, a Kubernetes cluster requires the following:

  • Credentials for the Kubernetes cluster in order to add it as a Cloud Provider. The simplest method is to use the same credentials as the Harness Delegate installed in the cluster. If you set up GCP as a cloud provider using a GCP user account, that account should also be able to configure the Kubernetes cluster on the cloud provider.
  • The kubectl command-line tool must be configured to communicate with your cluster.
  • A kubeconfig file for the cluster. The kubeconfig file configures access to a cluster. It does not need to be named kubeconfig.

For more information, see Accessing Clusters and Configure Access to Multiple Clusters from Kubernetes.

Kubernetes Cloud Provider

To set up a Kubernetes Cloud platform or cluster as a Harness Cloud Provider, do the following:

  1. In Harness, click Setup.
  2. Click Cloud Providers.
  3. Click Add Cloud Provider. The Cloud Provider dialog opens.
    In this example, we will add a Kubernetes Cluster Cloud Provider, but there are several other provider options. In some cases, you will need to provide access keys in order for the delegate to connect to the provider.
  4. In Type, select Kubernetes Cluster.
  5. In Display Name, enter a name for the Cloud Provider.
  6. Click the option Inherit Cluster Details from selected Delegate to use the credentials of the Delegate you installed in your cluster.
  7. In Delegate Name, select the name of the Delegate installed in your cluster. When you are done, the dialog will look something like this:
  8. Click SUBMIT. The Kubernetes Cluster Cloud Provider is added.


How did we do?