kedacore / charts

Helm charts for KEDA
Apache License 2.0
152 stars 216 forks source link

Missing "subjectaccessreviews" resource permissions on keda-operator Clusterrole #646

Open JMSPL opened 4 months ago

JMSPL commented 4 months ago

Hi! Recently I've upgraded Keda to the 2.14.0 version using the latest Helm charts available. Everything deployed just fine but while looking at the logs of the metrics API server the following message kept appearing:

Failed to make webhook authorizer request: subjectaccessreviews.authorization.k8s.io is forbidden: User "system:serviceaccount:keda-operator:keda-operator" cannot create resource "subjectaccessreviews" in API group "authorization.k8s.io" at the cluster scope

While having a look at the keda operator clusterrole template in the main branch I've realized the resource is indeed missing from it. Not sure if related but after the upgrade all our ScaledObjects and Jobs can no longer scale properly which I assume (might be a wrong assumption) is because of this. By running kubectl describe on any of the HPAs associated with Keda resources we can see the following:

 unable to get external metric ... unable to fetch metrics from external metrics API: an error on the server ("Internal Server Error: \"/apis/external.metrics.k8s.io/v1beta1/namespaces/...: subjectaccessreviews.authorization.k8s.io is forbidden: User \"system:serviceaccount:keda-operator:keda-operator\" cannot create resource \"subjectaccessreviews\" in API group \"authorization.k8s.io\" at the cluster scope") has prevented the request from succeeding (...) 

Expected Behavior

The resource and necessary actions should be present in the clusterrole Helm template and message above shouldn't be present allowing for a normal scaling behavior using the latest version of the Helm chart.

Actual Behavior

Message keeps being printed by the metrics API server not allowing for the proper scaling of affected resources (ScaledObjects and ScaledJobs)

Steps to Reproduce the Problem

  1. Deploy the latest version of the Helm chart
  2. Check logs of API server
  3. Describe HPAs associated with Keda scaling objects/jobs
  4. Profit(?)

Specifications

PS: This seems to be very easy to fix and I have a PR ready, if bug is confirmed/reproducible by others I can take care of firing it.