Challenge, Easy,  on  Kubernetes

Enforce Resource Policies Using LimitRange

Scenario

A namespace project-x already exists in the cluster. The platform team wants to enforce resource policies for all containers running in this namespace.


Task

  1. Create a LimitRange named projectx-limits in the project-x namespace that applies to containers only with the following rules:
    • Minimum CPU request: 100m, Minimum Memory request: 128Mi
    • Maximum CPU limit: 800m, Maximum Memory limit: 1Gi
    • If developers do not specify resources, the following defaults will be applied automatically:
      ResourceDefault RequestDefault Limit
      CPU200m500m
      Memory256Mi512Mi
  2. Ensure the LimitRange applies to containers only.
  3. Create a Pod named ml-worker using the image nginx in the same namespace.
  4. Ensure the Pod's resource configuration does not exceed the default request and default limit values defined in the LimitRange.
  5. Verify that the Pod is successfully created and complies with the LimitRange policies.

Hint 1

A LimitRange uses min, max, default, and defaultRequest fields under spec.limits. Set type: Container to apply rules to containers only. See the official docs: LimitRange


Test Cases