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

controller-manager can't access RemoteCluster due to namespaced role #4417

Open
miedzinski opened this issue May 14, 2024 · 2 comments · May be fixed by #4419
Open

controller-manager can't access RemoteCluster due to namespaced role #4417

miedzinski opened this issue May 14, 2024 · 2 comments · May be fixed by #4419

Comments

@miedzinski
Copy link
Contributor

Bug Report

What version of Kubernetes are you using?
v1.25.16

What version of Chaos Mesh are you using?
2.6.3

What did you do? / Minimal Reproducible Example
Updated from Helm chart with clusterScoped: false.

What did you expect to see?
Chaos Mesh should apply chaos.

What did you see instead?

E0514 11:32:40.444526       1 reflector.go:140] pkg/mod/k8s.io/client-go@v0.26.1/tools/cache/reflector.go:169: Failed to watch *v1alpha1.RemoteCluster: failed to list *v1alpha1.RemoteCluster: remoteclusters.chaos-mesh.org is forbidden: User "system:serviceaccount:chaos-mesh:chaos-controller-manager" cannot list resource "remoteclusters" in API group "chaos-mesh.org" at the cluster scope: RBAC: clusterrole.rbac.authorization.k8s.io "default-read" not found

Output of chaosctl


The cause is that Helm creates role binding chaos-controller-manager-target-namespace as namespaced RoleBinding, but RemoteCluster isn't namespaced (has scope: Cluster). As a fix we should always create ClusterRoleBinding here:

{{- if .Values.clusterScoped }}
kind: ClusterRoleBinding
{{- else }}
kind: RoleBinding
{{- end }}

@STRRL
Copy link
Member

STRRL commented May 14, 2024

Hi @miedzinski , It's better to create another role and cluster role biding for the CRD RemoteCluster.

Could you help us to improve it?

miedzinski added a commit to miedzinski/chaos-mesh that referenced this issue May 14, 2024
…s-mesh#4417)

Signed-off-by: Dominik Miedziński <dominik.miedzinski@allegro.com>
@miedzinski
Copy link
Contributor Author

You're right. There is a ClusterRole for that

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Release.Name }}-chaos-controller-manager-cluster-level
labels:
{{- include "chaos-mesh.labels" . | nindent 4 }}
app.kubernetes.io/component: controller-manager
rules:
- apiGroups: [ "" ]
resources:
- nodes
- persistentvolumes
- persistentvolumeclaims
{{- if .Values.clusterScoped }}
- namespaces
- services
{{- end }}
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "authorization.k8s.io" ]
resources:
- subjectaccessreviews
verbs: [ "create" ]

so it could be added there. Submitted #4419.

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

Successfully merging a pull request may close this issue.

2 participants