Skip to main content

Scaling Microservices in a Kubernetes Cluster

Hands-On Lab

 

Photo of Matthew Pearson

Matthew Pearson

Linux Training Architect II in Content

Length

01:00:00

Difficulty

Advanced

Not only is Kubernetes an easy way of deploying and managing containers, it also provides the ability to manually and automatically scale them. In this hands-on lab, we will install a complex microservices demo from GitHub on a Kubernetes cluster. After the microservices have been installed, we will manually scale individual microservices and set up automatic scaling.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Scaling Microservices in a Kubernetes Cluster

Introduction

Not only is Kubernetes an easy way of deploying and managing containers, it also provides the ability to manually and automatically scale them. In this hands-on lab, we will install a complex microservices demo from GitHub on a Kubernetes cluster. After the microservices have been installed, we will manually scale individual microservices and set up automatic scaling.

Connecting to the Lab

  1. Open your terminal application, and run the following command (remember to replace <MASTER_PUBLIC_IP> with the public IP you were provided on the lab instructions page):
    ssh cloud_user@<MASTER_PUBLIC_IP>
  2. Type yes at the prompt.
  3. Enter your cloud_user password at the prompt.

Create the sock-shop Namespace

  1. Run the following command:
    kubectl create namespace sock-shop
  2. Verify that the new namespace was successfully created.
    kubectl get namespaces

Deploy the Microservices Demo

  1. Run the following command:
    kubectl apply -f https://raw.githubusercontent.com/microservices-demo/microservices-demo/master/deploy/kubernetes/complete-demo.yaml
  2. Verify that the deployment was successful.
    kubectl get deployments -n sock-shop
  3. Verify that all of the pods are up and running.
    kubectl get pods -n sock-shop

Scale the carts and catalogue Deployments

  1. Run the following command:
    kubectl scale deployments carts catalogue --replicas=3 -n sock-shop
  2. List the current deployments.
    kubectl get deployments -n sock-shop
  3. List the current pods.
    kubectl get pods -n sock-shop

Autoscale the front-end Deployment

  1. Run the following command:
    kubectl autoscale deployment front-end -n sock-shop --max 6 --min 2 --cpu-percent 70
  2. Verify that the deployment was successfully scaled.
    kubectl get deployments -n sock-shop
  3. Verify that the scaling parameters were successfully configured.
    kubectl get hpa -n sock-shop

Conclusion

Congratulations, you've successfully completed this hands-on lab!