← Back to list

Real CKA Question 1 of 17 — Create a Horizontal Pod Autoscaler (HPA)

I will walk through 17 questions from my Certified Kubernetes Administrator (CKA) exam, which I successfully passed. The questions…

Manohar Shetty · 2026-03-06 16:00 · 2 claps · 2.5 min read paywalled
#cka #cks-exam #cka-exam #kubernetes #hpa
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud

Real CKA Question 1 of 17 — Create a Horizontal Pod Autoscaler (HPA)

I will walk through 17 questions from my Certified Kubernetes Administrator (CKA) exam, which I successfully passed. The questions presented here are the same ones I encountered during the exam.

The goal of this blog is to demonstrate how these tasks can be approached and solved in a practical way, similar to the real exam environment. Each question focuses on core Kubernetes administration skills and the command-line techniques needed to complete tasks efficiently.

By going through these questions step by step, you will understand how to approach similar problems during the CKA exam and improve your ability to solve them quickly under time pressure.

You can read the free version here if you don’t have a Medium Premium subscription:

[embed]Real CKA Question 1 of 17 — Create a Horizontal Pod Autoscaler (HPA) I will walk through 17 questions from my Certified Kubernetes Administrator (CKA) exam, which I successfully passed…medium.com

You can also consider enrolling in the full course where I solve all 17 questions in detail:

https://www.udemy.com/course/cka-2026-latest-exam-17-real-exam-questions-with-solutions/

The Certified Kubernetes Administrator exam is not a theory contest. It is a keyboard exam. You are dropped into a cluster and expected to make Kubernetes obey you. No slides, no excuses, just YAML and commands. Question 1 in many practice sets focuses on Horizontal Pod Autoscaling (HPA) — a mechanism that lets Kubernetes increase or decrease pods automatically based on metrics like CPU usage.

Think of HPA as a thermostat for your application. When CPU usage rises, Kubernetes adds more pods. When load drops, it removes them. The cluster continuously watches metrics and adjusts the number of replicas to keep the system balanced. Elegant idea. Brutally practical in real clusters.

Now let’s walk through the task.

Problem Statement

Create a new Horizontal Pod Autoscaler named apache-server in the autoscale namespace.

Requirements:

  • Target Deployment: apache-server
  • Namespace: autoscale
  • Target CPU usage: 50%
  • Minimum pods: 1
  • Maximum pods: 4
  • Downscale stabilization window: 30 seconds

Step 1 — Verify the Deployment Exists

Before creating autoscaling rules, check if the deployment actually exists. Blind configuration is how people waste time in the exam.

kubectl get deploy -n autoscale

You should see:

apache-server

If it isn’t there, nothing will scale.

Step 2— Create the HPA

In the exam, speed matters. The fastest way is using the kubectl autoscale command.

kubectl autoscale deployment apache-server --cpu-percent=50 --min=1 --max=4 
-n autoscale --dry-run=client -o yaml > hpa.yaml

This creates the Horizontal Pod Autoscaler.

What this actually does:

  • kubectl autoscale generates the HPA • --dry-run=client prevents it from being created in the cluster • -o yaml prints the YAML • > saves it into hpa.yaml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  creationTimestamp: null
  name: apache-server
  namespace: autoscale
spec:
  maxReplicas: 4
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: apache-server
  targetCPUUtilizationPercentage: 50
status:
  currentReplicas: 0
  desiredReplicas: 0

Now open the file and add the stabilization window because the autoscale command does not generate behavior rules.

Edit it:

vim hpa.yaml

Add this under spec:

behavior:
  scaleDown:
    stabilizationWindowSeconds: 30

The final structure should look like this:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: apache-server
  namespace: autoscale
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: apache-server
  minReplicas: 1
  maxReplicas: 4
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 30

Then apply it:

kubectl apply -f hpa.yaml

Quick verification:

kubectl get hpa -n autoscale

A practical CKA survival trick: always dry-run and redirect to YAML when possible. Humans make typos. Kubernetes never forgives them. Generating YAML from kubectl removes half the mistakes candidates make under exam pressure.


메타데이터
post_id
419e265fdb38
slug
real-cka-question-1-of-17-create-a-horizontal-pod-autoscaler-hpa-419e265fdb38
url
https://medium.com/@tradingcontentdrive/real-cka-question-1-of-17-create-a-horizontal-pod-autoscaler-hpa-419e265fdb38
canonical_url
https://medium.com/@tradingcontentdrive/real-cka-question-1-of-17-create-a-horizontal-pod-autoscaler-hpa-419e265fdb38
author_url
https://medium.com/@tradingcontentdrive
status
ok
fetched_at
2026-06-11 15:16:29