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

Plural field in constraints CRD is always singular #2751

Closed
mrueg opened this issue May 10, 2023 · 2 comments
Closed

Plural field in constraints CRD is always singular #2751

mrueg opened this issue May 10, 2023 · 2 comments
Labels
bug Something isn't working stale

Comments

@mrueg
Copy link
Contributor

mrueg commented May 10, 2023

What steps did you take and what happened:

  • Apply a constrainttemplate containerdenyprivileged

  • Apply a constraint containerdenyprivileged matching this template

  • Run:
    kubectl get customresourcedefinitions.apiextensions.k8s.io containerdenyprivileged.constraints.gatekeeper.sh -o yaml

spec:
  names:
   plural: containerdenyprivileged

What did you expect to happen:

spec:
  names:
   plural: containerdenyprivilegeds

Anything else you would like to add:

Kubernetes makes an unsafe guess on the plural from the ResourceName using https://github.com/kubernetes/kubernetes/blob/0383802c906edc31431c83307301138f2e53982d/staging/src/k8s.io/apimachinery/pkg/api/meta/restmapper.go#L126 if the client did not specify a resourcePlural (which a lot don't and simply rely on the same logic). It would be nice if gatekeeper would implement the same logic to generate the CRD.
See also: kubernetes/client-go#1082

Environment:

  • Gatekeeper version: 3.11.0
  • Kubernetes version: (use kubectl version): 1.25
@mrueg mrueg added the bug Something isn't working label May 10, 2023
@davis-haba
Copy link
Contributor

davis-haba commented May 10, 2023

Hi,

Our intention in not adopting the pluralizing logic is to ensure a 1-1 mapping between a ConstraintTemplate and it's generated CRD, without any guesswork on how it might have been pluralized.

The Constraint Framework is also intended to be abstracted from KRM. For example, GCP Config Validator uses the Constraint Framework to evaluate policy on Google cloud resources. As such, we do not feel strongly that we need to honor K8s idioms in this case.

I am curious if there any operational issue you are facing here or if the motivation is more philosophical. Is the non-pluralized CRD generation blocking you from doing something or making something difficult?

Thanks.

@stale
Copy link

stale bot commented Jul 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 10, 2023
@stale stale bot closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants