SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
Autoscaling Kubernetes
Jerzy Szczepkowski
jsz@google.com
A quick recap
Node / Kubelet
Pod
ContainerContainerContainer
Pod
Container
Node / Kubelet
Pod
Container
Container
Pod
ContainerContainerContainer
Node / Kubelet
Pod
Node / Kubelet
Pod
Container
Container
Pod
Master
Replication
Controller
Replication
Controller
ContainerContainerContainerContainer
Kubernetes
Revision
Autoscaling
Autoscaling: the ability of a system to automatically adjust the
amount of used computational resources based on the load
Benefits:
● reduce cost (on cloud provider)
● reduce power consumption
Horizontal: scale the number of instances
Vertical: scale the resources used by an instance
Autoscaling Kubernetes
Kubernetes
Nodes Pods
Horizontal # of nodes # of pods
Vertical
resources for a
node
resources for a pod
Kubernetes
Horizontal autoscaling of nodes
Nodes Pods
Horizontal # of nodes # of pods
Vertical
resources for a
node
resources for a pod
Example: on Google Cloud Platform
Autoscaling nodes
Google Compute Engine:
● Infrastructure as a Service (IaaS)
● user can create virtual machines on demand
● charged on a base of per-minute cost
Google Compute Engine is an exemplary platform for Kubernetes:
● user may set-up his own cluster on Google Compute Engine
● user may buy a predefined cluster (Google Container Engine)
In both cases, Google Compute Engine virtual machine are used as hosts for Kubernetes
master and nodes.
Managed Instance Group
Autoscaling nodes
Manage virtual machines in bulk!
Managed Instance Groups (Google Compute Engine) collectively manage groups of similar virtual
machine instances (in the same zone).
A Managed Instance Group creates virtual machines on a base of instance template:
‒ image (e.g.: debian distribution)
‒ startup script (e.g.: install pkgs and start services)
‒ shutdown script (e.g: gracefully stop services)
‒ + more...
Managed Instance Groups can be manually resized.
Managed Instance Groups are now available for Google Compute Engine users.
Autoscaling MIGs
Autoscaling nodes
Let the Cloud Autoscaler choose the best size of Managed Instance Group for you!
Intent based:
● User specifies average target utilization level for VMs.
● Cloud Autoscaler collects and interprets utilization data and determines how many VMs should be added
or removed from the Managed Instance Group to achieve close to the target utilization.
Autoscaling policies (currently supported):
● CPU utilization,
● HTTP load balancing serving capacity,
● Custom Cloud Monitoring Metrics.
Autoscaling behaviour: increase rapidly, decrease gracefully.
Cloud Autoscaler is now available as for Google Compute Engine users.
Kubernetes on a MIG
Autoscaling nodes
NodeController automatically discovers nodes by querying cloud provider
(based on a regular expression for node names).
Let’s create a Managed Instance Group for nodes!
Resize of Managed Instance Group → resize of cluster.
Master remains on a separate VM (not in the Managed Instance Group), unaffected by
resize.
Problems
Autoscaling nodes
● Each node needs to have an IP range (for pods):
NodeController distributes IP ranges to nodes during assimilation of a new node.
● Graceful removal of node:
○ mark node an unschedulable in spec (no new pods will be scheduled on it)
○ notify containers that the nodes will be removed
(they can stop accepting new traffic, finish writing persistent data, etc)
○ wait for a while before removal
May be triggered by shutdown script in Managed Instance Group.
● Rebalancing of pods on node addition:
○ adding new node will not affect already schedule pods
○ the new node may be empty, potentially for a long time
○ first add node, then increase replication controllers
May be solved by rescheduling/rebalancing.
Done
Proposal
???
Autoscaling Kubernetes nodes
Autoscaling nodes
Just use Cloud Autoscaler to scale Managed Instance Group for nodes!
Considered signals for scaling:
● resource utilization (CPU, memory)
● signals from scheduler (e.g.: # of pending pods)
Horizontal autoscaling of Pods
Kubernetes
Nodes Pods
Horizontal # of nodes # of pods
Vertical
resources for a
node
resources for a pod
Autoscaling Replication Controllers
Autoscaling pods
Effort started by Red Hat.
AutoScaler:
● abstraction on the top of ReplicationController,
● calls resize on RC,
● RC is unaware of AutoScaler.
Two approaches:
● intention based - try to maintain the given value;
● rule based - if the given value is reached, execute the given action
(increment/decrement).
Proposal
Problems
Autoscaling pods
Simplest solution: AutoScaler acts on a single ReplicationController.
However: we often have many RCs for service (e.g.: rolling update).
Improved solution: AutoScaler acts on set of RCs (with matching labels):
● monitor selector - RCs to monitor
● target selector - RCs to act on (the largest of them)
● during deployment / rolling update - option to disable decrement
How to collect signals:
● cAdvisor → Heapster → InfluxDB
● Google Cloud Monitoring (Google Container Engine)
Proposal
???
Autoscaling during rolling update
Autoscaling pods
Replication
Controller
version 1.4
Auto
Scaler
Pod
Pod
Pod
Pod
↕
Autoscaling during rolling update
Autoscaling pods
Replication
Controller
version 1.4
Auto
Scaler
Pod
Pod
Pod
↑
Replication
Controller
version 1.6
Pod
Pod
Autoscaling during rolling update
Autoscaling pods
Replication
Controller
version 1.4
Auto
Scaler
Pod
Pod
Replication
Controller
version 1.6
Pod
Pod
Pod
↑
Autoscaling during rolling update
Autoscaling pods
Replication
Controller
version 1.6
Auto
Scaler
Pod
Pod
Pod
Pod
↕
Problems
Autosclaing pods
Simplest solution: AutoScaler acts on a single ReplicationController.
However: we often have many RCs for service (e.g.: rolling update).
Improved solution: AutoScaler acts on set of RCs (with matching labels):
● monitor selector - RCs to monitor
● target selector - RCs to act on (the largest of them)
● during deployment / rolling update - option to disable decrement
How to collect signals:
● cAdvisor → Heapster → InfluxDB
● Google Cloud Monitoring (Google Container Engine)
Proposal
???
Questions?

More Related Content

PDF
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
PPTX
Autoscaling in Kubernetes
PDF
Kubernetes
PDF
Kubernetes Webinar - Using ConfigMaps & Secrets
PDF
Kubernetes extensibility: CRDs & Operators
PDF
Introduction to kubernetes
PDF
(Draft) Kubernetes - A Comprehensive Overview
PPTX
Kubernetes Basics
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Autoscaling in Kubernetes
Kubernetes
Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes extensibility: CRDs & Operators
Introduction to kubernetes
(Draft) Kubernetes - A Comprehensive Overview
Kubernetes Basics

What's hot (20)

PDF
Kubernetes Basics
PDF
Open shift 4 infra deep dive
PDF
Kubernetes 101
PPTX
Kubernetes Introduction
PPTX
Kubernetes PPT.pptx
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
PDF
GitOps with ArgoCD
ODP
Kubernetes Architecture
PDF
Introduction to Kubernetes and Google Container Engine (GKE)
PDF
Kubernetes Introduction
PDF
Kubernetes 101 - an Introduction to Containers, Kubernetes, and OpenShift
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PPTX
Kubernetes for Beginners: An Introductory Guide
PDF
GitOps with Amazon EKS Anywhere by Dan Budris
PDF
Getting Started with Kubernetes
PDF
Deploying your first application with Kubernetes
PDF
Introduction to kubernetes
PPTX
Introduction to kubernetes
PDF
OpenShift-Technical-Overview.pdf
PDF
Kubernetes - A Comprehensive Overview
Kubernetes Basics
Open shift 4 infra deep dive
Kubernetes 101
Kubernetes Introduction
Kubernetes PPT.pptx
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
GitOps with ArgoCD
Kubernetes Architecture
Introduction to Kubernetes and Google Container Engine (GKE)
Kubernetes Introduction
Kubernetes 101 - an Introduction to Containers, Kubernetes, and OpenShift
K8s in 3h - Kubernetes Fundamentals Training
Kubernetes for Beginners: An Introductory Guide
GitOps with Amazon EKS Anywhere by Dan Budris
Getting Started with Kubernetes
Deploying your first application with Kubernetes
Introduction to kubernetes
Introduction to kubernetes
OpenShift-Technical-Overview.pdf
Kubernetes - A Comprehensive Overview
Ad

Similar to Autoscaling Kubernetes (20)

PDF
Autoscaling in kubernetes v1
PDF
August-20_Autoscaling-and-Cost-Optimization-on-Kubernetes-From-0-to-100.pdf
PPTX
Autoscaling with Kubernetes
PPTX
How we Auto Scale applications based on CPU with Kubernetes at M6Web?
PDF
Scaling Microservices with Kubernetes
PDF
Mattia Gandolfi - Improving utilization and portability with Containers and C...
PDF
Kubernetes basics, Nodes, Pods, Containers, Deployments
PPTX
Kubernetes fundamentals
PDF
Kubernetes Autoscaling ​ & Cloud Native Solutions
PPTX
Kubernetes - State of the Union (Q1-2016)
PDF
apidays LIVE New York 2021 - Service reliability through autoscaling workload...
PDF
Adaptive Scaling of Microgateways on Kubernetes
PDF
Google Kubernetes Engine Deep Dive Meetup
PPTX
Automated container-deployment-on-kubernetes
PDF
ContainerDayVietnam2016: Kubernetes State-of-the-art Container Management Pla...
PDF
Using kubernetes to lose your fear of using containers
PDF
Kubernetes & Google Container Engine @ mabl
PDF
kubernetes_largescale_system_design_optimization
PDF
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for...
PDF
Kubernetes
Autoscaling in kubernetes v1
August-20_Autoscaling-and-Cost-Optimization-on-Kubernetes-From-0-to-100.pdf
Autoscaling with Kubernetes
How we Auto Scale applications based on CPU with Kubernetes at M6Web?
Scaling Microservices with Kubernetes
Mattia Gandolfi - Improving utilization and portability with Containers and C...
Kubernetes basics, Nodes, Pods, Containers, Deployments
Kubernetes fundamentals
Kubernetes Autoscaling ​ & Cloud Native Solutions
Kubernetes - State of the Union (Q1-2016)
apidays LIVE New York 2021 - Service reliability through autoscaling workload...
Adaptive Scaling of Microgateways on Kubernetes
Google Kubernetes Engine Deep Dive Meetup
Automated container-deployment-on-kubernetes
ContainerDayVietnam2016: Kubernetes State-of-the-art Container Management Pla...
Using kubernetes to lose your fear of using containers
Kubernetes & Google Container Engine @ mabl
kubernetes_largescale_system_design_optimization
Put the ‘Auto’ in Autoscaling – Make Kubernetes VPA and HPA work together for...
Kubernetes
Ad

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Approach and Philosophy of On baking technology
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Advanced IT Governance
PPTX
MYSQL Presentation for SQL database connectivity
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
DOCX
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Approach and Philosophy of On baking technology
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Advanced IT Governance
MYSQL Presentation for SQL database connectivity
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced Soft Computing BINUS July 2025.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
The AUB Centre for AI in Media Proposal.docx

Autoscaling Kubernetes

  • 2. A quick recap Node / Kubelet Pod ContainerContainerContainer Pod Container Node / Kubelet Pod Container Container Pod ContainerContainerContainer Node / Kubelet Pod Node / Kubelet Pod Container Container Pod Master Replication Controller Replication Controller ContainerContainerContainerContainer Kubernetes
  • 3. Revision Autoscaling Autoscaling: the ability of a system to automatically adjust the amount of used computational resources based on the load Benefits: ● reduce cost (on cloud provider) ● reduce power consumption Horizontal: scale the number of instances Vertical: scale the resources used by an instance
  • 4. Autoscaling Kubernetes Kubernetes Nodes Pods Horizontal # of nodes # of pods Vertical resources for a node resources for a pod
  • 5. Kubernetes Horizontal autoscaling of nodes Nodes Pods Horizontal # of nodes # of pods Vertical resources for a node resources for a pod
  • 6. Example: on Google Cloud Platform Autoscaling nodes Google Compute Engine: ● Infrastructure as a Service (IaaS) ● user can create virtual machines on demand ● charged on a base of per-minute cost Google Compute Engine is an exemplary platform for Kubernetes: ● user may set-up his own cluster on Google Compute Engine ● user may buy a predefined cluster (Google Container Engine) In both cases, Google Compute Engine virtual machine are used as hosts for Kubernetes master and nodes.
  • 7. Managed Instance Group Autoscaling nodes Manage virtual machines in bulk! Managed Instance Groups (Google Compute Engine) collectively manage groups of similar virtual machine instances (in the same zone). A Managed Instance Group creates virtual machines on a base of instance template: ‒ image (e.g.: debian distribution) ‒ startup script (e.g.: install pkgs and start services) ‒ shutdown script (e.g: gracefully stop services) ‒ + more... Managed Instance Groups can be manually resized. Managed Instance Groups are now available for Google Compute Engine users.
  • 8. Autoscaling MIGs Autoscaling nodes Let the Cloud Autoscaler choose the best size of Managed Instance Group for you! Intent based: ● User specifies average target utilization level for VMs. ● Cloud Autoscaler collects and interprets utilization data and determines how many VMs should be added or removed from the Managed Instance Group to achieve close to the target utilization. Autoscaling policies (currently supported): ● CPU utilization, ● HTTP load balancing serving capacity, ● Custom Cloud Monitoring Metrics. Autoscaling behaviour: increase rapidly, decrease gracefully. Cloud Autoscaler is now available as for Google Compute Engine users.
  • 9. Kubernetes on a MIG Autoscaling nodes NodeController automatically discovers nodes by querying cloud provider (based on a regular expression for node names). Let’s create a Managed Instance Group for nodes! Resize of Managed Instance Group → resize of cluster. Master remains on a separate VM (not in the Managed Instance Group), unaffected by resize.
  • 10. Problems Autoscaling nodes ● Each node needs to have an IP range (for pods): NodeController distributes IP ranges to nodes during assimilation of a new node. ● Graceful removal of node: ○ mark node an unschedulable in spec (no new pods will be scheduled on it) ○ notify containers that the nodes will be removed (they can stop accepting new traffic, finish writing persistent data, etc) ○ wait for a while before removal May be triggered by shutdown script in Managed Instance Group. ● Rebalancing of pods on node addition: ○ adding new node will not affect already schedule pods ○ the new node may be empty, potentially for a long time ○ first add node, then increase replication controllers May be solved by rescheduling/rebalancing. Done Proposal ???
  • 11. Autoscaling Kubernetes nodes Autoscaling nodes Just use Cloud Autoscaler to scale Managed Instance Group for nodes! Considered signals for scaling: ● resource utilization (CPU, memory) ● signals from scheduler (e.g.: # of pending pods)
  • 12. Horizontal autoscaling of Pods Kubernetes Nodes Pods Horizontal # of nodes # of pods Vertical resources for a node resources for a pod
  • 13. Autoscaling Replication Controllers Autoscaling pods Effort started by Red Hat. AutoScaler: ● abstraction on the top of ReplicationController, ● calls resize on RC, ● RC is unaware of AutoScaler. Two approaches: ● intention based - try to maintain the given value; ● rule based - if the given value is reached, execute the given action (increment/decrement). Proposal
  • 14. Problems Autoscaling pods Simplest solution: AutoScaler acts on a single ReplicationController. However: we often have many RCs for service (e.g.: rolling update). Improved solution: AutoScaler acts on set of RCs (with matching labels): ● monitor selector - RCs to monitor ● target selector - RCs to act on (the largest of them) ● during deployment / rolling update - option to disable decrement How to collect signals: ● cAdvisor → Heapster → InfluxDB ● Google Cloud Monitoring (Google Container Engine) Proposal ???
  • 15. Autoscaling during rolling update Autoscaling pods Replication Controller version 1.4 Auto Scaler Pod Pod Pod Pod ↕
  • 16. Autoscaling during rolling update Autoscaling pods Replication Controller version 1.4 Auto Scaler Pod Pod Pod ↑ Replication Controller version 1.6 Pod Pod
  • 17. Autoscaling during rolling update Autoscaling pods Replication Controller version 1.4 Auto Scaler Pod Pod Replication Controller version 1.6 Pod Pod Pod ↑
  • 18. Autoscaling during rolling update Autoscaling pods Replication Controller version 1.6 Auto Scaler Pod Pod Pod Pod ↕
  • 19. Problems Autosclaing pods Simplest solution: AutoScaler acts on a single ReplicationController. However: we often have many RCs for service (e.g.: rolling update). Improved solution: AutoScaler acts on set of RCs (with matching labels): ● monitor selector - RCs to monitor ● target selector - RCs to act on (the largest of them) ● during deployment / rolling update - option to disable decrement How to collect signals: ● cAdvisor → Heapster → InfluxDB ● Google Cloud Monitoring (Google Container Engine) Proposal ???