-
Notifications
You must be signed in to change notification settings - Fork 763
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
Unable to delete config
resource due to built-in Gatekeeper policy validator
#3058
Comments
thanks for filing this @skaven81 . IIUC, one should be able to replicate this locally with the Would you mind sharing your |
The specific use case was that I was developing a controller using the KOPF framework that would dynamically build a Gatekeeper Config resource in response to live changes in the cluster. While testing my code, I had created a dev namespace (other than I was able to |
thanks for the additional info!
there it is, which is why i had asked for the $ kubectl delete --raw "/apis/config.gatekeeper.sh/v1alpha1/namespaces/gatekeeper-system-dev/configs"
Error from server: admission webhook "validation.gatekeeper.sh" denied the request: config resource must have name 'config' I'll look into why this happens in this case and submit a patch |
I suspect that's because the |
What steps did you take and what happened:
I have the Gatekeeper webhook installed with validation of deletions enabled. This means that
validateConfigResource()
gets called from the Gatekeeper validating webhook, when the Gatekeeper Config resource is deleted. And this validation fails, resulting in:This only seems to happen when the
config
resource is deleted by the Kubernetes namespace controller, as part of its cascading deletions upon deleting a namespace.The API call that the namespace controller makes looks like this in the API logs:
Observe that the response was a 422, and that the deletion is not for the
config
resource specifically, but rather the group of resources,/apis/config.gatekeeper.sh/v1alpha1/namespaces/<ns>/configs
as opposed to the more typical direct resource deletion of/apis/config.gatekeeper.sh/v1alpha1/namespaces/<ns>/configs/config
which seems to work fine.What I believe is happening is that
validateConfigResource()
doesn't grok how to deal with this method of deletion. Thekube-controller-manager
is effectively saying "delete allConfig
s" without specifying a name, and sovalidateConfigResource()
returns a violation because the name is blank, notconfig
.What did you expect to happen:
Deleting a namespace containing a Gatekeeper OPA Config resource should not result in the
kube-controller-manager
getting blocked trying to delete theconfig
resource because of a Gatekeeper validation error.Environment:
kubectl version
): Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.8", GitCommit:"395f0a2fdc940aeb9ab88849e8fa4321decbf6e1", GitTreeState:"clean", BuildDate:"2023-08-24T00:43:07Z", GoVersion:"go1.20.7", Compiler:"gc", Platform:"linux/amd64"}The text was updated successfully, but these errors were encountered: