Skip to content

Commit

Permalink
Remove boilerplate RBAC, fix config structure for kustomize 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djwhatle committed May 8, 2019
1 parent 9d4554b commit 4cb837b
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 129 deletions.
18 changes: 3 additions & 15 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,9 @@ namePrefix: mig-controller-
#commonLabels:
# someName: someValue

# Each entry in this list must resolve to an existing
# resource definition in YAML. These are the resource
# files that kustomize reads, modifies and emits as a
# YAML string, with resources separated by document
# markers ("---").
resources:
- ../rbac/rbac_role.yaml
- ../rbac/rbac_role_binding.yaml
- ../manager/manager.yaml
# Comment the following 3 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- ../rbac/auth_proxy_service.yaml
- ../rbac/auth_proxy_role.yaml
- ../rbac/auth_proxy_role_binding.yaml
bases:
- ../rbac
- ../manager

patches:
- manager_image_patch.yaml
Expand Down
2 changes: 2 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- manager.yaml
9 changes: 9 additions & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- rbac_role.yaml
- rbac_role_binding.yaml
# Comment the following 3 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
100 changes: 0 additions & 100 deletions config/rbac/manager_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,6 @@ rules:
- get
- update
- patch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- update
- patch
- apiGroups:
- migration.openshift.io
resources:
Expand All @@ -84,26 +64,6 @@ rules:
- get
- update
- patch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- update
- patch
- apiGroups:
- migration.openshift.io
resources:
Expand All @@ -124,26 +84,6 @@ rules:
- get
- update
- patch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- update
- patch
- apiGroups:
- migration.openshift.io
resources:
Expand All @@ -164,26 +104,6 @@ rules:
- get
- update
- patch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- update
- patch
- apiGroups:
- migration.openshift.io
resources:
Expand All @@ -204,26 +124,6 @@ rules:
- get
- update
- patch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- update
- patch
- apiGroups:
- migration.openshift.io
resources:
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/migcluster/migcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ type ReconcileMigCluster struct {

// Reconcile reads that state of the cluster for a MigCluster object and makes changes based on the state read
// and what is in the MigCluster.Spec
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migclusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migclusters/status,verbs=get;update;patch
func (r *ReconcileMigCluster) Reconcile(request reconcile.Request) (reconcile.Result, error) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/migmigration/migmigration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ type ReconcileMigMigration struct {
}

// Reconcile performs Migrations based on the data in MigMigration
// Automatically generate RBAC rules to allow the Controller to read and write Deployments
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migmigrations,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migmigrations/status,verbs=get;update;patch
func (r *ReconcileMigMigration) Reconcile(request reconcile.Request) (reconcile.Result, error) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/migplan/migplan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ type ReconcileMigPlan struct {
}

// Automatically generate RBAC rules to allow the Controller to read and write Deployments
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migplans,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migplans/status,verbs=get;update;patch
func (r *ReconcileMigPlan) Reconcile(request reconcile.Request) (reconcile.Result, error) {
Expand Down
5 changes: 0 additions & 5 deletions pkg/controller/migstage/migstage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ type ReconcileMigStage struct {

// Reconcile reads that state of the cluster for a MigStage object and makes changes based on the state read
// and what is in the MigStage.Spec
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
// a Deployment as an example
// Automatically generate RBAC rules to allow the Controller to read and write Deployments
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migstages,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migstages/status,verbs=get;update;patch
func (r *ReconcileMigStage) Reconcile(request reconcile.Request) (reconcile.Result, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/migstorage/migstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package migstorage

import (
"context"

migapi "github.com/fusor/mig-controller/pkg/apis/migration/v1alpha1"
migref "github.com/fusor/mig-controller/pkg/reference"
kapi "k8s.io/api/core/v1"
Expand Down Expand Up @@ -92,8 +93,6 @@ type ReconcileMigStorage struct {
}

// Automatically generate RBAC rules to allow the Controller to read and write Deployments
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migstorages,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=migration.openshift.io,resources=migstorages/status,verbs=get;update;patch
func (r *ReconcileMigStorage) Reconcile(request reconcile.Request) (reconcile.Result, error) {
Expand Down

0 comments on commit 4cb837b

Please sign in to comment.