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