2 - Connectors and Providers Setup
In this topic, we will add a Harness Artifact Server and Cloud Provider to your account.
- Add the Artifact Server
- Add the Cloud Provider
- Next Steps
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.
- 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:
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:
- In Harness, click Setup.
- Click Connectors. The Connectors page appears.
- Click Artifact Servers, and then click Add Artifact Server. The Artifact Servers dialog appears.
- In Type, click Docker Registry. The dialog changes for the Docker Registry account.
- In Docker Registry URL, enter the URL for the Docker Registry (for Docker Hub, https://registry.hub.docker.com/v2/).
- Enter a username and password for the provider (for example, your Docker Hub account).
- Click SUBMIT. The artifact server is displayed.
Docker Registry Across Multiple Projects
In this document, we perform a simple setup 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.
Kubernetes Cloud Provider
To set up a Kubernetes Cloud platform or cluster as a Harness Cloud Provider, do the following:
- In Harness, click Setup.
- Click Cloud Providers.
- 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.
- In Type, select Kubernetes Cluster.
- In Display Name, enter a name for the Cloud Provider.
- Click the option Inherit Cluster Details from selected Delegate to use the credentials of the Delegate you installed in your cluster.
- In Delegate Name, select the name of the Delegate installed in your cluster. When you are done, the dialog will look something like this:
- Click SUBMIT. The Kubernetes Cluster Cloud Provider is added.