Bird
0
0

Which LimitRange YAML snippet achieves this?

hard📝 Workflow Q8 of 15
Kubernetes - Namespaces
You want to enforce a default memory request of 256Mi and a default memory limit of 512Mi for all containers in a namespace, but allow users to override these values up to a max of 1Gi. Which LimitRange YAML snippet achieves this?
AapiVersion: v1 kind: LimitRange metadata: name: mem-limits spec: limits: - type: Container defaultRequest: memory: "256Mi" default: memory: "512Mi" max: memory: "1Gi"
BapiVersion: v1 kind: LimitRange metadata: name: mem-limits spec: limits: - type: Pod defaultRequest: memory: "256Mi" default: memory: "512Mi" max: memory: "1Gi"
CapiVersion: v1 kind: LimitRange metadata: name: mem-limits spec: limits: - type: Container defaultRequest: memory: "512Mi" default: memory: "256Mi" max: memory: "1Gi"
DapiVersion: v1 kind: LimitRange metadata: name: mem-limits spec: limits: - type: Container defaultRequest: memory: "256Mi" max: memory: "512Mi"
Step-by-Step Solution
Solution:
  1. Step 1: Set defaultRequest and default correctly

    Default request 256Mi and default limit 512Mi must be set under type Container.
  2. Step 2: Set max memory to 1Gi

    Max memory limits override must be 1Gi to allow user overrides up to that value.
  3. Final Answer:

    YAML with type Container, defaultRequest 256Mi, default 512Mi, max 1Gi -> Option A
  4. Quick Check:

    Default and max memory limits set correctly = apiVersion: v1 kind: LimitRange metadata: name: mem-limits spec: limits: - type: Container defaultRequest: memory: "256Mi" default: memory: "512Mi" max: memory: "1Gi" [OK]
Quick Trick: Use defaultRequest, default, and max under type Container [OK]
Common Mistakes:
  • Using type Pod instead of Container
  • Swapping default and defaultRequest values
  • Omitting max memory limit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes