install and configure tkg 1.4 on vsphere – part-4 – deploy tkg workload cluster on vsphere

The steps to deploy a TKG Management cluster on a vSphere platform were covered in the previous part of this blog series. In this blog, we will go through the steps to deploy a TKG workload cluster on a vSphere platform.

When a TKG management cluster is created using an installer interface, the configuration of a TKG Management cluster is saved in a cluster configuration file with a random name, which is available under the ~/.config/tanzu/tkg/clusterconfigs/ directory.

For instance, in my lab environment, the configuration for a TKG Management cluster was saved in a file given below.

The contents of this file include cluster name, cluster CIDR, LDAP configuration etc. The same file can be used to deploy a TKG workload cluster.

Make a copy of the management cluster configuration file and save it with a new name.

Open the new file in vi mode or using any other such editor which you are comfortable with and set a name for a TKG workload cluster.

If you have created namespaces in your Tanzu Kubernetes Grid instance, you can deploy Tanzu Kubernetes Workload clusters to those namespaces by specifying the NAMESPACE variable. If you do not specify the  NAMESPACE variable, Tanzu Kubernetes Grid places clusters in the default namespace. 

For example, in the cluster configuration file, you can add a NAMESPACE variable to production as shown below

NAMESPACE: production

Run the command below to create a TKG workload cluster.

tanzu cluster create –file /root/.config/tanzu/clusterconfigs/<TKG workload cluster file name>

Please note – In the command above, you need to provide two hyphens before the ‘file’ parameter.

The command above will verify and validate the configuration defined in your cluster config file and will create a fully functional Tanzu Kubernetes cluster where you can deploy your Kubernetes pods and deployments.

In my lab environment, I used a development cluster plan to deploy a Tanzu Kubernetes workload cluster. The development plan (DEV) deploys a TKG cluster with 1 control plane node, and 1 worker node (each with 2 CPU and 4 GB RAM).

If required, you can change the cluster plan to production or specify other sizes for your control and worker nodes. For more details, please refer to Tanzu Kubernetes Cluster Template.

Once a Tanzu Kubernetes workload cluster is created, run the command below to set the context of a workload cluster in the admin kubeconfig file.

tanzu cluster kubeconfig get <Tanzu Kubernetes Workload Cluster name> –admin

Please note – In the command above, you need to provide two hyphens before the ‘admin’ parameter.

Run the command below, to view the available contexts

kubectl config get-contexts

Run the command below to switch the context to the Tanzu workload cluster

kubectl config use-context <Tanzu Kubernetes Workload cluster context>

Run the command below to check if the current context has been set to the required tanzu Kubernetes workload cluster context.

kubectl config current-context

Run the command below to examine the status of a newly deployed Tanzu Kubernetes Workload cluster. Both the control node and the worker node should be in ‘Ready’ state.

kubectl get nodes

So, with TKG, deploying a Kubernetes cluster is just a matter of running a single command i.e. tanzu cluster create –file <cluster configuration file>.

In the next blog, we will see how to deploy and run Kubernetes pods on a Tanzu Kubernetes workload cluster.

Leave a comment