Deploying Tanzu Kubernetes Clusters (TKC) on vSphere with Kubernetes using the TKG CLI

Published on May 19, 2020 under VMware · Tagged TKG, Kubernetes, vSphere with Kubernetes, vk8s, vSphere, TKC, Tanzu Kubernetes Cluster and Tanzu Kubernetes Grid · Read in about 2 min (391 words)

Tanzu Kubernetes Grid (TKG) is a great tool to deploy VMware Kubernetes on different Platforms. In previous blogs I covered how you could deploy a TKG to VMware Cloud on AWS as well as to a regular vSphere Environment. Today we will demonstrate how to use the TKG CLI to provision a Tanzu Kubernetes Cluster (TKC) to a vSphere With Kubernetes Environment.

In the previous blogs, we covered TKG on VMC and on vSphere. When you deploy a TKC to a vSphere with Kubernetes Supervisor Cluster there is no need to deploy a TKG Management Cluster as the Supervisor Cluster has the same functionality.

Adding the Supervisor Cluster as a Management Cluster using the TKG CLI

Before we begin, we can validate if the Supervisor Cluster is currently added as a TKG Management Cluster by running:

tkg get management-cluster

In our case our output is blank, so we can proceed to add the Supervisor Cluster into the TKG CLI. Using kubectl login to your Supervisor Cluster

kubectl vsphere login --vsphere-username [email protected] --server=control_Plane_VIP --insecure-skip-tls-verify=true

Switch Context to your Supervisor Cluster

kubectl config use-context <Supervisor_Cluster_context>

Add your Management Cluster

tkg add management-cluster

Verify your Management-Cluster has been added.

tkg get management-cluster

Deploying a TKC using the TKG CLI

Before you can deploy a TKC using the TKG CLI you need to either set environment variables by specifying export = at the command line, or set them by updating the ~/.tkg/config file.

Here is an example of variables for my environment.

export CONTROL_PLANE_STORAGE_CLASS=vsan-default-storage-policy
export WORKER_STORAGE_CLASS=vsan-default-storage-policy
export DEFAULT_STORAGE_CLASS=vsan-default-storage-policy
export STORAGE_CLASSES=vsan-default-storage-policy
export SERVICE_DOMAIN=fsa.lab 
export CONTROL_PLANE_VM_CLASS=best-effort-xsmall
export WORKER_VM_CLASS=best-effort-xsmall

Once your variables are set you can obtain a list of Kubernetes Versions that are available in the Supervisor Cluster

kubectl get virtualmachineimages

Identify which Namespace you want to deploy your TKC to:

kubectl get namespaces

Run tkg create cluster to provision your TKC cluster:

tkg create cluster tkg-tkc-01 --plan=dev --namespace tkc01 --kubernetes-version=v1.16.8+vmware.1-tkg.3.60d2ffd


Using the TKG CLI to provision Tanzu Kubernetes Clusters is a great way to handle the deployment, if you wish to not use the TKG CLI you can still provision a TKC using kubectl and yaml

Questions or Comments? Leave them below!

Share this post
comments powered by Disqus

See Also