Skip to content

Commit e10beb8

Browse files
authored
Merge pull request #499 from droot/bugfix/rbac-rule-status-subresource
add RBAC annotation for status subresource
2 parents 422c6ad + 2d6bc05 commit e10beb8

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed

pkg/scaffold/controller/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,10 @@ type Reconcile{{ .Resource.Kind }} struct {
198198
{{ if .Resource.CreateExampleReconcileBody -}}
199199
// Automatically generate RBAC rules to allow the Controller to read and write Deployments
200200
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
201+
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
201202
{{ end -}}
202203
// +kubebuilder:rbac:groups={{.GroupDomain}},resources={{ .Plural }},verbs=get;list;watch;create;update;patch;delete
204+
// +kubebuilder:rbac:groups={{.GroupDomain}},resources={{ .Plural }}/status,verbs=get;update;patch
203205
func (r *Reconcile{{ .Resource.Kind }}) Reconcile(request reconcile.Request) (reconcile.Result, error) {
204206
// Fetch the {{ .Resource.Kind }} instance
205207
instance := &{{ .Resource.Group}}{{ .Resource.Version }}.{{ .Resource.Kind }}{}

test/project/config/rbac/rbac_role.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ rules:
1616
- update
1717
- patch
1818
- delete
19+
- apiGroups:
20+
- apps
21+
resources:
22+
- deployments/status
23+
verbs:
24+
- get
25+
- update
26+
- patch
1927
- apiGroups:
2028
- crew.testproject.org
2129
resources:
@@ -28,6 +36,14 @@ rules:
2836
- update
2937
- patch
3038
- delete
39+
- apiGroups:
40+
- crew.testproject.org
41+
resources:
42+
- firstmates/status
43+
verbs:
44+
- get
45+
- update
46+
- patch
3147
- apiGroups:
3248
- ship.testproject.org
3349
resources:
@@ -40,6 +56,14 @@ rules:
4056
- update
4157
- patch
4258
- delete
59+
- apiGroups:
60+
- ship.testproject.org
61+
resources:
62+
- frigates/status
63+
verbs:
64+
- get
65+
- update
66+
- patch
4367
- apiGroups:
4468
- policy.testproject.org
4569
resources:
@@ -52,6 +76,14 @@ rules:
5276
- update
5377
- patch
5478
- delete
79+
- apiGroups:
80+
- policy.testproject.org
81+
resources:
82+
- healthcheckpolicies/status
83+
verbs:
84+
- get
85+
- update
86+
- patch
5587
- apiGroups:
5688
- creatures.testproject.org
5789
resources:
@@ -64,6 +96,14 @@ rules:
6496
- update
6597
- patch
6698
- delete
99+
- apiGroups:
100+
- creatures.testproject.org
101+
resources:
102+
- krakens/status
103+
verbs:
104+
- get
105+
- update
106+
- patch
67107
- apiGroups:
68108
- ""
69109
resources:
@@ -76,6 +116,14 @@ rules:
76116
- update
77117
- patch
78118
- delete
119+
- apiGroups:
120+
- ""
121+
resources:
122+
- namespaces/status
123+
verbs:
124+
- get
125+
- update
126+
- patch
79127
- apiGroups:
80128
- admissionregistration.k8s.io
81129
resources:

test/project/pkg/controller/firstmate/firstmate_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ type ReconcileFirstMate struct {
9696
// a Deployment as an example
9797
// Automatically generate RBAC rules to allow the Controller to read and write Deployments
9898
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
99+
// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch
99100
// +kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates,verbs=get;list;watch;create;update;patch;delete
101+
// +kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/status,verbs=get;update;patch
100102
func (r *ReconcileFirstMate) Reconcile(request reconcile.Request) (reconcile.Result, error) {
101103
// Fetch the FirstMate instance
102104
instance := &crewv1.FirstMate{}

test/project/pkg/controller/frigate/frigate_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type ReconcileFrigate struct {
8787
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
8888
// a Deployment as an example
8989
// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates,verbs=get;list;watch;create;update;patch;delete
90+
// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates/status,verbs=get;update;patch
9091
func (r *ReconcileFrigate) Reconcile(request reconcile.Request) (reconcile.Result, error) {
9192
// Fetch the Frigate instance
9293
instance := &shipv1beta1.Frigate{}

test/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type ReconcileHealthCheckPolicy struct {
8787
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
8888
// a Deployment as an example
8989
// +kubebuilder:rbac:groups=policy.testproject.org,resources=healthcheckpolicies,verbs=get;list;watch;create;update;patch;delete
90+
// +kubebuilder:rbac:groups=policy.testproject.org,resources=healthcheckpolicies/status,verbs=get;update;patch
9091
func (r *ReconcileHealthCheckPolicy) Reconcile(request reconcile.Request) (reconcile.Result, error) {
9192
// Fetch the HealthCheckPolicy instance
9293
instance := &policyv1beta1.HealthCheckPolicy{}

test/project/pkg/controller/kraken/kraken_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type ReconcileKraken struct {
8787
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
8888
// a Deployment as an example
8989
// +kubebuilder:rbac:groups=creatures.testproject.org,resources=krakens,verbs=get;list;watch;create;update;patch;delete
90+
// +kubebuilder:rbac:groups=creatures.testproject.org,resources=krakens/status,verbs=get;update;patch
9091
func (r *ReconcileKraken) Reconcile(request reconcile.Request) (reconcile.Result, error) {
9192
// Fetch the Kraken instance
9293
instance := &creaturesv2alpha1.Kraken{}

test/project/pkg/controller/namespace/namespace_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type ReconcileNamespace struct {
8787
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
8888
// a Deployment as an example
8989
// +kubebuilder:rbac:groups=core,resources=namespaces,verbs=get;list;watch;create;update;patch;delete
90+
// +kubebuilder:rbac:groups=core,resources=namespaces/status,verbs=get;update;patch
9091
func (r *ReconcileNamespace) Reconcile(request reconcile.Request) (reconcile.Result, error) {
9192
// Fetch the Namespace instance
9293
instance := &corev1.Namespace{}

0 commit comments

Comments
 (0)