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.
- Navigate to Menu -> Inventory
- Expand vcenter-mgmt.vcf.sddc.lab
- Expand mgmt-datacenter-01
- Expand mgmt-cluster-01
- Expand Namespaces
- Expand tkc01
We see that tkc01 is currently comprised of one control plane node and two worker nodes.
- Click ns01
- Click the Compute tab
- Click to select Tanzu Kubernetes
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.
- Click the PuTTY icon on the Windows taskbar
- Click Tanzu WS
- Click Load
- Click Open
- Login: sam
- Password: VMware123!
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.
-
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.
-
kubectl config use-context ns01
Next, run the kubectl get tkc
command to view the status of tkc01.
-
kubectl get tkc
Run the kubectl get virtualmachiens
command to see the VMs that make up tkc01.
-
kubectl get virtualmachiens
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
.
- kubectl edit tkc/tkc01
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.
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 |
|
Use the arrow keys to navigate to the |
|
Use the arrow keys to place the cursor on the number |
|
Type the letter |
|
Press the |
|
Type |
|
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.
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.
- kubectl get virtualmachines
- kubectl get tkc
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.
- Return to the vSphere Client
- 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.
- Click the refresh icon
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’.
- Click the Putty icon to return to the Putty terminal
Next, run the kubectl get tkc
command to view the status of tkc01.
- kubectl get tkc
Run the kubectl get virtualmachiens
command to see the VMs that make up tkc01.
- kubectl get virtualmachiens
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 nodereplicas
. - 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.