# Set up your Bare Metal Kubernetes Cluster

You can deploy Kubernetes clusters on physical machines using the bare metal support for <code class="expression">space.vars.product\_name</code>. Each cluster contains all the resources for your containerized workloads, such as nodes, pods, and services.

Learn more on how you can onboard physical machines to <code class="expression">space.vars.product\_name</code> , create a Kubernetes cluster through the <code class="expression">space.vars.product\_name</code> console, and verify if your cluster is working.

{% hint style="warning" %}
**Information**

Bare metal support for Kubernetes in <code class="expression">space.vars.product\_name</code> is currently in `beta`
{% endhint %}

### Prerequisites

Before you start, ensure you have:

* One or more Ubuntu physical machines for your Kubernetes nodes. <code class="expression">space.vars.product\_acronym</code> supports Ubuntu 20.04 LTS and Ubuntu 22.04 LTS.
* Network connectivity between all machines and the <code class="expression">space.vars.product\_name</code> management cluster.
* Administrator requires sudo or root access on all target machines.
* Valid <code class="expression">space.vars.product\_name</code> account credentials.
* Access to your <code class="expression">space.vars.product\_name</code> management console.

#### Step 1: Onboard your machines

To install the `byohctl` CLI and registering your physical machines with <code class="expression">space.vars.product\_name</code>, perform the following steps.

1. Download and install `byohctl` For each physical server you want to add a Kubernetes node, run this command.

{% tabs %}
{% tab title="Bash" %}

```bash
bash <(curl -s https://byohctl.s3.us-west-2.amazonaws.com/byohctl-setup)
```

{% endtab %}
{% endtabs %}

This command downloads and runs the setup script that installs the `byohctl` CLI on your machine.

2. Register your machine with <code class="expression">space.vars.product\_name</code> Run the following onboard command with your <code class="expression">space.vars.product\_name</code> credentials:

{% tabs %}
{% tab title="Bash" %}

```yaml
sudo ./byohctl onboard \
  -u <URL> \
  -e <USERNAME/EMAIL> \
  -d <DOMAIN> \
  -c <CLIENT_TOKEN> \
  -t <TENANT> \
  -r <REGION> \
  -p <PASSWORD>
```

{% endtab %}
{% endtabs %}

Replace the placeholder parameter with your actual information.

| Parameter          | Description                                                                             | Example                  |
| ------------------ | --------------------------------------------------------------------------------------- | ------------------------ |
| `<URL>`            | Your <code class="expression">space.vars.product\_name</code> management plane URL      | exampl.pcd.platform9.com |
| `<USERNAME/EMAIL>` | Your <code class="expression">space.vars.product\_name</code> username or email address | <testuser@platform9.com> |
| `<DOMAIN>`         | Your <code class="expression">space.vars.product\_name</code> domain                    | default                  |
| `<CLIENT_TOKEN>`   | Your <code class="expression">space.vars.product\_name</code> client token (secret)     | MyT0k3N                  |
| `<TENANT>`         | Your <code class="expression">space.vars.product\_name</code> tenant                    | service                  |
| `<REGION>`         | Your <code class="expression">space.vars.product\_name</code> region                    | regionone                |
| `<PASSWORD>`       | Your <code class="expression">space.vars.product\_name</code> password \_\_             | your\_password           |

Here is an example of how your command would be.

{% tabs %}
{% tab title="Bash" %}

```bash
byohctl onboard -u exampl.pcd.platform9.com -e testuser@platform9.com -d default -c MyT0k3N -t service -r regionone -p your_password
```

{% endtab %}
{% endtabs %}

3. Verify successful onboarding

Confirm that your machine has been properly registered with <code class="expression">space.vars.product\_name</code> and the agent is communicating correctly.

Verify that the agent service is active and communicating by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
systemctl status pf9-byohost-agent.service
```

{% endtab %}
{% endtabs %}

You should see the agent service is active and running.

Review the agent logs to confirm registration with <code class="expression">space.vars.product\_name</code> by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
cat /var/log/pf9/byoh/byoh-agent.log
```

{% endtab %}
{% endtabs %}

Confirm you see registration success messages in the logs.

From your management cluster, confirm the host is visible as an available resource by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get byohost -A
```

{% endtab %}
{% endtabs %}

Your machine should appear in the list of available hosts. You can also verify this on the <code class="expression">space.vars.product\_name</code> console from **Kubernetes** > **Infrastructure** > **Physical Hosts**.

#### Step 2: Create your Kubernetes cluster

1. Log in to your <code class="expression">space.vars.product\_name</code> console.
2. Navigate to **Infrastructure** > **Clusters**
3. Select **Create New Cluster with Physical Nodes** to access **Deploy a New Cluster**. Enter and choose the compute infrastructure for your new cluster.

| **Field**     | **Action**                           | **Description**                                                                                           |
| ------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| Cluster Name  | Enter a unique name for your cluster | This name identifies your cluster in the <code class="expression">space.vars.product\_name</code> console |
| Physical Node | Select your onboarded machines       | Choose from the available hosts list                                                                      |

4. Choose **Control Plane Type**: Choose **Managed Control Plane** and then select **Next**.
5. Configure your Kubernetes cluster settings.

| **Settings**       | **Action**           | **Description**                                                                                           |
| ------------------ | -------------------- | --------------------------------------------------------------------------------------------------------- |
| Kubernetes Version | Select from dropdown | Choose the Kubernetes version supported by your workloads.                                                |
| Kubernetes Flags   | Enable this flag     | Customize kube-apiserver, Controller Manager, and Scheduler flags using the cluster API.                  |
| Core Add-ons       | Enable as required   | CoreDNS and Calico can be enabled individually. Customize add-ons using cluster API add-on configuration. |
| Other Add-ons      | Enable as required   | Optional add-ons like MetalLB and Nvidia GPU Operator are available.                                      |

6. Select **Submit** to start the deployment process.

The <code class="expression">space.vars.product\_name</code> console now provisions your cluster using the physical machines you onboarded.

#### Step 3: Verify your cluster

**Monitor cluster creation**

Monitor your cluster creation progress in the <code class="expression">space.vars.product\_name</code> console.

1. Navigate to **Infrastructure** > **Clusters**.
2. Find your cluster in the list and monitor its status as Active

**Optionally**, you can also monitor progress using these `kubectl` commands from your management cluster.

* Check the TenantControlPlane status by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get tcp -A
```

{% endtab %}
{% endtabs %}

* Check the HostedControlPlane status by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get hcp -A
```

{% endtab %}
{% endtabs %}

* Monitor machine provisioning by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get machine -A
```

{% endtab %}
{% endtabs %}

When your machines show **Running** status with `NODENAME` and `PROVIDERID` values, your cluster nodes have successfully joined.

**Access your cluster**

Download the `kubeconfig` file from the <code class="expression">space.vars.product\_name</code> console.

1. Navigate to **Kubernetes > Infrastructure > Clusters** and then to your cluster.
2. Choose **Download Kubeconfig.**
3. Save the downloded file as `cluster-kubeconfig.yaml`.

* Set your `kubectl` context by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
export KUBECONFIG=<CLUSTER_KUBECONFIG.YAML>
```

{% endtab %}
{% endtabs %}

* Verify your cluster is working by running the following command.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get nodes -A 
kubectl get ns 
kubectl get pods -A
```

{% endtab %}
{% endtabs %}

These commands show your cluster nodes, namespaces, and running pods.

You have successfully created and verified your bare metal Kubernetes cluster. Your physical machines are now ready to run containerized workloads.

{% hint style="info" %}
**Info**

Cluster Autoscaling is not currently supported in BYOH Kubernetes clusters
{% endhint %}

## Best Practices

* Make sure your physical machines meet the minimum system requirements for Kubernetes nodes.
* The `byohctl` agent logs at `/var/log/pf9/byoh/byoh-agent.log` are useful for troubleshooting onboarding issues.
* Core add-ons are required for basic cluster functionality.
* Your Kubernetes version must be supported by your <code class="expression">space.vars.product\_name</code> management plane.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.platform9.com/private-cloud-director/kubernetes-clusters/setup-bare-metal-kubernetes-clusters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
