Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Only apply PSP is object is registered in the k8s API (#35)
Browse files Browse the repository at this point in the history
* Only apply PSP is object is registered in the k8s API

* Don't apply RBAC for PSPs if PSPs are not deployed
  • Loading branch information
fiunchinho authored Oct 4, 2022
1 parent 80a8985 commit ead67d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- `PodSecurityPolicy` are removed on newer k8s versions, so only apply it if object is registered in the k8s API.

## [0.5.1] - 2022-09-02

### Added
Expand Down
2 changes: 2 additions & 0 deletions helm/capg-firewall-rule-operator/templates/psp.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy" }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
Expand Down Expand Up @@ -26,3 +27,4 @@ spec:
hostNetwork: false
hostIPC: false
hostPID: false
{{- end }}
4 changes: 3 additions & 1 deletion helm/capg-firewall-rule-operator/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ roleRef:
name: {{ include "resource.default.name" . }}
apiGroup: rbac.authorization.k8s.io
---
{{- if .Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy" }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -49,7 +50,7 @@ metadata:
{{- include "labels.common" . | nindent 4 }}
rules:
- apiGroups:
- extensions
- policy
resources:
- podsecuritypolicies
verbs:
Expand All @@ -71,3 +72,4 @@ roleRef:
kind: ClusterRole
name: {{ include "resource.psp.name" . }}
apiGroup: rbac.authorization.k8s.io
{{- end }}

0 comments on commit ead67d4

Please sign in to comment.