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.
To create a Kubernetes Cluster from the Bastion Host, input the following command:
$ . ./k8s-create.sh
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
.The link for the GitHub repo is:
https://github.com/linuxacademy/content-aiops-essentials
To look at the Python source code in
scale_cluster.py
:cat scale_cluster.py
Also look at the template YAML for the instance group:
cat instance.yaml
Also, look at the
edit_cluster.sh
script that edits theinstance.yaml
file:cat edit_cluster.sh
Now execute the command to scale the cluster:
python scale_cluster.py
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