diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index a71a020d..ad84f01f 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -48,17 +48,6 @@ rules: - get - list - watch -- apiGroups: - - "" - resources: - - serviceaccounts - verbs: - - create - - get - - list - - patch - - update - - watch - apiGroups: - batch resources: @@ -79,28 +68,6 @@ rules: - get - list - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - - rolebindings - verbs: - - create - - get - - list - - patch - - update - - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - - roles - verbs: - - create - - get - - list - - patch - - update - - watch - apiGroups: - security.openshift.io resourceNames: diff --git a/controllers/ansibletest_controller.go b/controllers/ansibletest_controller.go index c31ccc5a..302d30f0 100644 --- a/controllers/ansibletest_controller.go +++ b/controllers/ansibletest_controller.go @@ -31,7 +31,6 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/env" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" "github.com/openstack-k8s-operators/lib-common/modules/common/job" - common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" "github.com/openstack-k8s-operators/test-operator/api/v1beta1" testv1beta1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1" "github.com/openstack-k8s-operators/test-operator/pkg/ansibletest" @@ -56,14 +55,11 @@ func (r *AnsibleTestReconciler) GetLogger(ctx context.Context) logr.Logger { // +kubebuilder:rbac:groups=test.openstack.org,resources=ansibletests/finalizers,verbs=update;patch // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;patch;update;delete; // +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update;patch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch // +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid;privileged;nonroot;nonroot-v2,resources=securitycontextconstraints,verbs=use // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete; // +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch // +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;create;update;watch;patch;delete -// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch // Reconcile - AnsibleTest func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { @@ -236,16 +232,6 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request) } } - // Service account, role, binding - rbacRules := GetCommonRbacRules(privileged) - rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules) - if err != nil { - return rbacResult, err - } else if (rbacResult != ctrl.Result{}) { - return rbacResult, nil - } - // Service account, role, binding - end - jobDef := ansibletest.Job( instance, serviceLabels, diff --git a/controllers/horizontest_controller.go b/controllers/horizontest_controller.go index 62b8e021..681ed429 100644 --- a/controllers/horizontest_controller.go +++ b/controllers/horizontest_controller.go @@ -28,7 +28,6 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/env" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" "github.com/openstack-k8s-operators/lib-common/modules/common/job" - common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" testv1beta1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1" "github.com/openstack-k8s-operators/test-operator/pkg/horizontest" batchv1 "k8s.io/api/batch/v1" @@ -53,14 +52,11 @@ func (r *HorizonTestReconciler) GetLogger(ctx context.Context) logr.Logger { // +kubebuilder:rbac:groups=test.openstack.org,resources=horizontests/finalizers,verbs=update;patch // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;patch;update;delete; // +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update;patch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch // +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid;privileged;nonroot;nonroot-v2,resources=securitycontextconstraints,verbs=use // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete; // +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch // +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;create;update;watch;patch;delete -// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch // Reconcile - HorizonTest func (r *HorizonTestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { @@ -231,16 +227,6 @@ func (r *HorizonTestReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, err } - // Service account, role, binding - rbacRules := GetCommonRbacRules(instance.Spec.Privileged) - rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules) - if err != nil { - return rbacResult, err - } else if (rbacResult != ctrl.Result{}) { - return rbacResult, nil - } - // Service account, role, binding - end - jobDef := horizontest.Job( instance, serviceLabels, diff --git a/controllers/tempest_controller.go b/controllers/tempest_controller.go index d82ff242..7bd045b5 100644 --- a/controllers/tempest_controller.go +++ b/controllers/tempest_controller.go @@ -58,14 +58,11 @@ func (r *TempestReconciler) GetLogger(ctx context.Context) logr.Logger { // +kubebuilder:rbac:groups=test.openstack.org,resources=tempests/finalizers,verbs=update;patch // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;patch;update;delete; // +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update;patch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch // +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid;privileged;nonroot;nonroot-v2,resources=securitycontextconstraints,verbs=use // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete; // +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch // +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;create;update;watch;patch;delete -// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch // Reconcile - Tempest func (r *TempestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { @@ -330,16 +327,6 @@ func (r *TempestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re return ctrl.Result{}, err } - // Service account, role, binding - rbacRules := GetCommonRbacRules(instance.Spec.Privileged) - rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules) - if err != nil { - return rbacResult, err - } else if (rbacResult != ctrl.Result{}) { - return rbacResult, nil - } - // Service account, role, binding - end - // Note(lpiwowar): Remove all the workflow merge code to webhook once it is done. // It will simplify the logic and duplicite code (Tempest vs Tobiko) if nextWorkflowStep < len(instance.Spec.Workflow) { diff --git a/controllers/tobiko_controller.go b/controllers/tobiko_controller.go index ee602985..05c47484 100644 --- a/controllers/tobiko_controller.go +++ b/controllers/tobiko_controller.go @@ -32,7 +32,6 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/helper" "github.com/openstack-k8s-operators/lib-common/modules/common/job" nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" - common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" "github.com/openstack-k8s-operators/lib-common/modules/common/util" testv1beta1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1" "github.com/openstack-k8s-operators/test-operator/pkg/tobiko" @@ -58,14 +57,11 @@ func (r *TobikoReconciler) GetLogger(ctx context.Context) logr.Logger { // +kubebuilder:rbac:groups=test.openstack.org,resources=tobikoes/finalizers,verbs=update;patch // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;patch;update;delete; // +kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update;patch -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch // +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid;privileged;nonroot;nonroot-v2,resources=securitycontextconstraints,verbs=use // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete; // +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch // +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;create;update;watch;patch;delete -// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch // Reconcile - Tobiko func (r *TobikoReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { @@ -318,16 +314,6 @@ func (r *TobikoReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res return ctrl.Result{}, err } - // Service account, role, binding - rbacRules := GetCommonRbacRules(privileged) - rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules) - if err != nil { - return rbacResult, err - } else if (rbacResult != ctrl.Result{}) { - return rbacResult, nil - } - // Service account, role, binding - end - jobDef := tobiko.Job( instance, serviceLabels,