nerdexam
Linux_Foundation

CKA · Question #49

Create a new HorizontalPodAutoscaler (HPA) named apache-server in the autoscale namespace. This HPA must target the existing Deployment called apache-server in the autoscale namespace. Set the HPA…

1. Connect to the correct host: ssh cka000050 2. Verify the deployment exists: kubectl get deployment apache-server -n autoscale (Make sure it's there before creating the HPA, otherwise the HPA won't bind correctly.) 3. Create the HPA: kubectl autoscale deployment apache-server…

Submitted by saadiq_pk· May 4, 2026Workloads and Scheduling

Question

Create a new HorizontalPodAutoscaler (HPA) named apache-server in the autoscale namespace. This HPA must target the existing Deployment called apache-server in the autoscale namespace. Set the HPA to aim for 50% CPU usage per Pod . Configure it to have at least 1 Pod and no more than 4 Pods . Also, set the downscale stabilization window to 30 seconds.

Explanation

  1. Connect to the correct host: ssh cka000050

  2. Verify the deployment exists: kubectl get deployment apache-server -n autoscale (Make sure it's there before creating the HPA, otherwise the HPA won't bind correctly.)

  3. Create the HPA: kubectl autoscale deployment apache-server
    --namespace autoscale
    --cpu-percent=50
    --min=1
    --max=4

  4. Add the downscale stabilization window: (You'll need to patch the HPA to include the stabilization window of 30s.) Create a patch file called hpa-patch.yaml: cat <<EOF > hpa-patch.yaml spec: behavior: scaleDown: stabilizationWindowSeconds: 30 EOF Apply the patch: kubectl patch hpa apache-server -n autoscale --patch "$(cat hpa-patch.yaml)"

  5. Confirm your work: kubectl describe hpa apache-server -n autoscale (Look for: Min/Max Pods: 1/4, Target CPU utilization: 50%, Stabilization window: should appear under Behavior > ScaleDown)

Topics

#HorizontalPodAutoscaler#Scaling#Deployments#CPU metrics

Community Discussion

No community discussion yet for this question.

Full CKA Practice