# Kubernetes clusters

Under Kubernetes clusters you create clusters in AWS, Azure, Google Cloud, or Open Telekom Cloud, or import an existing kubeconfig. Applications can then run as workloads on the cluster.

> Source: https://www.mainpath.ai/en/docs/kubernetes-integration/

Kubernetes distributes containers across several machines and restarts them after a failure; such a group of machines is called a cluster. Under **Kubernetes clusters** (in the left navigation, directly below **Servers**) you manage clusters once for the whole organization. In a project's **Hosting** step you can then pick a cluster alongside Docker servers and webspaces.

Cloud account credentials do not live here; they live under [Cloud accounts]({{< relref "cloud-accounts" >}}). **Manage credentials** in the top right of the cluster screen takes you there.

## Create a cluster

MainPath creates a managed cluster in the selected cloud account, including networking, nodes, and optional databases.

1. First add credentials for AWS, Azure, Google Cloud, or Open Telekom Cloud under **Cloud accounts**. How to create the keys is described under [AWS]({{< relref "aws-cloud-credentials" >}}), [Azure]({{< relref "azure-cloud-credentials" >}}), [Google Cloud]({{< relref "gcp-cloud-credentials" >}}), and [Open Telekom Cloud]({{< relref "otc-cloud-credentials" >}}).
2. Open **Kubernetes clusters** and click **Create cluster**.
3. Choose the provider, cloud account, name, region, Kubernetes version, node size, and node count.

MainPath creates the cluster in your account. It then appears in the cluster list and as a resource on the cloud account.

## Import a cluster

If you already have a cluster outside MainPath, import the access file (`kubeconfig`) that tools such as `kubectl` also use.

1. Open **Kubernetes clusters** and click **Import cluster**.
2. Paste the kubeconfig and save.

MainPath checks the file and stores it encrypted. Imported clusters can host applications, but they **cannot provision a managed cloud database**. That needs a cluster created by MainPath or a classic Docker server.

## Hosting and database

In the project composer under **Hosting** you choose **Kubernetes cluster**, **Docker server**, or (homepage-only projects) **Webspace**. Production, development, and dynamic environments share the same cluster, like a webspace.

You enable a relational database on the backend only after hosting is set to a classic server or a cluster created in a cloud account. You then pick engine, instance size, and storage for that provider. Without that hosting choice MainPath shows a notice instead of turning the database on.

