Hi all,
I am trying to implement HPA in K8s.
I have set hpa with
kubectl autoscale deployment lms --cpu-percent=80 --min=1 --max=10
But it doesn’t work:
% kubectl describe hpa -n capnet-prod
Name: lms
Namespace: <my namespace>
Labels: <none>
Annotations: <none>
CreationTimestamp: Fri, 08 Jul 2022 05:44:12 -0300
Reference: Deployment/lms
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): <unknown> / 80%
Min replicas: 1
Max replicas: 10
Deployment pods: 1 current / 0 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: failed to get cpu utilization: missing request for cpu
The reason seems to be that the pod specification does not include a request for cpu.
My questions are:
- Is it possible to add a cpu request using a plugin? I don’t see a patch there to modify the deployment.
- Which would be a good request for CPU? 500m sounds good?
If the answer to the first one is no, I would raise a PR with the following change to the lms deployment to something like:
apiVersion: apps/v1
kind: Deployment
metadata:
name: lms
labels:
app.kubernetes.io/name: lms
spec:
template:
spec:
containers:
- name: lms
...
resources:
requests:
memory: 2Gi
{% if LMS_CPU_REQUEST is defined %}
cpu: {{ LMS_CPU_REQUEST }}
{% endif %}
Similarly it can be repeated for cms and the workers.
What do you think?