Skip to content

Commit ae2a489

Browse files
committed
chore(charts): controller-gen output file into charts.
Updates the controller-gen command used to generated the RBAC manifests into the charts/kubewarden-controller directory. This commit also adds the kubebuilder markers to add the missing permissions in the controller roles that was added using manully created roles definitions. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com>
1 parent 6322955 commit ae2a489

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ generate-controller: manifests ## Generate code containing DeepCopy, DeepCopyIn
146146

147147
.PHONY: manifests
148148
manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. We use yq to modify the generated files to match our naming and labels conventions.
149-
$(GO_BUILD_ENV) $(CONTROLLER_GEN) rbac:roleName=controller-role crd webhook paths="./api/policies/v1" paths="./internal/controller" output:crd:artifacts:config=config/crd/bases output:rbac:artifacts:config=config/rbac
149+
$(GO_BUILD_ENV) $(CONTROLLER_GEN) rbac:roleName=controller-role,fileName=controller-rbac-roles.yaml,roleName=kubewarden-controller-manager crd webhook \
150+
paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \
151+
output:crd:artifacts:config=config/crd/bases \
152+
output:rbac:artifacts:config=charts/kubewarden-controller/templates \
150153

151154
.PHONY: generate-chart
152155
generate-chart: ## Generate Helm chart values schema.

charts/kubewarden-controller/templates/controller-rbac-roles.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
55
name: kubewarden-controller-manager
6-
labels:
7-
{{- include "kubewarden-controller.labels" . | nindent 4 }}
8-
annotations:
9-
{{- include "kubewarden-controller.annotations" . | nindent 4 }}
106
rules:
117
- apiGroups:
128
- admissionregistration.k8s.io
@@ -74,11 +70,7 @@ apiVersion: rbac.authorization.k8s.io/v1
7470
kind: Role
7571
metadata:
7672
name: kubewarden-controller-manager
77-
namespace: {{ .Release.Namespace }}
78-
labels:
79-
{{- include "kubewarden-controller.labels" . | nindent 4 }}
80-
annotations:
81-
{{- include "kubewarden-controller.annotations" . | nindent 4 }}
73+
namespace: kubewarden
8274
rules:
8375
- apiGroups:
8476
- ""

cmd/controller/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ import (
5353
//+kubebuilder:scaffold:imports
5454
)
5555

56+
// Kubewarden controller required permissiions
57+
//
58+
//+kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;watch;create;update;patch;delete,namespace="kubewarden"
59+
//+kubebuilder:rbac:groups="",resources=configmap,verbs=get;list;watch;create;update;patch;delete,namespace="kubewarden"
60+
//+kubebuilder:rbac:groups="",resources=event,verbs=create;patch,namespace="kubewarden"
61+
//+kubebuilder:rbac:groups="",resources=event,verbs=create;patch,namespace="kubewarden"
62+
//+kubebuilder:rbac:groups=authentication.k8s.io,resources=tokenreviews,verbs=create
63+
//+kubebuilder:rbac:groups=authorization.k8s.io,resources=subjectaccessreviews,verbs=create
64+
5665
//nolint:gochecknoglobals // Following the kubebuilder pattern
5766
var (
5867
scheme = runtime.NewScheme()

0 commit comments

Comments
 (0)