# Get started with Managed Kubernetes

Create a dev cluster with two nodes, run kubectl against it, and delete it again.

Replace _my-cluster_ with a name of your own: lowercase letters, digits and hyphens, starting with
a letter, at most 40 characters.

## Prerequisites

- Managed Kubernetes switched on for your organization (see [What is Managed Kubernetes?](what-is.md)).
- Permission for `eks:CreateCluster`, `eks:CreateNodegroup`, `eks:CreateAddon` (the cluster gets
  `metrics-server`), `eks:DescribeCluster`, `eks:AccessKubernetesApi` and `eks:DeleteCluster`. In
  the console, also `eks:ListClusters` to open **Kubernetes**, and `eks:ListNodegroups` for the
  **Nodes** tab.
- The dcloud CLI and `kubectl` installed.

## Step 1: Create the cluster

You pay for the control plane once it is active (a `dev` cluster's first 744 hours each month are
free for the organization), and for the two nodes as compute instances.

**Console**
1. Open **Kubernetes**, then choose **Create cluster**.
2. For **Name**, enter my-cluster.
3. Leave **Control plane** at **Dev**, and **Add a first node group now** selected.
4. For **Server type**, choose a type; for **Nodes**, enter `2`.
5. Choose **Create cluster**.

The console opens the cluster's page with the status `creating`.

**CLI**
```sh
dcloud eks clusters create --name my-cluster --tier dev \
  --nodegroup '{"name":"workers","instanceType":"performance-2","minSize":1,"desiredSize":2,"maxSize":3}'
```

The answer is the new cluster with the status `creating`.

## Step 2: Wait until it is active

Deutsche Cloud builds the endpoint load balancer and the control-plane machine, then the nodes. Each
step appears under **Activity** on the cluster's page.

**Console**
1. On the cluster's page, wait until the status in the header is `active`.
2. Choose **Nodes** to see the nodes join.

**CLI**
```sh
dcloud eks clusters get my-cluster
```

Repeat until `status` is `active`.

## Step 3: Run kubectl

You created the cluster, so you have a `ClusterAdmin` access entry on it (if you act through an IAM
role, the role has it).

1. Sign in once:

   ```sh
   dcloud auth login
   ```

2. Add the cluster to your kubeconfig with `dcloud eks update-kubeconfig --cluster my-cluster`.
   It adds the context `dcloud-my-cluster` and switches to it.
3. List the nodes:

   ```sh
   kubectl get nodes
   ```

The two nodes are listed once they have joined. The control-plane machine is not a node and is
not listed.

## Clean up

Delete the cluster and keep nothing, so nothing is billed from then on.

**Console**
1. On the cluster's page, choose **Danger zone**.
2. Select **Delete permanently: keep nothing (no snapshot, volumes deleted with their data)**.
3. Choose **Delete cluster**, enter the cluster name, and choose **Delete cluster**.

The console returns to the cluster list.

**CLI**
```sh
dcloud eks clusters delete my-cluster --permanent true
```

## Next steps

- [Add a node group](add-a-node-group.md)
- [Give someone access](give-access.md)
- [Install an add-on](install-an-add-on.md)
