Holo-Tanzu-TKC-Expand

Module 7 – Add a Node to a Tanzu Kubernetes Cluster (TKC)

When running Kubernetes workloads on Cloud Foundation with Tanzu it's easy to allocate infrastructure for hosting TKCs and to expand that capacity over time as needed. 

In Cloud Foundation with Tanzu capacity can be added to TKCs in two ways. 

  • You can scale the TKC vertically by increasing the size of the worker nodes.
  • You can scale the TKC horizontally by adding more worker nodes.

In this exercise we will show how to add capacity by adding an additional worker node.

Prior to completing this module, complete Module 4 – Create a Tanzu Kubernetes Cluster (TKC).

Note: while the developer can increase the size and number of virtual machines that get deployed as part of a TKC, the vSphere administrator retains controls over the total amount of cluster resources (CPU, memory, storage) that can be consumed by the TKCs running on the cluster.  Resource utilization policies are defined at the vSphere namespace.

Step 1: Review TKC


Start by viewing the details of tkc01 from the vSphere client.

  1. Navigate to Menu -> Inventory
  2. Expand vcenter-mgmt.vcf.sddc.lab
  3. Expand mgmt-datacenter-01
  4. Expand mgmt-cluster-01
  5. Expand Namespaces
  6. Expand tkc01

 

We see that tkc01 is currently comprised of one control plane node and two worker nodes.

Graphical user interface, application</p>
<p>Description automatically generated

  1. Click ns01
  2. Click the Compute tab
  3. Click to select Tanzu Kubernetes

Graphical user interface, application</p>
<p>Description automatically generated

Here we see that tkc01 is running, the Kubernetes version is v1.23.8, and the control plane address is 10.80.0.2 (the Kubernetes version and control plane IP may be different in your lab). 

Connect to the developer workstation.   

  1. Click the PuTTY icon on the Windows taskbar
  2. Click Tanzu WS
  3. Click Load
  4. Click Open
    • Login: sam
    • Password: VMware123!

 

Graphical user interface, application</p>
<p>Description automatically generated

 

In the PuTTY terminal, run the kubectl vsphere login --vsphere-username sam@vsphere.local --server 10.80.0.2 command to authenticate to the Kubernetes control plane running on the supervisor cluster.

  1. kubectl vsphere login --vsphere-username sam@vsphere.local --server 10.80.0.2

Next, run the kubectl config use-context ns01 command to connect to set the context to the ns01 vSphere namespace. 

  1. kubectl config use-context ns01

Text</p>
<p>Description automatically generated

Next, run the kubectl get tkc command to view the status of tkc01.

  1. kubectl get tkc

Run the kubectl get virtualmachiens command to see the VMs that make up tkc01.

  1. kubectl get virtualmachiens

Text</p>
<p>Description automatically generated

Again, we observe that the TKC is in a running state and currently has one control plane and two worker nodes. Note that the developer sees the same information that was shown to the vSphere administrator in the vSphere client

Step 1 Summary

In step 1 we viewed the details of tkc01 from both the vSphere client and the developer workstation.  We confirmed that the TKC is in a running state and is comprised of one control plane and two worker nodes.

Step 2: Add Worker Node

In this step we expand the tkc01 cluster by adding a third worker node.

In the PuTTY terminal run the command kubectl edit tkc/tkc01.

  1. kubectl edit tkc/tkc01

Text</p>
<p>Description automatically generated with medium confidence

The YAML configuration for tkc01 opens in the vi editor.  Scroll down to the topology section to locate the replicas property for the worker nodes.

Text</p>
<p>Description automatically generated

Change the replicas property to 3.  Save the changes and exit the vi editor.

If you are not familiar with the vi editor, the following table will guide you through the steps to make the change. 

Note that the vi editor has two modes.  By default, you start in the “command mode”.  While in this mode you use the arrow keys to scroll through the file and run ‘vi’ commands.  To edit/change the contents of the file you press lowercase ‘r’ (for replace) to overwrite the number “2” with the number “3”.  After making the change, press the “esc” key to switch back to command mode.  Then run the command ‘:wq’ will save the change and exit the vi editor.

 

To update the replicas property for the worker nodes using the vi editor:

 

Action

Results

Press the escape key (esc)

Place the editor in command mode

Use the arrow keys to navigate to the replicas property for the worker nodes

    nodePools:

    - name: workers

      replicas: 2

 

Use the arrow keys to place the cursor on the number 2 in the string replicas: 2

    nodePools:

    - name: workers

      replicas: 2

 

Type the letter r (replace) and type the number 3.  This will change the number from 2 to 3

    nodePools:

    - name: workers

      replicas: 3

 

Press the escape key (esc)

Switch back to command mode

Type :wq

Save the changes and exit the vi editor

The following image shows what the PuTTY terminal will look like after making the update and just before saving the changes and exiting the vi editor.

Text</p>
<p>Description automatically generated

When you exit the vi editor, the changes are applied.  You are notified that tkc01 has been edited.

The Kubernetes control plane detects the change and begins the process of adding a third worker node. To monitor the progress, run the kubectl get virtualmachines and kubectl get tkc commands. 

  1. kubectl get virtualmachines
  2. kubectl get tkc

Text</p>
<p>Description automatically generated

We see the new worker node being added to the TKC.  Note that the TKC READY status shows false while the additional node is being added.  The READY status will return to true after the node has been deployed and added to the TKC. 

Returning to the vSphere client we can also monitor the deployment from the Recent Tasks pane.

  1. Return to the vSphere Client
  2. Expand the Recent Tasks pane

 

Monitor the VM deployment.  It will take 3 to 5 minutes for the new worker node to be deployed.  Wait for it to complete.

Step 2 Summary

In step 2 used the tkc edit tkc/tkc01 command to open the TKC configuration in the vi editor.  We then changed the worker node replicas count to 3.  After making the change, the Kubernetes control plane initiated the steps to deploy an additional worker node and add it to the TKC.

Step 3: Verify New Worker Node


After the new node has been added, click the refresh icon on the vSphere Client.

  1. Click the refresh icon

Graphical user interface, text, application</p>
<p>Description automatically generated

 

Verify the ‘Worker Count’ is updated to ‘3’.

 

Return to the Putty terminal and re-run the kubectl get tkc and kubectl get virtualmachines commands to confirm the VM has joined the tkc01 cluster and that the READY status has been updated back to ‘true’. 

  1. Click the Putty icon to return to the Putty terminal

Next, run the kubectl get tkc command to view the status of tkc01.

  1. kubectl get tkc

Run the kubectl get virtualmachiens command to see the VMs that make up tkc01.

  1. kubectl get virtualmachiens

 

 

Text</p>
<p>Description automatically generated

Step 3 Summary

In step 3 we confirmed that the new worker node was successfully added to tkc01.  In the vSphere client we observed that following the VM deployment the TKC worker node count was increased to 3.  From the PuTTY terminal we confirmed there are now four virtual machines in tkc01 (one control plane node and three worker nodes).  We also confirmed that after the new worker node was added, the TKC READY state is set to true.

Module Summary

Being able to dynamically allocate capacity on demand and add additional capacity over time is a critical capability for any modern cloud. When running Kubernetes workloads on top of Cloud Foundation with Tanzu it's easy to not only allocate infrastructure for hosting TKCs, but also to resize TKCs as needed. 

TKCs can be expanded in two ways. 

  • You can scale the TKC horizontally by adding more worker nodes.
  • You can scale the TKC vertically by increasing the size of the worker nodes.

In this exercise we will saw how to add capacity to a TKC by adding an additional worker node.

Module Key Takeaways

  • With Cloud Foundation with Tanzu it's easy to allocate infrastructure for hosting TKCs and to expand the infrastructure over time. 
  • To add worker nodes to a running TKC, you use the kubectl edit tkc/tkc01 command to update the number of worker node replicas. 
  • While the developer can increase the size and number of virtual machines that get deployed as part of a TKC, the vSphere administrator retains controls over the total amount of cluster resources (CPU, memory, storage) that can be consumed by the TKCs running on the cluster.

 

Filter Tags

Document