I am trying to configure HPA for GKE workload in one of our projects (lets say ProjectA) using the pubsub metrics from another project of ours (lets say ProjectB). I receive the following permission denied error:
Warning FailedGetExternalMetric 9s (x12 over 2m56s) horizontal-pod-autoscaler unable to get external metric default/pubsub.googleapis.com|subscription|num_undelivered_messages/&LabelSelector{MatchLabels:map[string]string{resource.labels.project_id: ProjectB,resource.labels.subscription_id: ProjectB.Subscription,},MatchExpressions:LabelSelectorRequirement{},}: unable to fetch metrics from external metrics API: the server could not find the descriptor for metric pubsub.googleapis.com/subscription/num_undelivered_messages: googleapi: Error 403: Permission monitoring.metricDescriptors.get denied (or the resource may not exist)., forbidden
I have Mpnitoring.admin role assigned on both the projects and have pub/sub APIs enabled on both the projects.
Also, I am able to configure HPA for GKE workload in ProjectA using the pubsub metrics from with the ProjectA. I want to not extend the same configuration using metrics from ProjectB.
You need to configure the cluster service account or the service account for the custom metrics adapter to have the monitoring metrics viewer role/permissions, monitoring.metricDescriptors.get specifically in your case (the service account will need a few other metrics reading permissions) for the the project that the metrics are in.