logo

[TKG Series – Part 2] Install Kubernetes Cluster(s) using Tanzu Kubernetes Grid

TKG Series

For my next post, we will now be installing kubernetes clusters using Tanzu Kubernetes Grid (TKG). With properly configured tkg, the command is straightforward:.

  • Execute the command
    • tkg create cluster <cluster name>
    • –plan
      • prod or dev
        • this are ootb plan. you can create customized plan that will specify network, resources, datastore of deployed VMs.
    • –kubernetes-version
      • dependent on what photon template is used
    • –controlplane-machine
      • how many master node
    • –worker-machine-count
      • how many worker node

tkg create cluster helloworld --plan prod --kubernetes-version v1.17.3+vmware.2 --controlplane-machine-count 1 --worker-machine-count 1
  • Wait a couple of minutes – voila!
  • You can verify the kubernetes cluster by issuing

kubectl get nodes
tkg get cluster
I had another kubernetes cluster provisioned on this screenshot.

Switching kubernetes context

Once you have multiple kubernetes, you can switch context by doing the following

  • Save kubernetes credentials provisioned by tkg

tkg get credentials helloworld
  • Issue kubectl to get available contexts

kubectl config get-contexts
  • Switch context

kubectl config use-context CONTEXT_NAME
By switching context, you can now specify which kubernetes cluster to deploy your application

Scaling Kubernetes Cluster

tkg handles commands declartively in scaling kubernetes cluster. Meaning, the command you specified will be the “end-goal” of the cluster.

For example, to scale the helloworld cluster to 2 worker nodes, the following command can be issued


tkg scale cluster helloworld -w 2

To scale master nodes to 2 nodes and scale-in the worker nodes to 1 the following command can be issued:


tkg scale cluster helloworld -c 2 -w 1

TKG Terms:
Control Plane = Kubernetes Master Node
Worker = Kubernetes Worker/Minion Node

Destroy Cluster

The following easily destroys provisioned tkg kubernetes cluster. VMs are also deleted as part of the process


tkg delete cluster helloworld
Confirmation will be asked as the process is irreversible

After deleting the cluster, you need to delete the kubectl config as well by doing the following:


kubectl config unset clusters.&lt;CLUSTER NAME>
kubectl config unset users.&lt;ADMIN NAME>
kubectl config unset contexts.&lt;CONTEXT NAME>

In my next post, I’ll be describing how to create custom plans to customize the resources being consumed by tkg provisioned nodes.

  1. Pingback: A private cloud – all for myself » [TKG Series – Part 3] Creating custom plan in Tanzu Kubernetes Grid

Leave a Reply

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.