Skip to content

Commit

Permalink
feat(kong): fail to render templates when PodSecurityPolicy is reques…
Browse files Browse the repository at this point in the history
…ted but cluster doesn't serve it
  • Loading branch information
pmalek committed Jun 20, 2023
1 parent 4eb477b commit 0a34350
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions charts/kong/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
## Unreleased

### Improvements

* Running `tpl` against user-supplied labels and annotations used in Deployment
#### example:
```yaml
podLabels:
version: "{{ .Values.image.tag }}" # Will render dynamically when overridden downstream
```
[#814](https://github.com/Kong/charts/pull/814)
* Fail to render templates when PodSecurityPolicy was requested but cluster doesn't
serve its API.
[#823](https://github.com/Kong/charts/pull/823)
## 2.23.0
Expand Down
8 changes: 8 additions & 0 deletions charts/kong/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,14 @@ autoscaling/v1
{{- end -}}
{{- end -}}
{{- define "kong.policyVersion" -}}
{{- if (.Capabilities.APIVersions.Has "policy/v1beta1" ) -}}
policy/v1beta1
{{- else -}}
{{- fail (printf "Cluster doesn't have policy/v1beta1 API." ) }}
{{- end -}}
{{- end -}}
{{- define "kong.renderTpl" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
Expand Down
4 changes: 2 additions & 2 deletions charts/kong/templates/psp.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if and (.Values.podSecurityPolicy.enabled) (.Capabilities.APIVersions.Has "policy/v1beta1") }}
apiVersion: policy/v1beta1
{{- if and (.Values.podSecurityPolicy.enabled) }}
apiVersion: {{ include "kong.policyVersion" . }}
kind: PodSecurityPolicy
metadata:
name: {{ template "kong.serviceAccountName" . }}-psp
Expand Down

0 comments on commit 0a34350

Please sign in to comment.