SlideShare a Scribd company logo
Kubernetes Requests and Limits
Managing containers resources in Kubernetes
Ahmed AbouZaid, DevOps Engineer, Camunda
23.06.2021
2
Ahmed AbouZaid
A passionate DevOps engineer, Cloud/Kubernetes
specialist, Free/Open source geek, and an author.
I believe in self CI/CD
(Continuous Improvements/Development),
also that "the whole is greater than the sum of its parts".
DevOps transformation, automation, data, and metrics
are my preferred areas. And I like to help both
businesses and people to grow.
Find me at:
tech.aabouzaid.com | linkedin.com/in/aabouzaid
About
September 2017, who says a penguin can't fly?
3
Agenda
• Overview
• Containers, Docker, and Kubernetes
• Containers resource management
• Containers resource types
• Setting requests and limits
• Capacity and allocatable resources
• Tips and recap
Overview
5
Overview
Kubernetes is a container orchestration platform that provides a mechanism to
manage the resources of containers in the cluster.
That mechanism plays a role not only in managing the cluster resources but also
in scheduling the resources (i.e., on which node the pod will be running).
In this session, first, we will have a look at units of the Kubernetes cluster, then
how containers resource are managed, what kind of resources are managed,
then the difference between the cluster capacity and allocatable resources, then
requests and limits the scope, and finally tips and recap.
Containers, Docker, and Kubernetes
7
Containers, Docker, and Kubernetes
Containers
Technology for packaging an application
along with its runtime dependencies
Docker
Docker is the de facto standard to build
and share containerized apps
Kubernetes
A cloud-native platform to manage and
orchestrate containers workloads
8
Containers, Docker, and Kubernetes (continued)
Cluster
A collection of nodes that are grouped
together to provide resources sharing
and workload balancing
Node
The unit of computing in Kubernetes,
easily thought of as one individual machine
which runs Pods.
Pod
A logical host with collection of one
or more container, and it is the smallest
computing unit in Kubernetes Image source:
Kubernetes docs - Managing Resources for Containers
Containers resource management
10
Containers resource management
• Kubernetes allows to optionally set
how much resources a container needs
via “Requests and Limits”.
• The most common resources to specify
are CPU and memory.
• Requests and limits play a key role not
only in resource management but also
for stability and capacity planning.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: myimage
resources:
requests:
cpu: "1"
memory: "64Mi"
ephemeral-storage: "20Gi"
limits:
cpu: "2"
memory: "128Mi"
ephemeral-storage: "50Gi"
11
Containers resource management (continued)
Image source:
Learnk8s - Setting the right requests and limits in Kubernetes
What are requests and limits?
Requests and limits are the mechanisms
Kubernetes uses to control containers resources
such as CPU, memory, and ephemeral storage.
1. Requests: resources that container is guaranteed
to get by Kubernetes. It’s the minimum amount of
resources that are needed to work.
2. Limits: resources that container should not pass.
The container is only allowed to go up to that
threshold, otherwise Kubernetes will restrict it.
Containers resource types
13
Containers resource types (continued)
There are 3 core resources that could be configured via requests and limits:
(those resources used from underneath nodes)
• CPU
Measured in 1 vCPU/Core; thus, half of CPU core represented as “0.5”
which also equivalent to “500m”.
• Memory
Measured in bytes and can expressed as a plain integer or using suffixes, the
following are same value: “128974848”, “129M”, “123Mi”.
• Local ephemeral storage (e.g. ‘emptyDir’ volume)
Measured in bytes and can expressed as a plain integer or using suffixes, the
following are same value: “128974848”, “129M”, “123Mi”.
14
Containers resource types (continued)
What happens if a container
exceeded the configured limits?
• CPU
Kubernetes will enter “overcommit”
state and will just “throttle” (limit)
the container’s usage.
• Memory or ephemeral storage
Kubernetes will “evict” (kill)
the container’s pod and recreate it. Image source:
ITNEXT - Easy and Fast Adjustment of Kubernetes CPU and Memory
Setting requests and limits
16
Kubernetes requests and limits could be
specified in 3 ways:
1. Container settings (Pod level)
Each container in a pod able to
configures their own requests
and limits.
Setting requests and limits
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: myimage
resources:
requests:
cpu: "1"
memory: "64Mi"
ephemeral-storage: "20Gi"
limits:
cpu: "2"
memory: "128Mi"
ephemeral-storage: "50Gi"
17
2. LimitRange (Namespace level)
Configure resources for “every”
individual container in a namespace.
It helps to set default, min, and max
resources in the namespace.
Setting requests and limits (continued)
apiVersion: v1
kind: LimitRange
metadata:
name: dev-ns-limits
namespace: default
spec:
limits:
- type: Container
defaultRequest:
cpu: "1"
18
3. ResourceQuota (Namespace level)
Configure the “whole” resources in
a namespace. For example, setting
max CPU to “2” means all containers
“combined” in the namespace cannot
exceed 2 cores (1 container gets 2
cores, 2 containers get 1 core each, etc).
Setting requests and limits (continued)
apiVersion: v1
kind: ResourceQuota
metadata:
name: dev-team-quota
spec:
hard:
requests.cpu: "1"
requests.memory: 1Gi
limits.cpu: "2"
limits.memory: 2Gi
Capacity and allocatable resources
20
Capacity and allocatable resources
The maximum resources available for
any container is the maximum resources
on a single Kubernetes node.
However, not all Kubernetes node resources
is available for the pods.
Part of the node resources are saved for
Kubernetes agent essential components,
operating system, and eviction threshold.
• Capacity: total node resources.
• Allocatable: resources available for Pods.
Allocatable resources vary between cloud providers
but usually they are around 75% of the total capacity
Image source:
Learnk8s - Allocatable memory and CPU in Kubernetes Nodes
Tips and recap
22
Tips and recap
• Requests and limits play a key role not only in resource management
but also applications stability and capacity planning.
• Requests cannot configured to be more than limits.
• Requests and limits cannot be greater than the biggest Kubernetes node.
• Not all resources in Kubernetes nodes can be used to run Pods
you get in average about 75% of the total nodes resources.
• Pods with no requests and limits are more likely to be evicted first.
• When you set requests and limits for the first time, start with a small value
then adjust by monitoring your application usage for accurate values.
• Inaccurate requests and limits is waste of money and resources!
References
24
References
• What is a Kubernetes pod?
redhat.com/en/topics/containers/what-is-kubernetes-pod
• Managing Resources for Containers
kubernetes.io/docs/concepts/configuration/manage-resources-containers
• Kubernetes best practices: Resource requests and limits
cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-reso
urce-requests-and-limits
• Easy and Fast Adjustment of Kubernetes CPU and Memory
itnext.io/easy-and-fast-adjustment-of-kubernetes-cpu-and-memory-709394cc2cb1
• Setting the right requests and limits in Kubernetes
learnk8s.io/setting-cpu-memory-limits-requests
• Allocatable memory and CPU in Kubernetes Nodes
learnk8s.io/allocatable-resources
25
Questions? :-)

More Related Content

What's hot

Kubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesKubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best Practices
Ajeet Singh Raina
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
Megan O'Keefe
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
Krishna-Kumar
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Docker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityDocker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
Kubernetes and Prometheus
Kubernetes and PrometheusKubernetes and Prometheus
Kubernetes and Prometheus
Weaveworks
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
Jacopo Nardiello
 
Building an Active-Active IBM MQ System
Building an Active-Active IBM MQ SystemBuilding an Active-Active IBM MQ System
Building an Active-Active IBM MQ System
matthew1001
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Etsuji Nakai
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
Stefan Schimanski
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen
 
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
 Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra... Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
HostedbyConfluent
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
Akash Agrawal
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
Sathish VJ
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
iammutex
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
Rishabh Kumar
 
An overview of the Kubernetes architecture
An overview of the Kubernetes architectureAn overview of the Kubernetes architecture
An overview of the Kubernetes architecture
Igor Sfiligoi
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with Kubernetes
Deivid Hahn Fração
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
Crevise Technologies
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
Bob Killen
 

What's hot (20)

Kubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesKubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best Practices
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Kubernetes 101 Workshop
 
Docker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityDocker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and security
 
Kubernetes and Prometheus
Kubernetes and PrometheusKubernetes and Prometheus
Kubernetes and Prometheus
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Building an Active-Active IBM MQ System
Building an Active-Active IBM MQ SystemBuilding an Active-Active IBM MQ System
Building an Active-Active IBM MQ System
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
 
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
 Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra... Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
An overview of the Kubernetes architecture
An overview of the Kubernetes architectureAn overview of the Kubernetes architecture
An overview of the Kubernetes architecture
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with Kubernetes
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
 

Similar to Kubernetes Requests and Limits

Meetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on KubernetesMeetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on Kubernetes
dtoledo67
 
Lc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangyaLc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangya
Sahdev Zala
 
Kubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch IIKubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch II
PT Datacomm Diangraha
 
Nodeless and serverless kubernetes
Nodeless and serverless kubernetesNodeless and serverless kubernetes
Nodeless and serverless kubernetes
Nills Franssens
 
Knolx Goldilocks
Knolx GoldilocksKnolx Goldilocks
Knolx Goldilocks
Knoldus Inc.
 
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev Conference
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-Hassan
Syed Murtaza Hassan
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to Kubernetes
Ronny Trommer
 
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Amazon Web Services Korea
 
Kubernetes and bluemix
Kubernetes  and  bluemixKubernetes  and  bluemix
Kubernetes and bluemix
DuckDuckGo
 
A guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on KubernetesA guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on Kubernetes
t8kobayashi
 
Kubernetes Internals
Kubernetes InternalsKubernetes Internals
Kubernetes Internals
Shimi Bandiel
 
Managing Stateful Applications in Kubernetes
Managing Stateful Applications in KubernetesManaging Stateful Applications in Kubernetes
Managing Stateful Applications in Kubernetes
All Things Open
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby Steps
DigitalOcean
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
Knoldus Inc.
 
Kubecon US 2019: Kubernetes Multitenancy WG Deep Dive
Kubecon US 2019: Kubernetes Multitenancy WG Deep DiveKubecon US 2019: Kubernetes Multitenancy WG Deep Dive
Kubecon US 2019: Kubernetes Multitenancy WG Deep Dive
Sanjeev Rampal
 
Kubernetes Problem-Solving
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-Solving
All Things Open
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
VMUG IT
 
Kubernetes presentation
Kubernetes presentationKubernetes presentation
Kubernetes presentation
GauranG Bajpai
 

Similar to Kubernetes Requests and Limits (20)

Meetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on KubernetesMeetup 12-12-2017 - Application Isolation on Kubernetes
Meetup 12-12-2017 - Application Isolation on Kubernetes
 
Lc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangyaLc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangya
 
Kubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch IIKubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch II
 
Nodeless and serverless kubernetes
Nodeless and serverless kubernetesNodeless and serverless kubernetes
Nodeless and serverless kubernetes
 
Knolx Goldilocks
Knolx GoldilocksKnolx Goldilocks
Knolx Goldilocks
 
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-Hassan
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to Kubernetes
 
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
 
Kubernetes and bluemix
Kubernetes  and  bluemixKubernetes  and  bluemix
Kubernetes and bluemix
 
A guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on KubernetesA guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on Kubernetes
 
Kubernetes Internals
Kubernetes InternalsKubernetes Internals
Kubernetes Internals
 
Managing Stateful Applications in Kubernetes
Managing Stateful Applications in KubernetesManaging Stateful Applications in Kubernetes
Managing Stateful Applications in Kubernetes
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby Steps
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Kubecon US 2019: Kubernetes Multitenancy WG Deep Dive
Kubecon US 2019: Kubernetes Multitenancy WG Deep DiveKubecon US 2019: Kubernetes Multitenancy WG Deep Dive
Kubecon US 2019: Kubernetes Multitenancy WG Deep Dive
 
Kubernetes Problem-Solving
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-Solving
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
 
Kubernetes presentation
Kubernetes presentationKubernetes presentation
Kubernetes presentation
 

More from Ahmed AbouZaid

Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and CrossplanePlatform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Ahmed AbouZaid
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS exam
Ahmed AbouZaid
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
Ahmed AbouZaid
 
DevOps for Engineers
DevOps for EngineersDevOps for Engineers
DevOps for Engineers
Ahmed AbouZaid
 
How contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOpsHow contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOps
Ahmed AbouZaid
 
Developing Ansible Dynamic Inventory Script - Nov 2017
Developing Ansible Dynamic Inventory Script - Nov 2017Developing Ansible Dynamic Inventory Script - Nov 2017
Developing Ansible Dynamic Inventory Script - Nov 2017
Ahmed AbouZaid
 
Introduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK StackIntroduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK Stack
Ahmed AbouZaid
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
Ahmed AbouZaid
 
Why Ubuntu? - Arabic
Why Ubuntu? - ArabicWhy Ubuntu? - Arabic
Why Ubuntu? - Arabic
Ahmed AbouZaid
 

More from Ahmed AbouZaid (9)

Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and CrossplanePlatform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS exam
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
 
DevOps for Engineers
DevOps for EngineersDevOps for Engineers
DevOps for Engineers
 
How contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOpsHow contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOps
 
Developing Ansible Dynamic Inventory Script - Nov 2017
Developing Ansible Dynamic Inventory Script - Nov 2017Developing Ansible Dynamic Inventory Script - Nov 2017
Developing Ansible Dynamic Inventory Script - Nov 2017
 
Introduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK StackIntroduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK Stack
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Why Ubuntu? - Arabic
Why Ubuntu? - ArabicWhy Ubuntu? - Arabic
Why Ubuntu? - Arabic
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 

Kubernetes Requests and Limits

  • 1. Kubernetes Requests and Limits Managing containers resources in Kubernetes Ahmed AbouZaid, DevOps Engineer, Camunda 23.06.2021
  • 2. 2 Ahmed AbouZaid A passionate DevOps engineer, Cloud/Kubernetes specialist, Free/Open source geek, and an author. I believe in self CI/CD (Continuous Improvements/Development), also that "the whole is greater than the sum of its parts". DevOps transformation, automation, data, and metrics are my preferred areas. And I like to help both businesses and people to grow. Find me at: tech.aabouzaid.com | linkedin.com/in/aabouzaid About September 2017, who says a penguin can't fly?
  • 3. 3 Agenda • Overview • Containers, Docker, and Kubernetes • Containers resource management • Containers resource types • Setting requests and limits • Capacity and allocatable resources • Tips and recap
  • 5. 5 Overview Kubernetes is a container orchestration platform that provides a mechanism to manage the resources of containers in the cluster. That mechanism plays a role not only in managing the cluster resources but also in scheduling the resources (i.e., on which node the pod will be running). In this session, first, we will have a look at units of the Kubernetes cluster, then how containers resource are managed, what kind of resources are managed, then the difference between the cluster capacity and allocatable resources, then requests and limits the scope, and finally tips and recap.
  • 7. 7 Containers, Docker, and Kubernetes Containers Technology for packaging an application along with its runtime dependencies Docker Docker is the de facto standard to build and share containerized apps Kubernetes A cloud-native platform to manage and orchestrate containers workloads
  • 8. 8 Containers, Docker, and Kubernetes (continued) Cluster A collection of nodes that are grouped together to provide resources sharing and workload balancing Node The unit of computing in Kubernetes, easily thought of as one individual machine which runs Pods. Pod A logical host with collection of one or more container, and it is the smallest computing unit in Kubernetes Image source: Kubernetes docs - Managing Resources for Containers
  • 10. 10 Containers resource management • Kubernetes allows to optionally set how much resources a container needs via “Requests and Limits”. • The most common resources to specify are CPU and memory. • Requests and limits play a key role not only in resource management but also for stability and capacity planning. apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: my-container image: myimage resources: requests: cpu: "1" memory: "64Mi" ephemeral-storage: "20Gi" limits: cpu: "2" memory: "128Mi" ephemeral-storage: "50Gi"
  • 11. 11 Containers resource management (continued) Image source: Learnk8s - Setting the right requests and limits in Kubernetes What are requests and limits? Requests and limits are the mechanisms Kubernetes uses to control containers resources such as CPU, memory, and ephemeral storage. 1. Requests: resources that container is guaranteed to get by Kubernetes. It’s the minimum amount of resources that are needed to work. 2. Limits: resources that container should not pass. The container is only allowed to go up to that threshold, otherwise Kubernetes will restrict it.
  • 13. 13 Containers resource types (continued) There are 3 core resources that could be configured via requests and limits: (those resources used from underneath nodes) • CPU Measured in 1 vCPU/Core; thus, half of CPU core represented as “0.5” which also equivalent to “500m”. • Memory Measured in bytes and can expressed as a plain integer or using suffixes, the following are same value: “128974848”, “129M”, “123Mi”. • Local ephemeral storage (e.g. ‘emptyDir’ volume) Measured in bytes and can expressed as a plain integer or using suffixes, the following are same value: “128974848”, “129M”, “123Mi”.
  • 14. 14 Containers resource types (continued) What happens if a container exceeded the configured limits? • CPU Kubernetes will enter “overcommit” state and will just “throttle” (limit) the container’s usage. • Memory or ephemeral storage Kubernetes will “evict” (kill) the container’s pod and recreate it. Image source: ITNEXT - Easy and Fast Adjustment of Kubernetes CPU and Memory
  • 16. 16 Kubernetes requests and limits could be specified in 3 ways: 1. Container settings (Pod level) Each container in a pod able to configures their own requests and limits. Setting requests and limits apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: my-container image: myimage resources: requests: cpu: "1" memory: "64Mi" ephemeral-storage: "20Gi" limits: cpu: "2" memory: "128Mi" ephemeral-storage: "50Gi"
  • 17. 17 2. LimitRange (Namespace level) Configure resources for “every” individual container in a namespace. It helps to set default, min, and max resources in the namespace. Setting requests and limits (continued) apiVersion: v1 kind: LimitRange metadata: name: dev-ns-limits namespace: default spec: limits: - type: Container defaultRequest: cpu: "1"
  • 18. 18 3. ResourceQuota (Namespace level) Configure the “whole” resources in a namespace. For example, setting max CPU to “2” means all containers “combined” in the namespace cannot exceed 2 cores (1 container gets 2 cores, 2 containers get 1 core each, etc). Setting requests and limits (continued) apiVersion: v1 kind: ResourceQuota metadata: name: dev-team-quota spec: hard: requests.cpu: "1" requests.memory: 1Gi limits.cpu: "2" limits.memory: 2Gi
  • 20. 20 Capacity and allocatable resources The maximum resources available for any container is the maximum resources on a single Kubernetes node. However, not all Kubernetes node resources is available for the pods. Part of the node resources are saved for Kubernetes agent essential components, operating system, and eviction threshold. • Capacity: total node resources. • Allocatable: resources available for Pods. Allocatable resources vary between cloud providers but usually they are around 75% of the total capacity Image source: Learnk8s - Allocatable memory and CPU in Kubernetes Nodes
  • 22. 22 Tips and recap • Requests and limits play a key role not only in resource management but also applications stability and capacity planning. • Requests cannot configured to be more than limits. • Requests and limits cannot be greater than the biggest Kubernetes node. • Not all resources in Kubernetes nodes can be used to run Pods you get in average about 75% of the total nodes resources. • Pods with no requests and limits are more likely to be evicted first. • When you set requests and limits for the first time, start with a small value then adjust by monitoring your application usage for accurate values. • Inaccurate requests and limits is waste of money and resources!
  • 24. 24 References • What is a Kubernetes pod? redhat.com/en/topics/containers/what-is-kubernetes-pod • Managing Resources for Containers kubernetes.io/docs/concepts/configuration/manage-resources-containers • Kubernetes best practices: Resource requests and limits cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-reso urce-requests-and-limits • Easy and Fast Adjustment of Kubernetes CPU and Memory itnext.io/easy-and-fast-adjustment-of-kubernetes-cpu-and-memory-709394cc2cb1 • Setting the right requests and limits in Kubernetes learnk8s.io/setting-cpu-memory-limits-requests • Allocatable memory and CPU in Kubernetes Nodes learnk8s.io/allocatable-resources