SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
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? :-)

Mais conteúdo relacionado

Mais procurados

DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesRonny Trommer
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for BeginnersOktay Esgul
 
Kubernetes Networking 101
Kubernetes Networking 101Kubernetes Networking 101
Kubernetes Networking 101Weaveworks
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopSathish VJ
 
Extending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsExtending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsStefan Schimanski
 
Kubernetes
KubernetesKubernetes
Kuberneteserialc_w
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overviewGabriel Carro
 
Writing the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golangWriting the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golangHungWei Chiu
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewBob Killen
 
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeAcademy
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Megan O'Keefe
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Edureka!
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsRamit Surana
 
Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced schedulingTerry Cho
 
Container Security Deep Dive & Kubernetes
Container Security Deep Dive & Kubernetes Container Security Deep Dive & Kubernetes
Container Security Deep Dive & Kubernetes Aqua Security
 
Multi-cloud Kubernetes BCDR with Velero
Multi-cloud Kubernetes BCDR with VeleroMulti-cloud Kubernetes BCDR with Velero
Multi-cloud Kubernetes BCDR with VeleroKublr
 
Helm – The package manager for Kubernetes
Helm – The package manager for KubernetesHelm – The package manager for Kubernetes
Helm – The package manager for KubernetesFabianRosenthal1
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes NetworkingCJ Cullen
 

Mais procurados (20)

Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to Kubernetes
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for Beginners
 
01. Kubernetes-PPT.pptx
01. Kubernetes-PPT.pptx01. Kubernetes-PPT.pptx
01. Kubernetes-PPT.pptx
 
Kubernetes Networking 101
Kubernetes Networking 101Kubernetes Networking 101
Kubernetes Networking 101
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Extending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitionsExtending kubernetes with CustomResourceDefinitions
Extending kubernetes with CustomResourceDefinitions
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
 
Writing the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golangWriting the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golang
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive Overview
 
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its components
 
Kubernetes #6 advanced scheduling
Kubernetes #6   advanced schedulingKubernetes #6   advanced scheduling
Kubernetes #6 advanced scheduling
 
Container Security Deep Dive & Kubernetes
Container Security Deep Dive & Kubernetes Container Security Deep Dive & Kubernetes
Container Security Deep Dive & Kubernetes
 
Multi-cloud Kubernetes BCDR with Velero
Multi-cloud Kubernetes BCDR with VeleroMulti-cloud Kubernetes BCDR with Velero
Multi-cloud Kubernetes BCDR with Velero
 
Helm – The package manager for Kubernetes
Helm – The package manager for KubernetesHelm – The package manager for Kubernetes
Helm – The package manager for Kubernetes
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 

Semelhante a 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 Kubernetesdtoledo67
 
Lc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangyaLc3 beijing-june262018-sahdev zala-guangya
Lc3 beijing-june262018-sahdev zala-guangyaSahdev Zala
 
Kubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch IIKubernetes Basics - ICP Workshop Batch II
Kubernetes Basics - ICP Workshop Batch IIPT Datacomm Diangraha
 
Nodeless and serverless kubernetes
Nodeless and serverless kubernetesNodeless and serverless kubernetes
Nodeless and serverless kubernetesNills Franssens
 
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин Владев
PlovDev 2016: Оркестрация на контейнери с Kubernetes - Мартин ВладевPlovDev Conference
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanSyed Murtaza Hassan
 
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 bluemixDuckDuckGo
 
A guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on KubernetesA guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on Kubernetest8kobayashi
 
Kubernetes Internals
Kubernetes InternalsKubernetes Internals
Kubernetes InternalsShimi Bandiel
 
Managing Stateful Applications in Kubernetes
Managing Stateful Applications in KubernetesManaging Stateful Applications in Kubernetes
Managing Stateful Applications in KubernetesAll Things Open
 
Kubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsKubernetes: Beyond Baby Steps
Kubernetes: Beyond Baby StepsDigitalOcean
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxKnoldus 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 DiveSanjeev Rampal
 
Kubernetes Problem-Solving
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-SolvingAll 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, VMwareVMUG IT
 
Kubernetes presentation
Kubernetes presentationKubernetes presentation
Kubernetes presentationGauranG Bajpai
 
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdf
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdfImplementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdf
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdfssuserf4844f
 
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBuilding Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBitnami
 

Semelhante a 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 - Мартин Владев
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-Hassan
 
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
 
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdf
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdfImplementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdf
Implementing-SaaS-on-Kubernetes-Michael-Knapp-Andrew-Gao-Capital-One.pdf
 
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBuilding Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
 

Mais de 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 CrossplaneAhmed 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 examAhmed AbouZaid
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices WorkshopAhmed 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 DevOpsAhmed 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 2017Ahmed AbouZaid
 
Introduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK StackIntroduction to InfluxDB and TICK Stack
Introduction to InfluxDB and TICK StackAhmed AbouZaid
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with AnsibleAhmed AbouZaid
 

Mais de 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
 

Último

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

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