GithubHelp home page GithubHelp logo

Comments (6)

garethr avatar garethr commented on July 24, 2024 1

So, according to the specification this is actually doing the right thing. However Kubernetes doesn't use quite the same rules internally so kubeval is finding a bunch of similar issues. I'll open upstream bugs when I get a moment and also talk to SIG API Machinery about the actual internal implementation so I can have kubeval do the right thing.

From the upstream OpenAPI description at https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

io.k8s.api.core.v1.ResourceRequirements: {
  description: "ResourceRequirements describes the compute resource requirements.",
  properties: {
    limits: {
      description: "Limits describes the maximum amount of compute resources allowed. More info: 
https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/",
      type: "object",
      additionalProperties: {
        $ref: "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
      }
    },
    requests: {
      description: "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/",
      type: "object",
      additionalProperties: {
        $ref: "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
      }
    }
  }
},

Note that cpu and memory are not explicitly defined, but resources can take additional properties as long as they are of type quantity. Quantity is defined as:

io.k8s.apimachinery.pkg.api.resource.Quantity: {
  type: "string"
},

So:

  • the error appears at the limit and request key because they are additional properties. I'll see if the actual key is available from the json schema Go library, or file a bug for that
  • the spec actually says this should be a string. If you try with "200m" I think it will work for instance.
  • Kubernetes accepts null to mean blank string, hence the [string,null] part of the error which kubeval adds in

from kubeval.

garethr avatar garethr commented on July 24, 2024 1

Posted a clarifying question to SIG API Machinery at https://groups.google.com/forum/#!topic/kubernetes-sig-api-machinery/dLCXrZRwWpU

from kubeval.

garethr avatar garethr commented on July 24, 2024 1

This should now work as expected. Tests in 06e025e

The fix is in the upstream schemas in 06e025e so should work without needing you to update kubeval.

from kubeval.

garethr avatar garethr commented on July 24, 2024

This is not really a bug. It's a convenience feature specific to Quantity

I'll update the upstream specs to allow Quantity to be a number.

from kubeval.

garethr avatar garethr commented on July 24, 2024

I've also opened an upstream bug to track a fix in this spec kubernetes/kubernetes#50957

from kubeval.

thedrow avatar thedrow commented on July 24, 2024

Wonderful! Thank you very much.

from kubeval.

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.