Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smarterclayton/a848ca31726146da769de1982f4d0a5c to your computer and use it in GitHub Desktop.
Save smarterclayton/a848ca31726146da769de1982f4d0a5c to your computer and use it in GitHub Desktop.
if quota := v.CPUQuota; quota > 0 {
if quota < 1000 {
quota = 1000 // minQuotaPeriod
}
milliCPU := quota * 1000 // milliCPUtoCPU
milliCPU = milliCPU / 100000 // quotaPeriod
c.Resources.Limits[kapi.ResourceCPU] = resource.NewMilliQuantity(milliCPU, resource.DecimalSI)
}
if shares := v.CPUShares; shares > 0 {
if shares < 2 {
shares = 2 // minShares
}
milliCPU := quota * 1000 // milliCPUtoCPU
milliCPU = milliCPU / 1024 // sharesPerCPU
c.Resources.Requests[kapi.ResourceCPU] = resource.NewMilliQuantity(milliCPU, resource.DecimalSI)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment