Skip to content

Commit 17451d1

Browse files
pl4ntyCopilot
andauthored
Fix operator RBAC for event recording (#5243)
* Fix operator RBAC for event recording Agent-Logs-Url: https://github.com/pl4nty/toolhive/sessions/91c560a3-ef9f-42db-82be-d6fceeadeff7 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pl4nty <21111317+pl4nty@users.noreply.github.com> * Regen helm docs and update clusterrole tests Signed-off-by: Tom Plant <tom@tplant.com.au> --------- Signed-off-by: Tom Plant <tom@tplant.com.au> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 24fe776 commit 17451d1

10 files changed

Lines changed: 30 additions & 30 deletions

File tree

cmd/thv-operator/controllers/embeddingserver_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const (
6565
//+kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
6666
//+kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
6767
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
68-
//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch
68+
//+kubebuilder:rbac:groups=events.k8s.io,resources=events,verbs=create;patch
6969

7070
// Reconcile is part of the main kubernetes reconciliation loop which aims to
7171
// move the current state of the cluster closer to the desired state.

cmd/thv-operator/controllers/mcpregistry_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewMCPRegistryReconciler(
7070
// +kubebuilder:rbac:groups=toolhive.stacklok.dev,resources=mcpregistries/finalizers,verbs=update
7171
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
7272
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete
73-
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
73+
// +kubebuilder:rbac:groups=events.k8s.io,resources=events,verbs=create;patch
7474
//
7575
// For creating registry-api deployment and service
7676
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete

cmd/thv-operator/controllers/mcpremoteproxy_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type MCPRemoteProxyReconciler struct {
5959
// +kubebuilder:rbac:groups="",resources=services,verbs=create;delete;get;list;patch;update;watch
6060
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=create;delete;get;list;patch;update;watch
6161
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=create;delete;get;list;patch;update;watch
62-
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
62+
// +kubebuilder:rbac:groups=events.k8s.io,resources=events,verbs=create;patch
6363
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
6464
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=create;delete;get;list;patch;update;watch
6565
// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=create;delete;get;list;patch;update;watch

cmd/thv-operator/controllers/mcpserver_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (r *MCPServerReconciler) detectPlatform(ctx context.Context) (kubernetes.Pl
157157
// +kubebuilder:rbac:groups="",resources=services,verbs=create;delete;get;list;patch;update;watch
158158
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=create;delete;get;list;patch;update;watch
159159
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=create;delete;get;list;patch;update;watch
160-
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
160+
// +kubebuilder:rbac:groups=events.k8s.io,resources=events,verbs=create;patch
161161
// +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch
162162
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
163163
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=create;delete;get;list;patch;update;watch

cmd/thv-operator/controllers/virtualmcpserver_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type VirtualMCPServerReconciler struct {
125125
// +kubebuilder:rbac:groups="",resources=services,verbs=create;delete;get;list;patch;update;watch
126126
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=create;delete;get;list;patch;update;watch
127127
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=create;delete;get;list;patch;update;watch
128-
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
128+
// +kubebuilder:rbac:groups=events.k8s.io,resources=events,verbs=create;patch
129129
// +kubebuilder:rbac:groups="",resources=secrets,verbs=create;get;list;watch
130130
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=create;delete;get;list;patch;update;watch
131131
// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=create;delete;get;list;patch;update;watch

deploy/charts/operator/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The command removes all the Kubernetes components associated with the chart and
4646
|-----|------|---------|-------------|
4747
| fullnameOverride | string | `"toolhive-operator"` | Provide a fully-qualified name override for resources |
4848
| nameOverride | string | `""` | Override the name of the chart |
49-
| operator | object | `{"affinity":{},"autoscaling":{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80},"containerSecurityContext":{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"defaultImagePullSecrets":[],"env":[],"features":{"experimental":false},"gc":{"gogc":75,"gomemlimit":"110MiB"},"image":"ghcr.io/stacklok/toolhive/operator:v0.27.2","imagePullPolicy":"IfNotPresent","imagePullSecrets":[],"leaderElectionRole":{"binding":{"name":"toolhive-operator-leader-election-rolebinding"},"name":"toolhive-operator-leader-election-role","rules":[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":[""],"resources":["events"],"verbs":["create","patch"]}]},"livenessProbe":{"httpGet":{"path":"/healthz","port":"health"},"initialDelaySeconds":15,"periodSeconds":20},"nodeSelector":{},"podAnnotations":{},"podLabels":{},"podSecurityContext":{"runAsNonRoot":true},"ports":[{"containerPort":8080,"name":"metrics","protocol":"TCP"},{"containerPort":8081,"name":"health","protocol":"TCP"}],"proxyHost":"0.0.0.0","rbac":{"allowedNamespaces":[],"scope":"cluster"},"readinessProbe":{"httpGet":{"path":"/readyz","port":"health"},"initialDelaySeconds":5,"periodSeconds":10},"replicaCount":1,"resources":{"limits":{"cpu":"500m","memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}},"serviceAccount":{"annotations":{},"automountServiceAccountToken":true,"create":true,"labels":{},"name":"toolhive-operator"},"tolerations":[],"toolhiveRunnerImage":"ghcr.io/stacklok/toolhive/proxyrunner:v0.27.2","vmcpImage":"ghcr.io/stacklok/toolhive/vmcp:v0.27.2","volumeMounts":[],"volumes":[]}` | All values for the operator deployment and associated resources |
49+
| operator | object | `{"affinity":{},"autoscaling":{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80},"containerSecurityContext":{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"defaultImagePullSecrets":[],"env":[],"features":{"experimental":false},"gc":{"gogc":75,"gomemlimit":"110MiB"},"image":"ghcr.io/stacklok/toolhive/operator:v0.27.2","imagePullPolicy":"IfNotPresent","imagePullSecrets":[],"leaderElectionRole":{"binding":{"name":"toolhive-operator-leader-election-rolebinding"},"name":"toolhive-operator-leader-election-role","rules":[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["events.k8s.io"],"resources":["events"],"verbs":["create","patch"]}]},"livenessProbe":{"httpGet":{"path":"/healthz","port":"health"},"initialDelaySeconds":15,"periodSeconds":20},"nodeSelector":{},"podAnnotations":{},"podLabels":{},"podSecurityContext":{"runAsNonRoot":true},"ports":[{"containerPort":8080,"name":"metrics","protocol":"TCP"},{"containerPort":8081,"name":"health","protocol":"TCP"}],"proxyHost":"0.0.0.0","rbac":{"allowedNamespaces":[],"scope":"cluster"},"readinessProbe":{"httpGet":{"path":"/readyz","port":"health"},"initialDelaySeconds":5,"periodSeconds":10},"replicaCount":1,"resources":{"limits":{"cpu":"500m","memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}},"serviceAccount":{"annotations":{},"automountServiceAccountToken":true,"create":true,"labels":{},"name":"toolhive-operator"},"tolerations":[],"toolhiveRunnerImage":"ghcr.io/stacklok/toolhive/proxyrunner:v0.27.2","vmcpImage":"ghcr.io/stacklok/toolhive/vmcp:v0.27.2","volumeMounts":[],"volumes":[]}` | All values for the operator deployment and associated resources |
5050
| operator.affinity | object | `{}` | Affinity settings for the operator pod |
5151
| operator.autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | Configuration for horizontal pod autoscaling |
5252
| operator.autoscaling.enabled | bool | `false` | Enable autoscaling for the operator |
@@ -63,10 +63,10 @@ The command removes all the Kubernetes components associated with the chart and
6363
| operator.image | string | `"ghcr.io/stacklok/toolhive/operator:v0.27.2"` | Container image for the operator |
6464
| operator.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy for the operator container |
6565
| operator.imagePullSecrets | list | `[]` | List of image pull secrets to use |
66-
| operator.leaderElectionRole | object | `{"binding":{"name":"toolhive-operator-leader-election-rolebinding"},"name":"toolhive-operator-leader-election-role","rules":[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":[""],"resources":["events"],"verbs":["create","patch"]}]}` | Leader election role configuration |
66+
| operator.leaderElectionRole | object | `{"binding":{"name":"toolhive-operator-leader-election-rolebinding"},"name":"toolhive-operator-leader-election-role","rules":[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["events.k8s.io"],"resources":["events"],"verbs":["create","patch"]}]}` | Leader election role configuration |
6767
| operator.leaderElectionRole.binding.name | string | `"toolhive-operator-leader-election-rolebinding"` | Name of the role binding for leader election |
6868
| operator.leaderElectionRole.name | string | `"toolhive-operator-leader-election-role"` | Name of the role for leader election |
69-
| operator.leaderElectionRole.rules | list | `[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":[""],"resources":["events"],"verbs":["create","patch"]}]` | Rules for the leader election role |
69+
| operator.leaderElectionRole.rules | list | `[{"apiGroups":[""],"resources":["configmaps"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["coordination.k8s.io"],"resources":["leases"],"verbs":["get","list","watch","create","update","patch","delete"]},{"apiGroups":["events.k8s.io"],"resources":["events"],"verbs":["create","patch"]}]` | Rules for the leader election role |
7070
| operator.livenessProbe | object | `{"httpGet":{"path":"/healthz","port":"health"},"initialDelaySeconds":15,"periodSeconds":20}` | Liveness probe configuration for the operator |
7171
| operator.nodeSelector | object | `{}` | Node selector for the operator pod |
7272
| operator.podAnnotations | object | `{}` | Annotations to add to the operator pod |

deploy/charts/operator/templates/clusterrole/role.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ rules:
2020
- patch
2121
- update
2222
- watch
23-
- apiGroups:
24-
- ""
25-
resources:
26-
- events
27-
verbs:
28-
- create
29-
- patch
3023
- apiGroups:
3124
- ""
3225
resources:
@@ -73,6 +66,13 @@ rules:
7366
- patch
7467
- update
7568
- watch
69+
- apiGroups:
70+
- events.k8s.io
71+
resources:
72+
- events
73+
verbs:
74+
- create
75+
- patch
7676
- apiGroups:
7777
- gateway.networking.k8s.io
7878
resources:

deploy/charts/operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ operator:
182182
- patch
183183
- delete
184184
- apiGroups:
185-
- ""
185+
- events.k8s.io
186186
resources:
187187
- events
188188
verbs:

test/e2e/chainsaw/operator/multi-tenancy/setup/assert-rbac-clusterrole.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ rules:
2020
- patch
2121
- update
2222
- watch
23-
- apiGroups:
24-
- ""
25-
resources:
26-
- events
27-
verbs:
28-
- create
29-
- patch
3023
- apiGroups:
3124
- ""
3225
resources:
@@ -73,6 +66,13 @@ rules:
7366
- patch
7467
- update
7568
- watch
69+
- apiGroups:
70+
- events.k8s.io
71+
resources:
72+
- events
73+
verbs:
74+
- create
75+
- patch
7676
- apiGroups:
7777
- gateway.networking.k8s.io
7878
resources:

test/e2e/chainsaw/operator/single-tenancy/setup/assert-rbac-clusterrole.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ rules:
2020
- patch
2121
- update
2222
- watch
23-
- apiGroups:
24-
- ""
25-
resources:
26-
- events
27-
verbs:
28-
- create
29-
- patch
3023
- apiGroups:
3124
- ""
3225
resources:
@@ -73,6 +66,13 @@ rules:
7366
- patch
7467
- update
7568
- watch
69+
- apiGroups:
70+
- events.k8s.io
71+
resources:
72+
- events
73+
verbs:
74+
- create
75+
- patch
7676
- apiGroups:
7777
- gateway.networking.k8s.io
7878
resources:

0 commit comments

Comments
 (0)