-
Notifications
You must be signed in to change notification settings - Fork 759
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
Allow additional metadata properties in constraints.gatekeeper.sh openAPIV3Schema #3013
Comments
one note: namespace cannot be defined, since constraints are cluster-scoped. IIRC adding more metadata validation beyond name length may break CRDs in K8s.
It would be nice to be able to inherit K8s' metadata schema somehow. |
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. |
You're right about namespaces, but only allowing Some options that I see:
"metadata": {
"type": "object"
}
|
In what sense is this not correct? Is it possible to create a CRD in a running K8s cluster that allows restricting/defining metadata fields other than name? The problem would be K8s disallowing creation of the CRD. |
Because this is not valid resource according to the generated schema by gatekeeper: apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: required-labels
labels:
owner: myteam
annotations:
argocd.argoproj.io/sync-wave: '2' In what way is this not a valid Kubernetes resource? E.g. |
Please refer to my original link to Kubernetes' docs in my first reply:
According to the Kubernetes docs, if you try to kubectl apply a CRD with an opinion on metadata other than name length, the cluster will reject it. |
To be clear, if you can provide an example CRD definition that does what you want that you can successfully apply on a standard K8s cluster, I'd be happy to take a closer look. |
One other issue would be how divergent the schemas can be. If a newer version of K8s adds a new metadata field, our CRD would not have that field. If that turned out to break our ability to apply CRDs, that would be bad. These are things to watch out for, assuming that this is undocumented behavior which may or may not be considered part of the k8s API |
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. |
Describe the solution you'd like
Allow standard Kubernetes metadata properties in the generated constraint resources. Either by setting
additionalProperties
or by adding the missing properties.The
metadata
section currently only allows for thename
property.gatekeeper/pkg/readiness/testdata/crds/k8shttpsonly_crd.yaml
Lines 23 to 28 in 3e66ee2
We add some company standard metadata like
namespace
,labels
, andannotations
to every resource which includes constraints.We validate our generated Kubernetes resources in CI with kubeconform with the
--strict
flag.This causes errors like the following:
Anything else you would like to add:
Our current workaround is to filter out the constraint resources before running kubeconform.
I also added a feature request in yannh/kubeconform#169 to be able to ignore all constraint resources, but I do feel this should also be fixed here.
Environment:
kubectl version
): 1.24.10The text was updated successfully, but these errors were encountered: