Skip to content

Instantly share code, notes, and snippets.

@teyckmans teyckmans/DslExtensions.kt
Last active May 26, 2019

Embed
What would you like to do?
KubeRig resourcesHelper extension function
package example
import io.k8s.api.core.v1.ContainerDsl
fun ContainerDsl.resourcesHelper(cpuRequest: String = "", memoryRequest: String = "", cpuLimit: String = "", memoryLimit: String = "") {
resources {
if (cpuRequest != "" || memoryRequest != "") {
requests {
if (cpuRequest != "") {
request("cpu") {
quantity(cpuRequest)
}
}
if (memoryRequest != "") {
request("memory") {
quantity(memoryRequest)
}
}
}
}
if (cpuLimit != "" || memoryLimit != "") {
limits {
if (cpuLimit != "") {
limit("cpu") {
quantity(cpuLimit)
}
}
if (memoryLimit != "") {
limit("memory") {
quantity(memoryLimit)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.