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

add useExistingRole option - to support running in specific namespace… #1325

Merged
merged 1 commit into from
Jan 26, 2021
Merged

Conversation

KlavsKlavsen
Copy link
Contributor

…s without needing clusteradmin privs

This is a repost of helm/charts#23953

This adds support for running on kubernetes setups (such as is typical in openshift) where you only have access to your own namespaces.

I've gotten this support merged in both Prometheus and Grafana charts and
I'd really like to get it in this last chart I use for our Prometheus setup ;)

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Dec 16, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @KlavsKlavsen!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 16, 2020
@k8s-ci-robot k8s-ci-robot requested review from brancz and mrueg December 16, 2020 06:53
@KlavsKlavsen
Copy link
Contributor Author

CLA signed

@lilic
Copy link
Member

lilic commented Dec 16, 2020

/assign @mrueg

@KlavsKlavsen you need to push an empty commit to validate the CLA again, I believe the command is gone now to revalidate. Thanks for the PR!

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 16, 2020
Copy link
Member

@mrueg mrueg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and apologies it takes so long to get this change in.

charts/kube-state-metrics/Chart.yaml Outdated Show resolved Hide resolved
charts/kube-state-metrics/templates/role.yaml Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 18, 2020
@KlavsKlavsen
Copy link
Contributor Author

Rebased - ready for merge.. ?

@mrueg
Copy link
Member

mrueg commented Dec 21, 2020

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 21, 2020
@KlavsKlavsen
Copy link
Contributor Author

@mrueg only missing an /lgtm label CI says ?

@scottrigby
Copy link
Contributor

scottrigby commented Dec 22, 2020

/hold

Lets please wait for CI to be fully resolved before merging this.

  1. Current PR we hope will fix it: Remove kube-state-metrics gh-pages branch status checks test-infra#20322
  2. We will then be testing required checks on a low stakes PR (Add gh-pages Readme #1335, which just adds a README to the gh-pages branch)
  3. Once that succeeds, we will want to release the version of the chart that's now in master (before this PR, otherwise end users won't have access to it)
  4. From that point on we can merge PRs like this which make changes to the initial chart and create new releases

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 22, 2020
@KlavsKlavsen
Copy link
Contributor Author

The fix has been merged 6 days ago.. Hows the "simple PR" going? it seems to be stalled.

@mrueg
Copy link
Member

mrueg commented Dec 30, 2020

@KlavsKlavsen during this time of the year, please be aware that responses might take longer.
I'm waiting for @scottrigby to remove the hold.

@scottrigby
Copy link
Contributor

@KlavsKlavsen the PR isn't the problem, it's test infra that needs to remove required checks from the gh-pages branch. I'm not a repo admin so the feedback loop is slower - and much slower right now because repo maintainers are away over the holidays (as they should be!) 😃

If this PR were merged before that is resolved, it would not create a chart release. Backfilling that release would then have to be a manual process - more annoying and confusing to end users than just waiting to merge the PR.

Hope that helps explain it. Happy new year! Looking forward to resolving this soon.

@mrueg mrueg mentioned this pull request Jan 6, 2021
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 6, 2021
@KlavsKlavsen
Copy link
Contributor Author

@scottrigby Hi Scott and a good new year to you :) - I see version of chart has been updated.. Is everything in place for merging this, or ?

@scottrigby
Copy link
Contributor

@KlavsKlavsen Not yet. @tariq1890 and I are trying to schedule a collab session. I would think we will find a time for this very soon. Feel free to also follow along or join in Slack chat: https://kubernetes.slack.com/archives/CJJ529RUY/p1609938365003800

scottrigby added a commit to scottrigby/kube-state-metrics that referenced this pull request Jan 10, 2021
The chart github release was already created, but due to a k8s infra ci issue
the index could not be pushed to gh-pages branch.

See:
- kubernetes/test-infra#20426
- kubernetes#1345
- kubernetes#1342
- kubernetes#1325 (comment)

Signed-off-by: Scott Rigby <scott@r6by.com>
scottrigby added a commit to scottrigby/kube-state-metrics that referenced this pull request Jan 10, 2021
Unblocked by kubernetes/test-infra#20426

Fixes: kubernetes#1342

Reverts kubernetes#1345

Unblocks kubernetes#1325

See kubernetes#1325 (comment)

Signed-off-by: Scott Rigby <scott@r6by.com>
@@ -0,0 +1,27 @@
{{- if and (eq .Values.rbac.create true) (eq .Values.rbac.useClusterRole false) -}}
{{- range (split "," $.Values.namespace) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the range makes sense over here. I see that the {{- end -}} is placed correctly. I am just confused by the range block used in role.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The range block in role - is because a Clusterrole must be ONLY once.. But when operating on only a few namespaces - each must have the relevant role.. so there must be a role per namespace we operate on (as it's NOT a ClusterRole - it only affects the individual namespace and lives within it).
I hope that makes it clearer :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there USED to be a clusterrole.yaml and a role.yaml- but I was asked to merge the two - as they were 99% identical.

@tariq1890
Copy link
Contributor

@KlavsKlavsen You have my sincere apologies for making you wait for this PR for so long. But I am afraid that we can only merge this PR once we go live with kube-state-metrics v2.0 (correct me if I am mistaken @mrueg ).

The reason is that .Values.namespace is intended to be a single value field. We need to use the --namespaces field and that change has been made only in v2.0.

As a frequent user of helm charts myself, I feel it's in the best interest of open source users and maintainers to make the helm charts have the same cadence as that of the binary. In light of this, I think we should merge and publish this change only when kube-state-metrics v2 is released.

{{- if .Values.rbac.create -}}
{{- if and (eq $.Values.rbac.create true) (not .Values.rbac.useExistingRole) -}}
{{- if eq .Values.rbac.useClusterRole false }}
{{- range (split "," $.Values.namespace) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- range (split "," $.Values.namespace) }}
{{- range (split "," $.Values.namespaces) }}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @tariq1890 @KlavsKlavsen , i think this suggested change may have been accidentally missed.

may i know if the chart is going to use namespaces moving forward? a little confusing as the values.yaml specified use of namespaces (field used in rolebinding.yaml) but this role.yaml template is expecting namespace instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely correct Jianhao. (namespace was before 2.0 - its called namespaces in 2.0+). This chart has since been moved to https://github.com/prometheus-community/helm-charts/blob/d6ae19c6bb7089bd0080952ca6f98b68177e3dcb/charts/kube-state-metrics/templates/role.yaml#L3 - where it still lists namespace instead of namespaces - even though it has moved to 2.0.

@@ -0,0 +1,27 @@
{{- if and (eq .Values.rbac.create true) (eq .Values.rbac.useClusterRole false) -}}
{{- range (split "," $.Values.namespace) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- range (split "," $.Values.namespace) }}
{{- range (split "," $.Values.namespaces) }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlavsKlavsen You have my sincere apologies for making you wait for this PR for so long. But I am afraid that we can only merge this PR once we go live with kube-state-metrics v2.0 (correct me if I am mistaken @mrueg ).

The reason is that .Values.namespace is intended to be a single value field. We need to use the --namespaces field and that change has been made only in v2.0.

As a frequent user of helm charts myself, I feel it's in the best interest of open source users and maintainers to make the helm charts have the same cadence as that of the binary. In light of this, I think we should merge and publish this change only when kube-state-metrics v2 is released.

Let's keep this change on ksm-v1.9.x to be able to move forward and integrate it. I'm tracking v2 changes in
#1358

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In upstream 1.9 branch - the docs says: --namespace string Comma-separated list of namespaces to be enabled. Defaults to ""

So it has the exact same use for kube-state-metrics in 1.9.x as it has in 2.x - its just gotten an extra s for clarification.

So I'm not quite sure what you're referring to here, namespace also in 1.9.x supported multiple namespaces. ?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 25, 2021
@KlavsKlavsen
Copy link
Contributor Author

The reason is that .Values.namespace is intended to be a single value field. We need to use the --namespaces field and that change has been made only in v2.0.

In upstream 1.9 branch - the docs says: --namespace string Comma-separated list of namespaces to be enabled. Defaults to ""

So it has the exact same use for kube-state-metrics in 1.9.x as it has in 2.x - its just gotten an extra s for clarification.

So I'm not quite sure what you're referring to here ?

@mrueg
Copy link
Member

mrueg commented Jan 25, 2021

@KlavsKlavsen Thanks for the quick turnaround, can you remove 22057b4 (we release this for ksm-v1.x) and I'll make sure to get it merged immediately.

@KlavsKlavsen
Copy link
Contributor Author

reverted the change to support 2.x. I'll gladly submit a PR for 2.x with that small commit if you like.. I don't know where you keep the 2.x kube-state-metrics version of the chart though and how you want it.. :)

@mrueg
Copy link
Member

mrueg commented Jan 25, 2021

@KlavsKlavsen I meant removing the commit, not reverting. While at it, can you stash the commits into a single one? Thanks!

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 25, 2021
@KlavsKlavsen
Copy link
Contributor Author

@KlavsKlavsen I meant removing the commit, not reverting. While at it, can you stash the commits into a single one? Thanks!

Squashed all commits into one :)

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 25, 2021
go.mod Outdated Show resolved Hide resolved
in specific namespaces only when user has no access to entire cluster
(like in typical OpenShift environments).

Signed-off-by: Klavs Klavsen <klavs@enableit.dk>
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 26, 2021
@mrueg
Copy link
Member

mrueg commented Jan 26, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 26, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KlavsKlavsen, mrueg

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

The pull request process is described 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 merged commit e974d90 into kubernetes:master Jan 26, 2021
mrueg pushed a commit to mrueg/prometheus-community-helm-charts that referenced this pull request Apr 15, 2021
mrueg pushed a commit to mrueg/prometheus-community-helm-charts that referenced this pull request Apr 25, 2021
langecode pushed a commit to neticdk/helm-charts that referenced this pull request Aug 12, 2021
Unblocked by kubernetes/test-infra#20426

Fixes: kubernetes/kube-state-metrics#1342

Reverts kubernetes/kube-state-metrics#1345

Unblocks kubernetes/kube-state-metrics#1325

See kubernetes/kube-state-metrics#1325 (comment)

Signed-off-by: Scott Rigby <scott@r6by.com>
Signed-off-by: Thor Anker Kvisgård Lange <tal@netic.dk>
QuentinBisson pushed a commit to giantswarm/prometheus-community-helm-charts-upstream that referenced this pull request Oct 5, 2021
Unblocked by kubernetes/test-infra#20426

Fixes: kubernetes/kube-state-metrics#1342

Reverts kubernetes/kube-state-metrics#1345

Unblocks kubernetes/kube-state-metrics#1325

See kubernetes/kube-state-metrics#1325 (comment)

Signed-off-by: Scott Rigby <scott@r6by.com>
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
galina-tochilkin pushed a commit to mtp-devops/3d-party-helm that referenced this pull request Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. helm lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants