-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Describe the bug
When using the get-kubeconfig.sh script, the created cnsmanager-sa lacks of some permissions:
2023-03-28T11:17:56.643Z ERROR VolumeMigrationJobController.controller.volumemigrationjob-controller volumemigrationjob/volumemigrationjob_controller.go:216 failed to get volume migration tasks for the job {"name": "volumemigrationjob-2b352bca-cd5a-11ed-8421-1e896c6caec5", "namespace": "cns-manager", "TraceId": "ac7f0efe-bea9-48c0-9630-77b7bfcfa475", "error": "volumemigrationtasks.cnsmanager.cns.vmware.com is forbidden: User "system:serviceaccount:default:cnsmanager-sa" cannot list resource "volumemigrationtasks" in API group "cnsmanager.cns.vmware.com" in the namespace "cns-manager""}
E0328 11:18:19.819033 1 event.go:264] Server rejected event '&v1.Event{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"volumemigrationjob-3d5c91be-cd5a-11ed-8421-1e896c6caec5.17509130cb8b2e2a", GenerateName:"", Namespace:"cns-manager", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, InvolvedObject:v1.ObjectReference{Kind:"VolumeMigrationJob", Namespace:"cns-manager", Name:"volumemigrationjob-3d5c91be-cd5a-11ed-8421-1e896c6caec5", UID:"b3f4cf99-fdde-4bec-b2e6-9383e35f9240", APIVersion:"cnsmanager.cns.vmware.com/v1alpha1", ResourceVersion:"243516", FieldPath:""}, Reason:"VolumeMigrationJobCompleted", Message:"All tasks finished. Volume migration job is complete", Source:v1.EventSource{Component:"cnsmanager.cns.vmware.com", Host:""}, FirstTimestamp:v1.Time{Time:time.Time{wall:0xc100d11eedcf202a, ext:6201947942605, loc:(*time.Location)(0x36647a0)}}, LastTimestamp:v1.Time{Time:time.Time{wall:0xc100d11eedcf202a, ext:6201947942605, loc:(*time.Location)(0x36647a0)}}, Count:1, Type:"Normal", EventTime:v1.MicroTime{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, Series:(*v1.EventSeries)(nil), Action:"", Related:(*v1.ObjectReference)(nil), ReportingController:"", ReportingInstance:""}': 'events is forbidden: User "system:serviceaccount:default:cnsmanager-sa" cannot create resource "events" in API group "" in the namespace "cns-manager"' (will not retry!)
Adding this to the ClusterRole makes the error messages disappear:
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "get", "list", "watch", "update", "patch", "delete"]
- apiGroups: ["cnsmanager.cns.vmware.com"]
resources: ["volumemigrationtasks"]
verbs: ["get", "list"]Reproduction steps
- Deploy cns-manager according to documentation
- Run a migration
- Get pod logs and see the ERROR messages
Expected behavior
All needed RBAC permissions should be included and it shouldn't be necessary to add some in addition to the scripts that create them.
Additional context
No response