Skip to content

Instantly share code, notes, and snippets.

@teyckmans
Last active May 26, 2019 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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