Skip to content
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

Dynamically change the API version of the PDB in Helm Chart #1502

Merged
merged 6 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/build/helmify/kustomize-for-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ webhooks:
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
failurePolicy: HELMSUBST_VALIDATING_WEBHOOK_CHECK_IGNORE_FAILURE_POLICY
---
HELMSUBSET_PDB_POLICY_GROUP_VERSION: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: HELMSUBST

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxsmythe thanks!

apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
Expand Down
6 changes: 6 additions & 0 deletions cmd/build/helmify/replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ var replacements = map[string]string{
{{- range .Values.controllerManager.exemptNamespaces}}
- --exempt-namespace={{ . }}
{{- end }}`,
`HELMSUBSET_PDB_POLICY_GROUP_VERSION: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could break if the ordering of fields in the Kustomize output is not maintained.

It might be better to modify https://github.com/open-policy-agent/gatekeeper/blob/master/cmd/build/helmify/main.go to directly detect these and make the replacement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxsmythe I followed the documentation below and made some changes outside of main.go, but there is certainly a danger that this implementation will not work.

please edit kustomization.yaml, kustomize-for-helm.yaml and replacements.go under that directory and then run make manifests.

https://github.com/open-policy-agent/gatekeeper/blob/e00262b76acc82f5dc2a7e3a371d57894e7776b3/charts/gatekeeper/README.md#contributing-changes

I will modify main.go to directly detect these. Thanks.

apiVersion: policy/v1beta1`: `{{- if .Capabilities.APIVersions.Has "policy/v1" }}
apiVersion: policy/v1
{{ else }}
apiVersion: policy/v1beta1
{{ end -}}`,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
apiVersion: policy/v1
{{ else }}
apiVersion: policy/v1beta1
{{ end -}}
kind: PodDisruptionBudget
metadata:
labels:
Expand Down