Kubernetes - NamespacesYou 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"Check Answer
Step-by-Step SolutionSolution:Step 1: Set defaultRequest and default correctlyDefault request 256Mi and default limit 512Mi must be set under type Container.Step 2: Set max memory to 1GiMax memory limits override must be 1Gi to allow user overrides up to that value.Final Answer:YAML with type Container, defaultRequest 256Mi, default 512Mi, max 1Gi -> Option AQuick 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 ContainerSwapping default and defaultRequest valuesOmitting max memory limit
Master "Namespaces" in Kubernetes9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kubernetes Quizzes Kubernetes Fundamentals - Setting up a local cluster (minikube, kind) - Quiz 3easy Labels and Selectors - Annotations vs labels - Quiz 5medium Pods - Executing commands in Pods - Quiz 6medium Pods - Pod definition in YAML - Quiz 13medium Pods - Viewing Pod details and logs - Quiz 2easy ReplicaSets and Deployments - Deployment as higher-level abstraction - Quiz 7medium ReplicaSets and Deployments - Deployment as higher-level abstraction - Quiz 11easy ReplicaSets and Deployments - Deployment status and history - Quiz 14medium Services - ClusterIP service type - Quiz 6medium kubectl Essential Commands - kubectl get for listing resources - Quiz 11easy