Question
You are responsible for configuring Resource Requests and Limits for a stateful database application running on Kubernetes. The database application requires the following:
- Minimum CPU request of 500m.
- Minimum memory request of 1Gi.
- CPU limit of 1 core.
- Memory limit of 2Gi.
You must ensure that the application can scale properly without risking overconsumption of cluster resources.
Which of the following YAML manifests correctly configures a StatefulSet to meet these resource requirements?
Correct Answer: A
Explanation:
Option A is the correct answer because it uses proper resource requests and limits:
- Requests are defined as:
cpu: 500m
(500 millicores, ensuring the application gets at least 500m CPU)memory: 1Gi
(1Gi as the minimum guaranteed memory)
- Limits are defined as:
cpu: 1
(capping CPU usage at a maximum of 1 core)memory: 2Gi
(setting the maximum memory usage for the pod at 2Gi)
These settings ensure the StatefulSet meets the database’s scaling requirements while respecting cluster resource constraints.
The resources.requests
ensure Kubernetes schedules the pods only on nodes with sufficient resources, while the resources.limits
prevent overconsumption of cluster capacity.
Why Other Options Are Incorrect
Option B:
This manifest is valid syntactically, but it uses limits and requests in a different order of prioritization. The cluster will not scale optimally unless requests and limits are properly balanced as shown in Option A.
Option C:
This manifest has mismatched values for requests and limits. Specifically, the CPU limit (1m
) is too low, and it doesn’t adhere to the actual scaling constraints necessary to maintain application stability.
Option D:
Although 500m
CPU is requested, limits are incorrectly limited to 500m
CPU, which means that the pod would scale inconsistently. Additionally, memory settings don’t align with the provided database specifications.
Correct Answer: A
Explanation:
Option A is the correct answer because it uses proper resource requests and limits:
- Requests are defined as:
cpu: 500m
(500 millicores, ensuring the application gets at least 500m CPU)memory: 1Gi
(1Gi as the minimum guaranteed memory)
- Limits are defined as:
cpu: 1
(capping CPU usage at a maximum of 1 core)memory: 2Gi
(setting the maximum memory usage for the pod at 2Gi)
These settings ensure the StatefulSet meets the database’s scaling requirements while respecting cluster resource constraints.
The resources.requests
ensure Kubernetes schedules the pods only on nodes with sufficient resources, while the resources.limits
prevent overconsumption of cluster capacity.
Why Other Options Are Incorrect
Option B:
This manifest is valid syntactically, but it uses limits and requests in a different order of prioritization. The cluster will not scale optimally unless requests and limits are properly balanced as shown in Option A.
Option C:
This manifest has mismatched values for requests and limits. Specifically, the CPU limit (1m
) is too low, and it doesn’t adhere to the actual scaling constraints necessary to maintain application stability.
Option D:
Although 500m
CPU is requested, limits are incorrectly limited to 500m
CPU, which means that the pod would scale inconsistently. Additionally, memory settings don’t align with the provided database specifications.