0
0
Kubernetesdevops~20 mins

Scaling Deployments in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scaling Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Scaling a Deployment Using kubectl
You have a Kubernetes deployment named webapp currently running 3 replicas. You run the command kubectl scale deployment webapp --replicas=5. What will be the state of the deployment after this command completes?
AThe deployment will have 5 pods running, scaling up from 3.
BThe deployment will remain at 3 pods because scaling requires editing the YAML file.
CThe deployment will have 8 pods running, adding 5 to the existing 3.
DThe deployment will be deleted and recreated with 5 pods.
Attempts:
2 left
💡 Hint
Think about what the --replicas flag does in the scale command.
🧠 Conceptual
intermediate
2:00remaining
Understanding Horizontal Pod Autoscaler (HPA)
Which statement correctly describes how the Horizontal Pod Autoscaler (HPA) works in Kubernetes?
AHPA automatically adjusts the number of pod replicas based on observed CPU utilization or other select metrics.
BHPA manually scales pods only when a user runs a scaling command.
CHPA replaces the deployment controller to manage pods.
DHPA scales the number of nodes in the cluster based on pod demand.
Attempts:
2 left
💡 Hint
Think about what metrics HPA uses to decide scaling.
Configuration
advanced
3:00remaining
Configuring a Deployment for Auto Scaling
You want to create a Horizontal Pod Autoscaler for a deployment named api-server that scales between 2 and 10 replicas based on CPU usage targeting 60%. Which YAML snippet correctly defines this HPA?
A
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: api-server-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-server
  replicas: 5
  targetCPUUtilizationPercentage: 60
B
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: api-server-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-server
  minReplicas: 10
  maxReplicas: 2
  targetCPUUtilizationPercentage: 60
C
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-server-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-server
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 60
D
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-server-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-server
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 60
Attempts:
2 left
💡 Hint
Check minReplicas and maxReplicas values and metric type.
Troubleshoot
advanced
2:30remaining
Troubleshooting Failed Scaling of Deployment
You applied an HPA to scale your deployment frontend based on CPU usage, but the number of pods never changes even when CPU usage is high. Which of the following is the most likely cause?
AThe deployment has a fixed replica count set in its YAML file.
BThe metrics-server is not installed or not running in the cluster.
CThe pods are using too much memory instead of CPU.
DThe HPA resource is missing the minReplicas field.
Attempts:
2 left
💡 Hint
HPA depends on metrics to decide scaling.
🔀 Workflow
expert
3:00remaining
Scaling Deployment with Zero Downtime
You need to scale your payment-service deployment from 3 to 6 replicas without causing downtime. Which sequence of commands ensures zero downtime during scaling?
A
kubectl set image deployment payment-service payment-service=payment-service:v2
kubectl scale deployment payment-service --replicas=6
B
kubectl delete pods -l app=payment-service
kubectl scale deployment payment-service --replicas=6
C
kubectl scale deployment payment-service --replicas=6
kubectl rollout status deployment payment-service
D
kubectl scale deployment payment-service --replicas=6
kubectl rollout undo deployment payment-service
Attempts:
2 left
💡 Hint
Think about how Kubernetes manages pods during scaling and rollout.