kuberig-io / kuberig-dsl

KubeRig DSL generation code
https://kuberig.io
Apache License 2.0
8 stars 0 forks source link

improve DSL syntax for resource requirements quantity #5

Open teyckmans opened 5 years ago

teyckmans commented 5 years ago

This needs some polishing:

requests {
    request("cpu") {
        quantity("500m")
    }
    request("memory") {
        quantity("250Mi")
    }
}
limits {
    limit("cpu") {
        quantity("1000m")
    }
    limit("memory") {
        quantity("500Mi")
    }
}

Would be nice to have this:

requests {
    cpu(500, [MILLICPU, MILLICORES])
    memory(250, [E, P, T, G, M, K, Ei, Pi, Ti, Gi, Mi, Ki])
}

With m and Mi being values of enums.

teyckmans commented 5 years ago

might be better/cleaner to solve this with an extension function

resources(
    cpuRequest="500m", 
    memoryRequest="250Mi",
    cpuLimit="1000m",
    memoryLimit="500Mi"
)
teyckmans commented 5 years ago

it may be needed to model the unit, to allow for smart policies to set limit, e.g. maxMemory(10, G)