Scaling a Cluster with Python

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

This lab guides the student through the final component of the proof-of-concept. This lab uses kops to scale a cluster after a Python program edits the cluster configuration YAML file. This is all done from a Bastion Host.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a cluster with kops.
  1. To create a Kubernetes Cluster from the Bastion Host, input the following command:

    $ . ./
  2. You may view the default YAML templates created by kops with any of the following commands:

    kops edit cluster

    Or to look at the instance group for the nodes:

    kops edit ig nodes

    After looking at the base installation, you may create the cluster by entering:

    kops update cluster --yes
Validate the cluster that was created.

To validate the newly created cluster:

kops validate cluster

And eventually, after the EC2 servers are up:

kubectl get nodes
Use Python to increase the nodes in the instance group.

You may view the files below from the GitHub site, or by simply using cat.

  1. The link for the GitHub repo is:
  2. To look at the Python source code in

  3. Also look at the template YAML for the instance group:

    cat instance.yaml
  4. Also, look at the script that edits the instance.yaml file:

  5. Now execute the command to scale the cluster:

  6. Tell kops to commit the changes to the cluster:

    kops rolling-update cluster --yes
Validate that the cluster was scaled.

You may simply validate the number of worker nodes running by entering:

kubectl get node

Additional Resources

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!