operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

Two identical Kubebuilders in different CRs with *

Open OdedViner opened this issue 1 year ago • 1 comments

Bug Report

When there are two identical Kubebuilders [same groups ] in different CRs and the verb in one of them is * then we need to add a condition that verbs=* and not verbs=*+[list, update...]

In this example:

controllers/storagecluster/reconcile.go
// +kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=*
func (r *StorageClusterReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {

controllers/storagerequest/storagerequest_controller.go
// +kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=get;list;watch;create;update;patch;delete
func (r *StorageRequestReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {


config/rbac/role.yaml
- apiGroups:
  - storage.k8s.io
  resources:
  - storageclasses
  verbs:
  - '*'
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
https://github.com/red-hat-storage/ocs-operator/blob/main/config/rbac/role.yaml#L409-L421

What did you do?

What did you expect to see?

astricks+[get,list,create]=astricks

What did you see instead? Under which circumstances?

Environment

Operator type: Golang

Kubernetes cluster type: Openshift

$ operator-sdk version

$ go version (if language is Go) $ go version go version go1.22.3 linux/amd64

$ kubectl version

Possible Solution

Additional context

OdedViner avatar Aug 26 '24 17:08 OdedViner

Hi @OdedViner since this is about kubebuilder, this issue is probably best opened in that project.

acornett21 avatar Oct 15 '24 22:10 acornett21

@acornett21 done https://github.com/kubernetes-sigs/kubebuilder/issues/4222

OdedViner avatar Oct 19 '24 12:10 OdedViner