Added cluster size autoscaling e2e test
This commit is contained in:
@@ -34,6 +34,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
apierrs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
|
||||
@@ -167,6 +168,8 @@ type RCConfig struct {
|
||||
Timeout time.Duration
|
||||
PodStatusFile *os.File
|
||||
Replicas int
|
||||
CpuLimit int64 // millicores
|
||||
MemLimit int64 // bytes
|
||||
|
||||
// Env vars, set the same for every pod.
|
||||
Env map[string]string
|
||||
@@ -1081,6 +1084,16 @@ func RunRC(config RCConfig) error {
|
||||
c.Ports = append(c.Ports, api.ContainerPort{Name: k, ContainerPort: v})
|
||||
}
|
||||
}
|
||||
if config.CpuLimit > 0 || config.MemLimit > 0 {
|
||||
rc.Spec.Template.Spec.Containers[0].Resources.Limits = api.ResourceList{}
|
||||
}
|
||||
if config.CpuLimit > 0 {
|
||||
rc.Spec.Template.Spec.Containers[0].Resources.Limits[api.ResourceCPU] = *resource.NewMilliQuantity(config.CpuLimit, resource.DecimalSI)
|
||||
}
|
||||
if config.MemLimit > 0 {
|
||||
rc.Spec.Template.Spec.Containers[0].Resources.Limits[api.ResourceMemory] = *resource.NewQuantity(config.MemLimit, resource.DecimalSI)
|
||||
}
|
||||
|
||||
_, err := config.Client.ReplicationControllers(config.Namespace).Create(rc)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating replication controller: %v", err)
|
||||
|
Reference in New Issue
Block a user