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

Disable psp by default #2944

Closed
cdenneen opened this issue Aug 10, 2023 · 14 comments · Fixed by #3179
Closed

Disable psp by default #2944

cdenneen opened this issue Aug 10, 2023 · 14 comments · Fixed by #3179
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@cdenneen
Copy link

PSP's are no longer supported in Kubernetes so recommend making default value of chart false:

https://github.com/open-policy-agent/gatekeeper/blob/master/charts/gatekeeper/values.yaml#L264C16-L264C16

@cdenneen cdenneen added the enhancement New feature or request label Aug 10, 2023
@ritazh
Copy link
Member

ritazh commented Aug 11, 2023

👍

@cdenneen would you like to open a PR for this?

@sozercan
Copy link
Member

@cdenneen this is only there for backwards compat. if your cluster doesn't have the necessary APIs for PSP, it will not be enabled. https://github.com/open-policy-agent/gatekeeper/blob/master/charts/gatekeeper/templates/gatekeeper-admin-podsecuritypolicy.yaml#L1C40-L1C40

@cdenneen
Copy link
Author

@sozercan while this might be how it should work I can confirm the Helm Release fails due to this.

@sozercan
Copy link
Member

@cdenneen I am not familiar with Helm releases (assuming this the Terraform provider?). Can you paste your error?
Could this be an issue on the Terraform side?

@fopni01
Copy link

fopni01 commented Sep 5, 2023

@sozercan Here is the error I have when trying to put pspenabled: false
`

│ Error: resource mapping not found for name: "gatekeeper-admin" namespace: "" from "": no matches for kind "PodSecurityPolicy" in version "policy/v1beta1"

573 | │ ensure CRDs are installed first

`

@mazay
Copy link

mazay commented Oct 11, 2023

@sozercan HelmRelease is fluxcd custom resource. For whatever reason the PSP switch doesn't work there as well as the API capabilities check.

@cdenneen
Copy link
Author

@sozercan Here is the error I have when trying to put pspenabled: false `

│ Error: resource mapping not found for name: "gatekeeper-admin" namespace: "" from "": no matches for kind "PodSecurityPolicy" in version "policy/v1beta1"

573 | │ ensure CRDs are installed first

`

The issue is actually the PSP wasn’t removed before Kubernetes was updated to 1.25. Sadly after the upgrade the resource is there but can’t be removed or seen since the CRD is no longer there. I had this problem after upgrading EKS and not disabling the PSP for gatekeeper before I did the upgrade.

@mazay
Copy link

mazay commented Oct 11, 2023

@cdenneen thanks for sharing this! Do you happen to have any hints on a fix?

@cdenneen
Copy link
Author

I do not. Believe I uninstalled gatekeeper (delete helmrelease) and reconciled again. I’ve since replaced the cluster with new so no issues on a new 1.26+ cluster.

@nreisch
Copy link
Contributor

nreisch commented Nov 16, 2023

The issue appears to be due to Helm's diff-patch behavior. If a <1.25 cluster has a Helm release that contains the deprecated PSP resource, when the cluster is in-place upgraded to 1.25+ where the PSP is now removed, Helm tries to get the PSP resource from the existing release which is now removed and fails, and thus the state of the release is now failed.

The mitigation is to remove the deprecated resource from the release if your cluster gets into this state so that the Helm get/reconciliation succeeds. You can use this Helm plugin to remove deprecated resources from the existing helm release: https://github.com/helm/helm-mapkubeapis

@ritazh ritazh added this to the v3.15.0 milestone Nov 17, 2023
@ritazh
Copy link
Member

ritazh commented Nov 17, 2023

Let's make a decision when to remove PSP. @sozercan @maxsmythe

@maxsmythe
Copy link
Contributor

Do we want to just flip enabled to false, so users on older versions can manually re-enable it if they desire?

@JBOClara
Copy link

JBOClara commented Nov 18, 2023 via email

@ritazh
Copy link
Member

ritazh commented Nov 20, 2023

Do we want to just flip enabled to false, so users on older versions can manually re-enable it if they desire?

sgtm. I will open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants