Giter Club home page Giter Club logo

Comments (18)

liggitt avatar liggitt commented on May 27, 2024 1

fwiw, optionals can make that more concise:

self.?status.?conditions.orValue([]).exists(c, c.type == 'QuotaReserved' && c.status == 'True')

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

/sig api-machinery
cc @cici37 @jpbetz

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

@IrvingMg, @trasc did I miss anything important?

from kubernetes.

sftim avatar sftim commented on May 27, 2024

What do you mean by Pod templates @alculquicondor?

One pattern I'd like to see used more: when you create something that embeds a Pod template, the controller for that kind tries to dry-run make a PodTemplate. That way you get one place to put customer validation (eg a ValidatingAdmissionPolicy), and it can apply to lots of API kinds without repetition.

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

One pattern I'd like to see used more: when you create something that embeds a Pod template, the controller for that kind tries to dry-run make a PodTemplate.

Interesting. I've never seen that. It sounds bullet proof from a validation perspective. Is there dry-run support in the apiserver? But then it would have to be called from the webhook?

from kubernetes.

jpbetz avatar jpbetz commented on May 27, 2024

Regexes for object names, label keys, values, container names, etc. I think this one is already in the works?

Yes, this one is progressing here: #123572 (cc @alexzielenski)

from kubernetes.

jpbetz avatar jpbetz commented on May 27, 2024

The ultimate validation: Pod templates, but worth starting with just containers :) Very useful for job CRDs.

We might do something special to validated embedded types like this that doesn't involved CEL. But yes, I agree there is a huge need here. Do you happen to have any references to specific use cases? I'm working on accumulating those.

from kubernetes.

liggitt avatar liggitt commented on May 27, 2024

Is there dry-run support in the apiserver?

yes, since 1.12: https://github.com/kubernetes/kubernetes/blob/release-1.12/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L485-L491

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

Re: dry-run support
I see. Still, that would imply that a webhook has to do an API call. Would you still recommend this?

Do you happen to have any references to specific use cases?

  1. All of the kubeflow job CRDs, to start. They will eventually fail at Pod or k8s Job creation, if the template is wrong, as they are not doing any validation.
  2. Kueue Workload objects https://kueue.sigs.k8s.io/docs/concepts/workload/. These are created out of existing Jobs, Pods, or arbitrary CRDs (like Kubeflow jobs). The only problematic case is the last one.

from kubernetes.

kannon92 avatar kannon92 commented on May 27, 2024
  1. JobSet validation (based on JobTemplates) kubernetes-sigs/jobset#422

from kubernetes.

kannon92 avatar kannon92 commented on May 27, 2024

@danielvegamyhre was looking into kubectl-validate as a way to validate templates as a library.

from kubernetes.

IrvingMg avatar IrvingMg commented on May 27, 2024

@IrvingMg, @trasc did I miss anything important?

Not that I can think of. That's everything we need for now.

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

WRT conditions, right now, we have to do things like this:

has(self.status) && has(self.status.conditions) && self.status.conditions.exists(c, c.type == 'QuotaReserved' && c.status == 'True')

It would be good to have a simplified experience, similar to meta.IsConditionTrue in golang.

I added a separate item for this.

from kubernetes.

fedebongio avatar fedebongio commented on May 27, 2024

/cc @cici37 @alexzielenski @jpbetz
/triage accepted

from kubernetes.

TristonianJones avatar TristonianJones commented on May 27, 2024

@alculquicondor is part of the issue that there isn't support for variables within CRD validations? I'm certain that the ValidatingAdmissionPolicy support for variables is instrumental in making the config as DRY as possible.

from kubernetes.

alexzielenski avatar alexzielenski commented on May 27, 2024

FWIW I have a draft KEP I was hoping to implement this release (maybe deferred to next) to add variables also to CRDs

kubernetes/enhancements#4590

from kubernetes.

alculquicondor avatar alculquicondor commented on May 27, 2024

I wasn't aware that CEL itself supported variables. That could help.

But, in general, there are common structs that multiple APIs might want to use, and we should have library validations for those.

from kubernetes.

jpbetz avatar jpbetz commented on May 27, 2024

But, in general, there are common structs that multiple APIs might want to use, and we should have library validations for those.

100% agree on this. I'd like it to feel to a CEL user like the language "understand" kubernetes resources and the types found within them. This includes quantities, durations, date-times, int-or-string, IPs, CIDRs, and all the name formats,. and maybe more sophisticated types like Conditions, selectors... We're have support for many of these and are actively working on some others, but we definitely have gaps.

from kubernetes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.