Personal Development Category (English)728x90

Kubernetes tutorial – Scale & perform updates to your app

Disclosure: This page uses affiliate links.When you click an affliate link,we get a small compensation at no cost to you.Thanks for your support!Learn more

In the last post, we have looked at how to create the local cluster, deploy an app, and check the status of the deployments. In continuation of the series, in this post, we are going to check how to scale & perform updates to applications running on the Kubernetes cluster. Earlier posts of this series were featured in KubeWeekly

Step #1. Check the list of application deployment

If you can remember, in the last post we have deployed our Nginx application using the run command. So let us check the list of application deployments using get deployments command.

The run command would have created only one Pod for running our application. But in the real-life scenario, when traffic increases, we will need to scale the application to keep up with user demand. Running multiple instances of an application will require a way to distribute the traffic to all of them. Services have an integrated load-balancer that will distribute network traffic to all Pods of an exposed Deployment. Services will monitor continuously the running Pods using endpoints, to ensure the traffic is sent only to available Pods.

Kubernetes get deployment command

Image – kubectl get deployment command

To list your deployments use the get deployments command:

We should have 1 Pod. If not, run the command again. This shows:

Subscribe to Emails

More than 100,000 subscribers across the world trust & read Upnxtblog articles. Subscribe to emails updates!
* indicates required
  • The DESIRED state is showing the configured number of replicas
  • The CURRENT state show how many replicas are running now
  • The UP-TO-DATE is the number of replicas that were updated to match the desired (configured) state
  • The AVAILABLE state shows how many replicas are actually AVAILABLE to the users

Step #2. Scale up/down application deployment

Now let’s scale the Deployment to 4 replicas. We are going to use the kubectl scale command, followed by the deployment type, name, and desired number of instances:

Kubernetes scale deployment command

Image – kubectl scale deployment command

The change was applied, and we have 4 instances of the application available. Next, let’s check if the number of Pods changed:

Devops Engineer Masters Program will make you proficient in DevOps principles like CI/CD, Continuous Monitoring and Continuous Delivery, using tools like Puppet, Nagios, Chef, Docker, Git & Jenkins. It includes training on Linux, Python, Docker, AWS DevOps Certification Training and Splunk. The curriculum has been determined by extensive research on 5000+ job descriptions across the globe.
New customer offer! Top courses from $13.99 when you first visit Udemy
Kubernetes get deployments command

Image – kubectl get deployments command

Now there should be 4 pods running in the cluster

Kubernetes get pods command
Recover over 700 unique file formats. Fully recover documents, emails, photos, videos, audio files and more. Supports 8 different data lost scenarios: deleted files recovery, recycle bin recovery, formatted drive recovery, lost partition recovery, externa

Image – kubectl get pods command

There are 4 Pods now, with different IP addresses. The change was registered in the Deployment events log. To check that, use the describe command:

kubectl describe command

Image – kubectl describe command

You can also view in the output of this command that there are 4 replicas now.

To scale down the Service to 2 replicas, run again the scale command:

kubectl scale command

Image – kubectl scale command

Step #3. Perform rolling updates to application deployment

If you have multiple instances of an Application running, there could be scenarios where old instances can clash with the new instances, and if you shut down the cluster for updates, downtime could never be not acceptable. Users expect applications to be available all the time and developers are expected to deploy new versions of them several times a day.

In Kubernetes, this is done with rolling updates. Rolling updates allow deployments update to take place with zero downtime by incrementally updating Pods instances with new ones. The new Pods will be scheduled on Nodes with available resources.

Career Category (English)640x480

Rolling updates allow the following actions:

  • Promote an application from one environment to another (via container image updates)
  • Rollback to previous versions
  • Continuous Integration and Continuous Delivery of applications with zero downtime

To view the current image version of the app, run a describe command against the Pods (look at the Image field):

kubectl describe command

Image – kubectl describe command

To update the image of the application to the new version, use the set image command, followed by the deployment name and the new image version:

kubectl set image command

Image – kubectl set image command

Google IT Support Professional Certificate by Grow with Google (300x600) - 2
kubectl describe pods command

Image – kubectl describe pods command

The command notified the Deployment to use a different image for your app and initiated a rolling update. Check the status of the new Pods, and view the old one terminating with the get pods command:

Step #4. Rollback updates to application deployment

Suppose if you want to roll out the updates we made, We’ll use the rollout undo command:

kubectl rollout undo command

Image – kubectl rollout undo command

The rollout command reverted the deployment to the previously known state. Updates are versioned and you can revert to any previously known state of a Deployment. List again the Pods:

After the rollout succeeds, you may want to get the Deployment.

Step #5. Cleanup

Finally, you can clean up the resources you created in your cluster:

kubectl delete service my-nginx
kubectl delete deployment my-nginx


Like this post? Don’t forget to share it!

Additional Resources :

Kubernetes tutorial - Scale & perform updates to your app
Article Name
Kubernetes tutorial - Scale & perform updates to your app
In this post, we are going to check how to scale & perform updates to applications running on Kubernetes cluster.
Publisher Name
Publisher Logo

3 thoughts on “Kubernetes tutorial – Scale & perform updates to your app”

  1. Pingback: Kubernetes tutorial - Create simple cluster & Deploy app
  2. Trackback: Kubernetes tutorial - Create simple cluster & Deploy app
  3. Pingback: TOP 20 Microservices Design Patterns
  4. Trackback: TOP 20 Microservices Design Patterns
  5. Pingback: TOP 7 Managed Kubernetes Platforms
  6. Trackback: TOP 7 Managed Kubernetes Platforms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: