mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-05 20:07:20 +02:00
Set maximum CPU and Memory requests on K8s (#1959)
* Set maximum CPU and Memory requests on K8s
This commit is contained in:
@@ -54,6 +54,8 @@ type Resources struct {
|
||||
DefaultMemoryLimit string `name:"default_memory_limit" default:"500Mi"`
|
||||
MinCPULimit string `name:"min_cpu_limit" default:"250m"`
|
||||
MinMemoryLimit string `name:"min_memory_limit" default:"250Mi"`
|
||||
MaxCPURequest string `name:"max_cpu_request"`
|
||||
MaxMemoryRequest string `name:"max_memory_request"`
|
||||
PodEnvironmentConfigMap spec.NamespacedName `name:"pod_environment_configmap"`
|
||||
PodEnvironmentSecret string `name:"pod_environment_secret"`
|
||||
NodeReadinessLabel map[string]string `name:"node_readiness_label" default:""`
|
||||
|
||||
@@ -367,3 +367,21 @@ func IsSmallerQuantity(requestStr, limitStr string) (bool, error) {
|
||||
|
||||
return request.Cmp(limit) == -1, nil
|
||||
}
|
||||
|
||||
func MinResource(maxRequestStr, requestStr string) (resource.Quantity, error) {
|
||||
|
||||
isSmaller, err := IsSmallerQuantity(maxRequestStr, requestStr)
|
||||
if isSmaller && err == nil {
|
||||
maxRequest, err := resource.ParseQuantity(maxRequestStr)
|
||||
if err != nil {
|
||||
return maxRequest, err
|
||||
}
|
||||
return maxRequest, nil
|
||||
}
|
||||
|
||||
request, err := resource.ParseQuantity(requestStr)
|
||||
if err != nil {
|
||||
return request, err
|
||||
}
|
||||
return request, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user