Hi Team,
Question 1 in the mock exam doesn’t specify the name of the HPA to be created. I am not sure why this question is marked as False in the exam. Kindly assist. Thanks!
Create an HPA for a deployment named frontend-deployment in the default namespace. The HPA should scale the deployment based on CPU utilization, maintaining an average CPU usage of 70% across all pods. Set the minimum number of replicas to 2 and the maximum to 10.
My answer:
cluster1-controlplane ~ ➜ k describe hpa
Name: frontend-hpa
Namespace: default
Labels: <none>
Annotations: <none>
CreationTimestamp: Fri, 25 Apr 2025 01:23:10 +0000
Reference: Deployment/frontend-deployment
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): 0% (0) / 70%
Min replicas: 2
Max replicas: 10
Deployment pods: 2 current / 2 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True ReadyForNewScale recommended size matches current size
ScalingActive True ValidMetricFound the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)
ScalingLimited True TooFewReplicas the desired replica count is less than the minimum replica count
Events: <none>
YAML file:
cluster1-controlplane ~ ➜ k get hpa -o yaml
apiVersion: v1
items:
- apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"autoscaling/v2","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"frontend-hpa","namespace":"default"},"spec":{"maxReplicas":10,"metrics":[{"resource":{"name":"cpu","target":{"averageUtilization":70,"type":"Utilization"}},"type":"Resource"}],"minReplicas":2,"scaleTargetRef":{"apiVersion":"apps/v1","kind":"Deployment","name":"frontend-deployment"}}}
creationTimestamp: "2025-04-25T01:23:10Z"
name: frontend-hpa
namespace: default
resourceVersion: "3632"
uid: 7401d979-c6cb-42e0-897e-9a4348b572f1
spec:
maxReplicas: 10
metrics:
- resource:
name: cpu
target:
averageUtilization: 70
type: Utilization
type: Resource
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: frontend-deployment
status:
conditions:
- lastTransitionTime: "2025-04-25T01:23:25Z"
message: recommended size matches current size
reason: ReadyForNewScale
status: "True"
type: AbleToScale
- lastTransitionTime: "2025-04-25T01:23:25Z"
message: the HPA was able to successfully calculate a replica count from cpu
resource utilization (percentage of request)
reason: ValidMetricFound
status: "True"
type: ScalingActive
- lastTransitionTime: "2025-04-25T01:28:25Z"
message: the desired replica count is less than the minimum replica count
reason: TooFewReplicas
status: "True"
type: ScalingLimited
currentMetrics:
- resource:
current:
averageUtilization: 0
averageValue: "0"
name: cpu
type: Resource
currentReplicas: 2
desiredReplicas: 2
lastScaleTime: "2025-04-25T01:28:25Z"
kind: List
metadata:
resourceVersion: ""
Regards,
Sakshi