-
Notifications
You must be signed in to change notification settings - Fork 46
refactor(charts): Change generation of RBAC templates #1520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3a037f9
f83eeaf
7e07524
af43702
9ea96f8
4c0a2bf
de6d5f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,7 @@ test-rust: | |||||||||||||
| .PHONY: helm-unittest | ||||||||||||||
| helm-unittest: | ||||||||||||||
| helm unittest charts/kubewarden-controller --file "tests/**/*_test.yaml" | ||||||||||||||
| helm unittest charts/kubewarden-crds --file "tests/**/*_test.yaml" | ||||||||||||||
|
|
||||||||||||||
| .PHONY: test-e2e | ||||||||||||||
| test-e2e: controller-image audit-scanner-image policy-server-image | ||||||||||||||
|
|
@@ -146,8 +147,13 @@ generate-controller: manifests ## Generate code containing DeepCopy, DeepCopyIn | |||||||||||||
| $(GO_BUILD_ENV) $(CONTROLLER_GEN) object paths="./api/policies/v1" | ||||||||||||||
|
|
||||||||||||||
| .PHONY: manifests | ||||||||||||||
| manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. We use yq to modify the generated files to match our naming and labels conventions. | ||||||||||||||
| $(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 | ||||||||||||||
| manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||||||||||||||
| $(GO_BUILD_ENV) $(CONTROLLER_GEN) rbac:roleName=kubewarden-controller-manager,fileName=controller-rbac-roles.yaml crd webhook \ | ||||||||||||||
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | ||||||||||||||
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ | ||||||||||||||
|
Comment on lines
+152
to
+153
|
||||||||||||||
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | |
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ | |
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | |
| output:crd:artifacts:config=config/crd/bases \ | |
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ | |
| output:rbac:artifacts:config=config/rbac \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We plan to remove the config directory in the future. So, we can ignore this comment for now.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| {{- if eq .Values.auditScanner.serviceAccountName "audit-scanner" }} | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: audit-scanner-cluster-role | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| rules: | ||
| - apiGroups: | ||
| - policies.kubewarden.io | ||
| resources: | ||
| - clusteradmissionpolicies | ||
| - clusteradmissionpolicygroups | ||
| - admissionpolicies | ||
| - admissionpolicygroups | ||
| - clusteradmissionpolicies/status | ||
| - clusteradmissionpolicygroups/status | ||
| - admissionpolicies/status | ||
| - admissionpolicygroups/status | ||
| - policyservers | ||
| - policyservers/status | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - apiGroups: | ||
| - wgpolicyk8s.io | ||
| resources: | ||
| - policyreports | ||
| - clusterpolicyreports | ||
| verbs: | ||
| - create | ||
| - deletecollection | ||
| - get | ||
| - list | ||
| - patch | ||
| - update | ||
| - watch | ||
| - apiGroups: | ||
| - openreports.io | ||
| resources: | ||
| - reports | ||
| - clusterreports | ||
| verbs: | ||
| - create | ||
| - deletecollection | ||
| - get | ||
| - list | ||
| - patch | ||
| - update | ||
| - watch | ||
| {{ end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {{- if eq .Values.auditScanner.serviceAccountName "audit-scanner" }} | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: audit-scanner-cluster-role-viewer | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: view | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ .Values.auditScanner.serviceAccountName }} | ||
| namespace: {{ .Release.Namespace }} | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: audit-scanner-cluster-role | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: audit-scanner-cluster-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ .Values.auditScanner.serviceAccountName }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{ end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # This ClusterRole grants read access to the /metrics endpoint. | ||
| # It is not generated by controller-gen because nonResourceURLs cannot be | ||
| # expressed via kubebuilder RBAC markers in a way that keeps it in a separate | ||
| # ClusterRole. It is maintained manually to preserve a dedicated role for | ||
| # metrics scraping (e.g., by Prometheus). | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: kubewarden-controller-metrics-reader | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| rules: | ||
| - nonResourceURLs: | ||
| - /metrics | ||
| verbs: | ||
| - get |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: kubewarden-controller-manager | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: Role | ||
| name: kubewarden-controller-manager | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "kubewarden-controller.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: kubewarden-controller-manager | ||
| labels: | ||
| {{- include "kubewarden-controller.labels" . | nindent 4 }} | ||
| annotations: | ||
| {{- include "kubewarden-controller.annotations" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: kubewarden-controller-manager | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "kubewarden-controller.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} |
Uh oh!
There was an error while loading. Please reload this page.