Deploying Tanzu Kubernetes Clusters (TKC) on vSphere with Kubernetes using the TKG CLI
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:
1tkg 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
1kubectl vsphere login --vsphere-username [email protected] --server=control_Plane_VIP --insecure-skip-tls-verify=true
Switch Context to your Supervisor Cluster
1kubectl config use-context <Supervisor_Cluster_context>
Add your Management Cluster
1tkg add management-cluster
Verify your Management-Cluster has been added.
1tkg 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.
1export CONTROL_PLANE_STORAGE_CLASS=vsan-default-storage-policy
2export WORKER_STORAGE_CLASS=vsan-default-storage-policy
3export DEFAULT_STORAGE_CLASS=vsan-default-storage-policy
4export STORAGE_CLASSES=vsan-default-storage-policy
5export SERVICE_DOMAIN=fsa.lab
6export CONTROL_PLANE_VM_CLASS=best-effort-xsmall
7export WORKER_VM_CLASS=best-effort-xsmall
8export SERVICE_CIDR=100.64.0.0/13
9export CLUSTER_CIDR=100.96.0.0/11
Once your variables are set you can obtain a list of Kubernetes Versions that are available in the Supervisor Cluster
1kubectl get virtualmachineimages
Identify which Namespace you want to deploy your TKC to:
1kubectl get namespaces
Run tkg create cluster to provision your TKC cluster:
1tkg create cluster tkg-tkc-01 --plan=dev --namespace tkc01 --kubernetes-version=v1.16.8+vmware.1-tkg.3.60d2ffd
Conclusion
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!
comments powered by DisqusSee Also
- Deploying Tanzu Kubernetes Grid (TKG) on VMware Cloud on AWS (VMC)
- Deploying Tanzu Kubernetes Grid (TKG) on vSphere
- Part 6: Deploying vSphere with Kubernetes - Provisioning and Managing a Tanzu Kubernetes Cluster
- Part 5: Deploying vSphere with Kubernetes - Using vSphere with Kubernetes
- Part 4: Deploying vSphere with Kubernetes - Enabling vSphere with Kubernetes