0
0
Kubernetesdevops~20 mins

Limit ranges for defaults in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LimitRange Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Default CPU limit from LimitRange
Given this LimitRange YAML applied in a namespace, what is the default CPU limit for a pod container without explicit limits?
Kubernetes
apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-limit-range
spec:
  limits:
  - default:
      cpu: 500m
    defaultRequest:
      cpu: 250m
    type: Container
A500m
B250m
CNo default CPU limit is set
D1000m
Attempts:
2 left
💡 Hint
Look at the 'default' field under 'limits' for CPU.
Configuration
intermediate
2:00remaining
Set default memory request and limit
Which YAML snippet correctly sets a default memory request of 128Mi and a default memory limit of 256Mi for containers in a namespace?
A
apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limits
spec:
  limits:
  - default:
      memory: 128Mi
    defaultRequest:
      memory: 256Mi
    type: Container
B
apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limits
spec:
  limits:
  - default:
      memory: 256Mi
    defaultRequest:
      memory: 128Mi
    type: Pod
C
apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limits
spec:
  limits:
  - defaultRequest:
      memory: 256Mi
    default:
      memory: 128Mi
    type: Container
D
apiVersion: v1
kind: LimitRange
metadata:
  name: mem-limits
spec:
  limits:
  - defaultRequest:
      memory: 128Mi
    default:
      memory: 256Mi
    type: Container
Attempts:
2 left
💡 Hint
Remember defaultRequest is the minimum guaranteed, default is the max limit.
Troubleshoot
advanced
2:30remaining
Pod creation fails due to LimitRange defaults
A pod without resource limits fails to create in a namespace with this LimitRange: apiVersion: v1 kind: LimitRange metadata: name: limit-range spec: limits: - default: cpu: 200m memory: 256Mi max: cpu: 100m memory: 128Mi type: Container What is the reason for the failure?
AThe default max CPU and memory exceed the max allowed, causing a conflict.
BThe pod lacks explicit resource requests, which are mandatory despite defaults.
CThe LimitRange type should be 'Pod' not 'Container'.
DThe default values are lower than the minimum required, causing rejection.
Attempts:
2 left
💡 Hint
Check if default values are within max limits.
🔀 Workflow
advanced
2:00remaining
Applying LimitRange to enforce defaults
You want to enforce default CPU and memory limits on all containers in a namespace without requiring users to specify them. Which workflow step is correct?
AModify the pod spec to include default resource limits in the cluster configuration file.
BCreate a LimitRange with 'default' values for CPU and memory, then apply it to the namespace with kubectl apply.
CUse a PodSecurityPolicy to enforce default CPU and memory limits.
DSet resource quotas with default CPU and memory limits in the namespace.
Attempts:
2 left
💡 Hint
LimitRange is designed to set default resource limits.
Best Practice
expert
3:00remaining
Best practice for setting LimitRange defaults
Which is the best practice when setting default resource limits in a LimitRange to avoid pod failures and resource starvation?
ASet default limits very high to avoid pod failures due to limit exceeded errors.
BSet default requests equal to default limits to prevent any resource bursting.
CSet default requests lower than expected usage and default limits slightly above typical usage to allow burst.
DDo not set default requests or limits; let users specify all resource values explicitly.
Attempts:
2 left
💡 Hint
Think about balancing resource guarantees and flexibility.