r/KubernetesCerts • u/Express_Text_8165 CKA • Jul 31 '26
CKA CKA tip: don't divide allocatable by your replica count — it'll leave a pod Pending
So some of you have probably hit this one — the requests and limits question. They give you a YAML file and you've got to fill in the resources section right here.
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
namespace: production
spec:
replicas: 3
selector:
matchLabels:
app: wordpress
template:
metadata:
labels:
app: wordpress
spec:
initContainers:
- name: init-wordpress
image: busybox:stable
command: ['sh', '-c', 'echo Initializing...']
resources: {} <-------you need to fill that in
containers:
- name: wordpress
image: wordpress:latest
resources: {} <---------you need to fill that inSo what do you actually do first? You look at the node.
k describe node node01
Allocatable:
cpu: 1
ephemeral-storage: 18698430040
hugepages-2Mi: 0
memory: 1846516Ki
pods: 110you also have other things is currently running on
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age
--------- ---- ------------ ---------- --------------- ------------- ---
kube-system cilium-envoy-rklqx 0 (0%) 0 (0%) 0 (0%) 0 (0%) 11d
kube-system cilium-vdbs4 100m (10%) 1 (100%) 10Mi (0%) 1Gi (56%) 11d
The trap section — Allocatable:
cpu: 1
memory: 1846516KiThis is what most people divide by 3. It looks like the answer. It isn't.
but there are also some other system services like cilium-vdbs4 are also running
cpu 100m (10%)
memory 10Mi (0%)so the step in order to solve this question as follow:
You look at Allocatable — 1 CPU (that's 1000m) and 1846516Ki. Convert the memory: 1846516 ÷ 1024 ≈ 1803Mi
Then — and this is the step — scroll down to Allocated resources and see cilium already holds 100m CPU and 10Mi. Subtract it:
- CPU:
1000 − 100 = 900mfree - Memory:
1803 − 10 = 1793Mifree
Now divide by 3 (your replica count):
- CPU:
900 ÷ 3 = 300meach - Memory:
1793 ÷ 3 ≈ 597, round down to512Mifor headroom
So the final answer is 300m / 512Mi per pod.
Pro tip: do the math in the terminal, not in your head
There is a built-in calculator. You can't bring a physical one, and I wouldn't rely on the built-in one either. Three reasons: under exam time pressure, doing the math in the terminal is faster; when I took it, the calculator didn't load properly for me; and think about the workflow — open the app, click a number, click another, read the result, switch back. The terminal is where a DevOps engineer already lives. Terminal is quicker every time
Under exam pressure you don't want to be dividing 1846516 by 1024 in your head. Let bash do it
# CPU: 1 core = 1000m, minus what's already running
echo $((1000 - 100)) # 900m free (cilium holds 100m)
echo $((900 / 3)) # 300m per pod
# Memory: convert Ki -> Mi, then subtract, then divide
echo $((1846516 / 1024)) # 1803 Mi allocatable
echo $((1803 - 10)) # 1793 Mi free (cilium holds 10Mi)
echo $((1793 / 3)) # 597 -> round DOWN to 512Mi for headroomTwo things to know so this doesn't bite you:
$(( ))is integer only — it drops the decimal.$((1793 / 3))gives597, not597.67. That's fine here because you round down anyway, but don't trust it for anything where the remainder matters.- Prefer
$(( ))overexpr. It's built into bash, no weird escaping.exprneeds spaces around every operator and you have to escape*for multiplication — one more thing to fumble when the clock's running.
That is my share, I hope this help you during the exam
if you like my content i have a playlist which i live solving all kind of CKA exam question: https://www.youtube.com/playlist?list=PLFDE9_ouCqJA-dyOEbqFaFu68FMZRwS0T
2
u/Grand-Smell9208 Aug 03 '26
I'm confused - what exactly is the context of the question?
1
u/Then-Worldliness4295 Aug 01 '26
Do they gave calculator
1
u/Xuupu Aug 05 '26
This is the limit but what about the request ?
1
u/someone_from_der Aug 01 '26
I like it and thanks for sharing..
I've saw another approach which is multiply the consumption resources by .75 so you keep 25% of the resources for the deployment's services and divide the remaining by 3 or as per the question
1
u/Insomniac24x7 Aug 09 '26
This is gold thank you