Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non cluster-admin cannot request metrics #90

Closed
benjaminapetersen opened this issue Jul 24, 2018 · 12 comments
Closed

Non cluster-admin cannot request metrics #90

benjaminapetersen opened this issue Jul 24, 2018 · 12 comments

Comments

@benjaminapetersen
Copy link

I have the Deploy 1.8 YAML files deployed on an OpenShift cluster @ v3.11.0-alpha.0+3af079d-343.

If I run the following:
oc get --raw /apis/metrics.k8s.io/v1beta1/namespaces/<my-namespace>/pods/<my-happy-pod>

I will receive the response:

Error from server (Forbidden): pods.metrics.k8s.io "<my-happy-pod>" is forbidden: 
User "<me>" cannot get pods.metrics.k8s.io in the namespace "<my-namespace>": 
User "<me>" cannot get pods.metrics.k8s.io in project "<my-namespace>"

I believe a non-cluster-admin user must be able to get metrics for the metrics service to be most useful.

@DirectXMan12

fyi @spadgett

@DirectXMan12
Copy link
Contributor

We might need to move this to the Kubernetes repo, since it's a question of default policy, but we might also just be able to aggregate up to one of the default cluster roles. I'll need to take a look.

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Jul 24, 2018

I think we can add an rbac.authorization.k8s.io/aggregate-to-view: true label on a role here and fix this, but it's probably better to just fix the default cluster policy in Kubernetes.

@DirectXMan12
Copy link
Contributor

Talked to the sig-auth folks -- we probably just want to have aggregate-to-view here.

@seh
Copy link

seh commented Aug 8, 2018

Which roles should be labeled as such, @DirectXMan12? We define the "metrics-server-auth-reader" Role and the "system:metrics-server" ClusterRole per the 1.8+ deployment advice.

@seh
Copy link

seh commented Aug 9, 2018

Reading kubernetes/kubernetes#66579 again this morning, I now assume that you meant that we'll define the new "system:namespaced-metrics-reader" ClusterRole in this project, and aggregate it via label.

@DirectXMan12
Copy link
Contributor

yes, correct.

@seh
Copy link

seh commented Aug 13, 2018

How does one make use of all the permissions granted in the "custom.metrics.k8s.io" group, such as "jobs.batch?"

@DirectXMan12
Copy link
Contributor

what do you mean? Are you asking what URLs those translate to? the resource "jobs.batch" in the API group "custom.metrics.k8s.io" corresponds to the URL /apis/custom.metrics.k8s.io/v1beta1/namespaces/<ns>/jobs.batch/<name-or-star>/<metric>, and grants permission to fetch any metric (subresource) on jobs.batch (although there's a typo and they should have subresources of * attached).

@seh
Copy link

seh commented Aug 13, 2018

Are you asking what URLs those translate to?

Yes, that's what I'm asking. I tried several of my guesses, and couldn't find any to which the API server responded positively.

there's a typo and they should have subresources of * attached

I'll add that subresource tomorrow morning and try a few URLs again.

More broadly, though, does this imply that the metrics server is collecting metrics on all of these resources today, or is it that if there were such metrics in the future, this is how we'd read them?

Does the "<metric>" placeholder in your URL template have any valid values today?

@DirectXMan12
Copy link
Contributor

Those ones aren't actually related to metrics-server -- they're related to custom metrics adapters. They can be removed from the metrics-server version of the PR -- they were in the original PR since I figured I'd handle both "safe" metrics APIs in one go.

@seh
Copy link

seh commented Aug 14, 2018

Given that, I can whittle my ClusterRole down to granting "get" and "list" against the "pods" resource within the "metrics.k8s.io" group.

What's a good source for learning about these custom metrics adapters?

@DirectXMan12
Copy link
Contributor

@seh take a look at the documentation in kubernetes-sigs/custom-metrics-apiserver#24

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

No branches or pull requests

3 participants