Effortless Cluster API Setup on vSphere

Deploying a Cluster API Management Cluster on vSphere: A Step-by-Step Guide

In this article, we will explore the process of deploying a Cluster API management cluster on vSphere. We will cover the steps required to download and deploy the PhotonOS Kubernetes and HAProxy images, as well as the creation of a new CentOS or Ubuntu VM to act as a temporary bootstrap server. Additionally, we will discuss the configuration of the cluster components and the initialisation of the local-control-plane cluster as our management cluster.

Step 1: Download and Deploy OVA Images

To begin, we need to download the PhotonOS Kubernetes and HAProxy images from the Google Cloud Storage link provided below:

* PhotonOS Kubernetes:

* HAProxy:

Once the images are downloaded, we can deploy them in vSphere using the OVA files. To do this, follow these steps:

1. Open vSphere and select “File” > “Deploy OVA Template”.

2. Select the PhotonOS Kubernetes OVA file and click “Next”.

3. Select the HAProxy OVA file and click “Next”.

4. Choose a datastore to store the virtual machines and click “Finish”.

5. Take a snapshot of the virtual machines before converting them to templates.

6. Convert the virtual machines to templates by selecting them in the vSphere interface, right-clicking, and selecting “Template > Convert to Template”.

Step 2: Create a New CentOS or Ubuntu VM

Next, we need to create a new CentOS or Ubuntu VM to act as a temporary bootstrap server. For this, follow these steps:

1. Open vSphere and select “File” > “New” > “Virtual Machine”.

2. Choose the appropriate version of CentOS or Ubuntu and click “Next”.

3. Select the appropriate hardware configuration and click “Next”.

4. Name the virtual machine and click “Finish”.

Step 3: Install Components on the Bootstrap VM

Once the bootstrap VM is created, we need to install the required components on it. For this, follow these steps:

1. Connect to the bootstrap VM using vSphere Client.

2. Install Docker by running the following command:

“`

sudo yum install docker

“`

3. Install KIND by running the following command:

“`

sudo yum install kind

“`

4. Install kubectl by running the following command:

“`

sudo yum install kubectl

“`

5. Install clusterctl by running the following command:

“`

sudo yum install clusterctl

“`

Step 4: Create a Cluster Configuration File

Next, we need to create a cluster configuration file that defines the configuration values for our management cluster. This file is stored in YAML format and contains information such as the number of control-plane and worker nodes, the Kubernetes version, and other settings. To create this file, follow these steps:

1. Create a new file on the bootstrap VM’s local disk using any text editor.

2. Name the file “cluster.yaml” and open it in the text editor.

3. Add the following content to the file, replacing the values where appropriate:

“`

apiVersion: cluster.x-k8s.io/v1alpha3

kind: Cluster

metadata:

name: local-control-plane

spec:

controlPlane:

replicas: 3

nodes:

– name: node-1

label: kind/node/1

– name: node-2

label: kind/node/2

– name: node-3

label: kind/node/3

worker:

replicas: 2

nodes:

– name: worker-1

label: kind/node/1

– name: worker-2

label: kind/node/2

“`

4. Save the file and exit the text editor.

Step 5: Initialise and Create the Bootstrap Management Cluster

Now that we have created the cluster configuration file, we can initialise the management cluster using the following command:

“`

kind create cluster –config=cluster.yaml

“`

This command will create the management cluster using the configuration defined in the “cluster.yaml” file. Once the creation is complete, we can check the status of the cluster components using the following command:

“`

kubectl get all -n kind-system

“`

Step 6: Review and Modify Cluster Configuration (Optional)

Before we proceed with deploying the workload cluster, we recommend reviewing the cluster configuration file and making any necessary modifications. For example, you may want to adjust the CPU, memory, storage, and pods CIDR settings. You can use sed to perform a find and replace within the file, as follows:

“`

sed -i ‘s#CPU\s+=\([0-9]+)#\1’ cluster.yaml

sed -i ‘s#MEMORY\s+=\([0-9]+)#\1’ cluster.yaml

sed -i ‘s#STORAGE\s+=\([0-9]+)#\1’ cluster.yaml

sed -i ‘s#PODS_CIDR\s+=\([0-9]+)#\1’ cluster.yaml

“`

Replace the number in square brackets with the appropriate value for your environment.

Step 7: Deploy the Workload Cluster (Not Covered in This Guide)

Once you have reviewed and modified the cluster configuration file as needed, you can proceed with deploying the workload cluster using the following command:

“`

kind create cluster –config=cluster.yaml

“`

This command will create the workload cluster using the configuration defined in the “cluster.yaml” file.

Conclusion

———-

In this guide, we have covered the deployment of a management cluster for Kind and Kubernetes on vSphere using the CAPV-images. We have also provided an overview of how to review and modify the cluster configuration file before deploying the workload cluster. By following these steps, you can set up a management cluster for Kind and Kubernetes on vSphere and deploy your workload clusters using the appropriate configuration values.