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

fix(kiali-server): don't create unused ClusterRole #261

Conversation

capuche2412
Copy link
Contributor

PR to solve kiali/kiali#7357

@@ -1,3 +1,4 @@
{{- if or (.Values.deployment.view_only_mode) (ne .Values.auth.strategy "anonymous") -}}
Copy link
Contributor

@jmazzitelli jmazzitelli May 15, 2024

Choose a reason for hiding this comment

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

anonymous mode can still be used with view_only_mode=true or false (in fact, I think many people use it with true, but there is no restriction).

I don't think auth.strategy setting should affect which role is created.

Can you explain the thinking behind checking for anonymous mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get your point.
The goal is to have the same behavior with the roleBinding.
So if the roleBinding is set to viewer role, the viewer role is created (same for full rights role)

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -1,3 +1,4 @@
{{- if not (or (.Values.deployment.view_only_mode) (ne .Values.auth.strategy "anonymous")) -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

see my previous comment about auth.strategy.

@jmazzitelli jmazzitelli dismissed their stale review May 16, 2024 08:30

dismissing change-request - if not anonymous, the Kiali SA will always be view-only. Only when using anonymous would the SA ever possibly be read-write

@jmazzitelli jmazzitelli self-requested a review May 16, 2024 08:30
@jmazzitelli
Copy link
Contributor

jmazzitelli commented May 16, 2024

Here's a quick test to see things working. Run "helm template" with these combinations of settings - the first three should result in the kiali-viewer Role being created and used in the RoleBinding whose name is also kiali-viewer. The last should not have any kiali-viewer resource generated or used.

  1. deployment.view_only_mode=false , auth.strategy=token
  2. deployment.view_only_mode=true , auth.strategy=token
  3. deployment.view_only_mode=true , auth.strategy=anonymous
  4. deployment.view_only_mode=false , auth.strategy=anonymous
$ helm template --set deployment.view_only_mode=false --set auth.strategy=token _output/charts/kiali-server-*.tgz | grep "kiali-viewer"
  name: kiali-viewer
  name: kiali-viewer
  name: kiali-viewer
$ helm template --set deployment.view_only_mode=true --set auth.strategy=token _output/charts/kiali-server-*.tgz | grep "kiali-viewer"
  name: kiali-viewer
  name: kiali-viewer
  name: kiali-viewer
$ helm template --set deployment.view_only_mode=true --set auth.strategy=anonymous _output/charts/kiali-server-*.tgz | grep "kiali-viewer"
  name: kiali-viewer
  name: kiali-viewer
  name: kiali-viewer
$ helm template --set deployment.view_only_mode=false --set auth.strategy=anonymous _output/charts/kiali-server-*.tgz | grep "kiali-viewer"
<empty output>

That last one will show a different behavior from the current helm chart. Because both roles are created today, that last one will result in a single "name: kiali-vewer" line (that's the Role that is created but not used).

You can also examine the output of one of the first three commands to see that no Role is created with the name "kiali" that has the write permissions. A quick way to see this is to grep for "ClusterRole" and see that only one is created now with this PR, but today's helm charts create two roles:

This PR results in:

$ helm template --set deployment.view_only_mode=true --set auth.strategy=token _output/charts/kiali-server-*.tgz | yq | grep '^kind: ClusterRole'
kind: ClusterRole
kind: ClusterRoleBinding

but master build (today's helm chart) results in:

$ helm template --set deployment.view_only_mode=true --set auth.strategy=token _output/charts/kiali-server-*.tgz | yq | grep '^kind: ClusterRole'
kind: ClusterRole
kind: ClusterRole
kind: ClusterRoleBinding

Copy link
Contributor

@jmazzitelli jmazzitelli left a comment

Choose a reason for hiding this comment

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

lgtm. reviewed code and tested (see test procedure I used in earlier comment).

@jmazzitelli
Copy link
Contributor

I did a quick check of the hack/istio/multicluster/kiali-prepare-remote-cluster.sh script which uses the server helm chart to prepare remote cluster secrets in a multi-cluster environment, and it should still work. The relevant code is here, and this does not look like it requires the old behavior of getting both roles created - it only looks for role or role-viewer depending on the view_only_mode setting passed in by the user.

@jmazzitelli jmazzitelli merged commit ff22e32 into kiali:master May 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants