0
0
Kubernetesdevops~10 mins

Cost optimization in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a resource limit for CPU in a pod specification.

Kubernetes
resources:
  limits:
    cpu: [1]
Drag options to blanks, or click blank then click option'
A500m
B2CPU
C1000Mi
D2GB
Attempts:
3 left
💡 Hint
Common Mistakes
Using memory units like '2GB' for CPU limits
Using '2CPU' which is not a valid unit
2fill in blank
medium

Complete the command to view the current resource usage of pods in a namespace.

Kubernetes
kubectl top pods -n [1]
Drag options to blanks, or click blank then click option'
Asystem
Bdefault
Call
Dkube-system
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'all' which is not a valid namespace
Using 'kube-system' which is for system pods
3fill in blank
hard

Fix the error in the YAML snippet to request 1 CPU core for a container.

Kubernetes
resources:
  requests:
    cpu: [1]
Drag options to blanks, or click blank then click option'
A1Mi
B1GB
C1000m
Done
Attempts:
3 left
💡 Hint
Common Mistakes
Using memory units like '1GB' or '1Mi'
Using words like 'one' instead of numeric units
4fill in blank
hard

Fill both blanks to create a Horizontal Pod Autoscaler that scales between 2 and 5 replicas based on CPU usage.

Kubernetes
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: example-hpa
spec:
  minReplicas: [1]
  maxReplicas: [2]
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
Drag options to blanks, or click blank then click option'
A2
B10
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting maxReplicas lower than minReplicas
Using very high maxReplicas causing cost spikes
5fill in blank
hard

Fill all three blanks to create a resource quota limiting pods and CPU usage in a namespace.

Kubernetes
apiVersion: v1
kind: ResourceQuota
metadata:
  name: cpu-pod-quota
spec:
  hard:
    pods: [1]
    requests.cpu: [2]
    limits.cpu: [3]
Drag options to blanks, or click blank then click option'
A10
B4
C8
D1000m
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing CPU units with pod counts
Using invalid CPU units like '4' without units