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

Prometheus server should use SA token when talking to apiserver #3138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Jan 22, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

Prometheus server should use service account token when talking to kube-apiserver. We should not rely on anonymous auth.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

We currently create ClusterRole and ClusterRoleBinding for anonymous auth.

createClusterRole := func() error {
_, err := clientSet.GetClient().RbacV1().ClusterRoles().Create(context.TODO(), &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: "apiserver-metrics-viewer"},
Rules: []rbacv1.PolicyRule{
{Verbs: []string{"get"}, NonResourceURLs: []string{"/metrics"}},
},
}, metav1.CreateOptions{})
return err
}
createClusterRoleBinding := func() error {
_, err := clientSet.GetClient().RbacV1().ClusterRoleBindings().Create(context.TODO(), &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{Name: "system:anonymous"},
RoleRef: rbacv1.RoleRef{Kind: "ClusterRole", Name: "apiserver-metrics-viewer"},
Subjects: []rbacv1.Subject{
{Kind: "User", Name: "system:anonymous"},
},
}, metav1.CreateOptions{})
return err
}

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 22, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mengqiy
Once this PR has been reviewed and has the lgtm label, please assign wojtek-t for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 22, 2025
@mengqiy
Copy link
Member Author

mengqiy commented Jan 23, 2025

/retest

@k8s-ci-robot
Copy link
Contributor

@mengqiy: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-perf-tests-clusterloader2-kubemark 598e901 link true /test pull-perf-tests-clusterloader2-kubemark

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants