Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

HPA not working since osiris-proxy sidecar has no option to set resource request or limit #46

Open
TheEvilCoder42 opened this issue Oct 18, 2019 · 4 comments

Comments

@TheEvilCoder42
Copy link

Environment:

  • Kubernetes distribution (e.g. AKS, ACS Engine, GKE, EKS, etc.): AWS EKS
  • Kubernetes version (use kubectl version): 1.14
  • Osiris version (specify by SHA or semver): 113a458
  • Install method (specify exact helm install command used): helm install osiris/osiris-edge --name osiris --namespace osiris-system --devel

What happened?
Tried to configure Horizontal Pod Autoscaler on Pod where Osiris is enabled.
HPA complains about a missing resource request, it works without the osiris-proxy sidecar.

Name:                                                  example-app-hpa
Namespace:                                             tenant-1
Labels:                                                <none>
Annotations:                                           kubectl.kubernetes.io/last-applied-configuration:
                                                         {"apiVersion":"autoscaling/v1","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"example-app-hpa","namespace":"tenant-...
CreationTimestamp:                                     Fri, 18 Oct 2019 14:41:41 +0200
Reference:                                             Deployment/example-app-deployment
Metrics:                                               ( current / target )
  resource cpu on pods  (as a percentage of request):  <unknown> / 85%
Min replicas:                                          1
Max replicas:                                          5
Deployment pods:                                       0 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   ScalingDisabled    scaling is disabled since the replica count of the target is zero
Events:
  Type     Reason                        Age                From                       Message
  ----     ------                        ----               ----                       -------
  Warning  FailedGetResourceMetric       14m (x5 over 15m)  horizontal-pod-autoscaler  unable to get metrics for resource cpu: no metrics returned from resource metrics API
  Warning  FailedComputeMetricsReplicas  14m (x5 over 15m)  horizontal-pod-autoscaler  failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
  Warning  FailedComputeMetricsReplicas  12m (x7 over 14m)  horizontal-pod-autoscaler  failed to get cpu utilization: missing request for cpu
  Warning  FailedGetResourceMetric       12m (x8 over 14m)  horizontal-pod-autoscaler  missing request for cpu

What you expected to happen?
HPA should work on Pod where Osiris is enabled.
There should be a possibility to configure the osiris-proxy sidecar container.

How to reproduce it (as minimally and precisely as possible):
Enable Osiris on a deployment, configure HPA for this deployment too.
Osiris will work, HPA will report a missing resource request.

Anything else that we need to know?
Didn't found any possibility to set the resources on the osiris-proxy sidecar container.
I tried setting the resources on all containers by passing it in a yaml file when installing with helm but this didn't affected the osiris-proxy sidecar.

@krancour
Copy link
Contributor

The proxy's resource requirements should be very small-- thought I'll admit to not knowing exactly how small. A good first pass at this would involve hard-coding the resource requests and limits in the proxy injector. PRs welcome.

@TheEvilCoder42
Copy link
Author

TheEvilCoder42 commented Oct 25, 2019

I tried to hard-code the resource requests and limits in the pod_patch.go file, at least I got it past building..

+ "k8s.io/apimachinery/pkg/api/resource"

+ Resources: corev1.ResourceRequirements{
+   Limits: corev1.ResourceList{
+     "cpu":    resource.MustParse("250m"),
+     "memory": resource.MustParse("256Mi"),
+   },
+   Requests: corev1.ResourceList{
+     "cpu":    resource.MustParse("100m"),
+     "memory": resource.MustParse("128Mi"),
+   },
+ },

I built the image with make build, pushed it to a ecr repo and deployed it on Kubernetes.
When deploying the deployment of an example app I get the following error; Internal error occurred: admission webhook "proxy-injector.osiris.deislabs.io" denied the request: Invalid kind for review: AdmissionReview

This also happens when I build it directly from master, without my patch..

@krancour
Copy link
Contributor

@TheEvilCoder42 you encountered a bug that was accidentally introduced by #47 and fixed this morning in #53.

@fonsecas72
Copy link

fonsecas72 commented Oct 31, 2020

I have a kind of related issue. I have a quota rule that forces to set resources

Error creating: pods "pod" is forbidden: failed quota: generic-namespace-quota: must specify limits.cpu,limits.memory,requests.cpu,requests.memory

I'm willing to add this feature (It'll take time) but before I start coding, can you please explain to me how do you imagine this being solved? For example, would using pod annotations be a good option ?

(edit)
Sorry, only now I saw the PR and your comment. So can I assume I can move this forward via pod annotations ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants