Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
400e6856
Commit
400e6856
authored
Sep 17, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14036 from socaa/hpa-mem-tests
Auto commit by PR queue bot
parents
445fde3d
e837209f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
181 additions
and
40 deletions
+181
-40
autoscaling_utils.go
test/e2e/autoscaling_utils.go
+80
-20
horizontal_pod_autoscaling.go
test/e2e/horizontal_pod_autoscaling.go
+101
-20
No files found.
test/e2e/autoscaling_utils.go
View file @
400e6856
...
@@ -31,10 +31,11 @@ const (
...
@@ -31,10 +31,11 @@ const (
consumptionTimeInSeconds
=
30
consumptionTimeInSeconds
=
30
sleepTime
=
30
*
time
.
Second
sleepTime
=
30
*
time
.
Second
requestSizeInMillicores
=
100
requestSizeInMillicores
=
100
requestSizeInMegabytes
=
100
port
=
80
port
=
80
targetPort
=
8080
targetPort
=
8080
timeoutRC
=
120
*
time
.
Second
timeoutRC
=
120
*
time
.
Second
image
=
"gcr.io/google_containers/resource_consumer:
alph
a"
image
=
"gcr.io/google_containers/resource_consumer:
bet
a"
rcIsNil
=
"ERROR: replicationController = nil"
rcIsNil
=
"ERROR: replicationController = nil"
)
)
...
@@ -49,60 +50,101 @@ rc.ConsumeCPU(300)
...
@@ -49,60 +50,101 @@ rc.ConsumeCPU(300)
type
ResourceConsumer
struct
{
type
ResourceConsumer
struct
{
name
string
name
string
framework
*
Framework
framework
*
Framework
channel
chan
int
cpu
chan
int
stop
chan
int
mem
chan
int
stopCPU
chan
int
stopMem
chan
int
}
}
// NewResourceConsumer creates new ResourceConsumer
/*
// cpu argument is in millicores
NewResourceConsumer creates new ResourceConsumer
func
NewResourceConsumer
(
name
string
,
replicas
int
,
cpu
int
,
framework
*
Framework
)
*
ResourceConsumer
{
initCPU argument is in millicores
initMemory argument is in megabytes
*/
func
NewResourceConsumer
(
name
string
,
replicas
,
initCPU
,
initMemory
int
,
framework
*
Framework
)
*
ResourceConsumer
{
runServiceAndRCForResourceConsumer
(
framework
.
Client
,
framework
.
Namespace
.
Name
,
name
,
replicas
)
runServiceAndRCForResourceConsumer
(
framework
.
Client
,
framework
.
Namespace
.
Name
,
name
,
replicas
)
rc
:=
&
ResourceConsumer
{
rc
:=
&
ResourceConsumer
{
name
:
name
,
name
:
name
,
framework
:
framework
,
framework
:
framework
,
channel
:
make
(
chan
int
),
cpu
:
make
(
chan
int
),
stop
:
make
(
chan
int
),
mem
:
make
(
chan
int
),
stopCPU
:
make
(
chan
int
),
stopMem
:
make
(
chan
int
),
}
}
go
rc
.
makeConsumeCPURequests
()
go
rc
.
makeConsumeCPURequests
()
rc
.
ConsumeCPU
(
cpu
)
rc
.
ConsumeCPU
(
initCPU
)
go
rc
.
makeConsumeMemRequests
()
rc
.
ConsumeMem
(
initMemory
)
return
rc
return
rc
}
}
// ConsumeCPU consumes given number of CPU
// ConsumeCPU consumes given number of CPU
func
(
rc
*
ResourceConsumer
)
ConsumeCPU
(
millicores
int
)
{
func
(
rc
*
ResourceConsumer
)
ConsumeCPU
(
millicores
int
)
{
rc
.
channel
<-
millicores
rc
.
cpu
<-
millicores
}
// ConsumeMem consumes given number of Mem
func
(
rc
*
ResourceConsumer
)
ConsumeMem
(
megabytes
int
)
{
rc
.
mem
<-
megabytes
}
}
func
(
rc
*
ResourceConsumer
)
makeConsumeCPURequests
()
{
func
(
rc
*
ResourceConsumer
)
makeConsumeCPURequests
()
{
defer
GinkgoRecover
()
var
count
int
var
count
int
var
rest
int
var
rest
int
for
{
for
{
select
{
select
{
case
millicores
:=
<-
rc
.
c
hannel
:
case
millicores
:=
<-
rc
.
c
pu
:
count
=
millicores
/
requestSizeInMillicores
count
=
millicores
/
requestSizeInMillicores
rest
=
millicores
-
count
*
requestSizeInMillicores
rest
=
millicores
-
count
*
requestSizeInMillicores
case
<-
time
.
After
(
sleepTime
)
:
case
<-
time
.
After
(
sleepTime
)
:
if
count
>
0
{
if
count
>
0
{
rc
.
sendConsumeCPUrequests
(
count
,
requestSizeInMillicores
,
consumptionTimeInSeconds
)
rc
.
sendConsumeCPURequests
(
count
,
requestSizeInMillicores
,
consumptionTimeInSeconds
)
}
if
rest
>
0
{
go
rc
.
sendOneConsumeCPURequest
(
rest
,
consumptionTimeInSeconds
)
}
case
<-
rc
.
stopCPU
:
return
}
}
}
func
(
rc
*
ResourceConsumer
)
makeConsumeMemRequests
()
{
var
count
int
var
rest
int
for
{
select
{
case
megabytes
:=
<-
rc
.
mem
:
count
=
megabytes
/
requestSizeInMegabytes
rest
=
megabytes
-
count
*
requestSizeInMegabytes
case
<-
time
.
After
(
sleepTime
)
:
if
count
>
0
{
rc
.
sendConsumeMemRequests
(
count
,
requestSizeInMegabytes
,
consumptionTimeInSeconds
)
}
}
if
rest
>
0
{
if
rest
>
0
{
go
rc
.
sendOneConsume
CPUr
equest
(
rest
,
consumptionTimeInSeconds
)
go
rc
.
sendOneConsume
MemR
equest
(
rest
,
consumptionTimeInSeconds
)
}
}
case
<-
rc
.
stop
:
case
<-
rc
.
stop
Mem
:
return
return
}
}
}
}
}
}
func
(
rc
*
ResourceConsumer
)
sendConsumeCPU
r
equests
(
requests
,
millicores
,
durationSec
int
)
{
func
(
rc
*
ResourceConsumer
)
sendConsumeCPU
R
equests
(
requests
,
millicores
,
durationSec
int
)
{
for
i
:=
0
;
i
<
requests
;
i
++
{
for
i
:=
0
;
i
<
requests
;
i
++
{
go
rc
.
sendOneConsumeCPU
r
equest
(
millicores
,
durationSec
)
go
rc
.
sendOneConsumeCPU
R
equest
(
millicores
,
durationSec
)
}
}
}
}
// sendOneConsumeCPUrequest sends POST request for cpu consumption
func
(
rc
*
ResourceConsumer
)
sendConsumeMemRequests
(
requests
,
megabytes
,
durationSec
int
)
{
func
(
rc
*
ResourceConsumer
)
sendOneConsumeCPUrequest
(
millicores
int
,
durationSec
int
)
{
for
i
:=
0
;
i
<
requests
;
i
++
{
go
rc
.
sendOneConsumeMemRequest
(
megabytes
,
durationSec
)
}
}
// sendOneConsumeCPURequest sends POST request for cpu consumption
func
(
rc
*
ResourceConsumer
)
sendOneConsumeCPURequest
(
millicores
int
,
durationSec
int
)
{
defer
GinkgoRecover
()
_
,
err
:=
rc
.
framework
.
Client
.
Post
()
.
_
,
err
:=
rc
.
framework
.
Client
.
Post
()
.
Prefix
(
"proxy"
)
.
Prefix
(
"proxy"
)
.
Namespace
(
rc
.
framework
.
Namespace
.
Name
)
.
Namespace
(
rc
.
framework
.
Namespace
.
Name
)
.
...
@@ -116,6 +158,22 @@ func (rc *ResourceConsumer) sendOneConsumeCPUrequest(millicores int, durationSec
...
@@ -116,6 +158,22 @@ func (rc *ResourceConsumer) sendOneConsumeCPUrequest(millicores int, durationSec
expectNoError
(
err
)
expectNoError
(
err
)
}
}
// sendOneConsumeMemRequest sends POST request for memory consumption
func
(
rc
*
ResourceConsumer
)
sendOneConsumeMemRequest
(
megabytes
int
,
durationSec
int
)
{
defer
GinkgoRecover
()
_
,
err
:=
rc
.
framework
.
Client
.
Post
()
.
Prefix
(
"proxy"
)
.
Namespace
(
rc
.
framework
.
Namespace
.
Name
)
.
Resource
(
"services"
)
.
Name
(
rc
.
name
)
.
Suffix
(
"ConsumeMem"
)
.
Param
(
"megabytes"
,
strconv
.
Itoa
(
megabytes
))
.
Param
(
"durationSec"
,
strconv
.
Itoa
(
durationSec
))
.
Do
()
.
Raw
()
expectNoError
(
err
)
}
func
(
rc
*
ResourceConsumer
)
GetReplicas
()
int
{
func
(
rc
*
ResourceConsumer
)
GetReplicas
()
int
{
replicationController
,
err
:=
rc
.
framework
.
Client
.
ReplicationControllers
(
rc
.
framework
.
Namespace
.
Name
)
.
Get
(
rc
.
name
)
replicationController
,
err
:=
rc
.
framework
.
Client
.
ReplicationControllers
(
rc
.
framework
.
Namespace
.
Name
)
.
Get
(
rc
.
name
)
expectNoError
(
err
)
expectNoError
(
err
)
...
@@ -139,7 +197,8 @@ func (rc *ResourceConsumer) WaitForReplicas(desiredReplicas int) {
...
@@ -139,7 +197,8 @@ func (rc *ResourceConsumer) WaitForReplicas(desiredReplicas int) {
}
}
func
(
rc
*
ResourceConsumer
)
CleanUp
()
{
func
(
rc
*
ResourceConsumer
)
CleanUp
()
{
rc
.
stop
<-
0
rc
.
stopCPU
<-
0
rc
.
stopMem
<-
0
expectNoError
(
DeleteRC
(
rc
.
framework
.
Client
,
rc
.
framework
.
Namespace
.
Name
,
rc
.
name
))
expectNoError
(
DeleteRC
(
rc
.
framework
.
Client
,
rc
.
framework
.
Namespace
.
Name
,
rc
.
name
))
expectNoError
(
rc
.
framework
.
Client
.
Services
(
rc
.
framework
.
Namespace
.
Name
)
.
Delete
(
rc
.
name
))
expectNoError
(
rc
.
framework
.
Client
.
Services
(
rc
.
framework
.
Namespace
.
Name
)
.
Delete
(
rc
.
name
))
expectNoError
(
rc
.
framework
.
Client
.
Experimental
()
.
HorizontalPodAutoscalers
(
rc
.
framework
.
Namespace
.
Name
)
.
Delete
(
rc
.
name
,
api
.
NewDeleteOptions
(
0
)))
expectNoError
(
rc
.
framework
.
Client
.
Experimental
()
.
HorizontalPodAutoscalers
(
rc
.
framework
.
Namespace
.
Name
)
.
Delete
(
rc
.
name
,
api
.
NewDeleteOptions
(
0
)))
...
@@ -171,4 +230,5 @@ func runServiceAndRCForResourceConsumer(c *client.Client, ns, name string, repli
...
@@ -171,4 +230,5 @@ func runServiceAndRCForResourceConsumer(c *client.Client, ns, name string, repli
Replicas
:
replicas
,
Replicas
:
replicas
,
}
}
expectNoError
(
RunRC
(
config
))
expectNoError
(
RunRC
(
config
))
}
}
test/e2e/horizontal_pod_autoscaling.go
View file @
400e6856
...
@@ -17,8 +17,6 @@ limitations under the License.
...
@@ -17,8 +17,6 @@ limitations under the License.
package
e2e
package
e2e
import
(
import
(
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/apis/experimental"
"k8s.io/kubernetes/pkg/apis/experimental"
...
@@ -27,7 +25,8 @@ import (
...
@@ -27,7 +25,8 @@ import (
)
)
const
(
const
(
sleep
=
10
*
time
.
Minute
kind
=
"replicationController"
subresource
=
"scale"
)
)
var
_
=
Describe
(
"Horizontal pod autoscaling"
,
func
()
{
var
_
=
Describe
(
"Horizontal pod autoscaling"
,
func
()
{
...
@@ -41,30 +40,31 @@ var _ = Describe("Horizontal pod autoscaling", func() {
...
@@ -41,30 +40,31 @@ var _ = Describe("Horizontal pod autoscaling", func() {
AfterEach
(
func
()
{
AfterEach
(
func
()
{
})
})
// CPU tests
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.3"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.3"
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
3
)
rc
.
CleanUp
()
rc
.
CleanUp
()
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.7"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.7"
)
rc
.
WaitForReplicas
(
1
)
rc
.
WaitForReplicas
(
1
)
rc
.
CleanUp
()
rc
.
CleanUp
()
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.1"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.1"
)
rc
.
WaitForReplicas
(
5
)
rc
.
WaitForReplicas
(
5
)
rc
.
CleanUp
()
rc
.
CleanUp
()
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
1
,
700
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.3"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.3"
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeCPU
(
300
)
rc
.
ConsumeCPU
(
300
)
rc
.
WaitForReplicas
(
1
)
rc
.
WaitForReplicas
(
1
)
...
@@ -72,8 +72,8 @@ var _ = Describe("Horizontal pod autoscaling", func() {
...
@@ -72,8 +72,8 @@ var _ = Describe("Horizontal pod autoscaling", func() {
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
300
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
1
,
300
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.1"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.1"
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeCPU
(
700
)
rc
.
ConsumeCPU
(
700
)
rc
.
WaitForReplicas
(
5
)
rc
.
WaitForReplicas
(
5
)
...
@@ -81,8 +81,8 @@ var _ = Describe("Horizontal pod autoscaling", func() {
...
@@ -81,8 +81,8 @@ var _ = Describe("Horizontal pod autoscaling", func() {
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.3"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.3"
)
rc
.
WaitForReplicas
(
1
)
rc
.
WaitForReplicas
(
1
)
rc
.
ConsumeCPU
(
700
)
rc
.
ConsumeCPU
(
700
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
3
)
...
@@ -90,17 +90,75 @@ var _ = Describe("Horizontal pod autoscaling", func() {
...
@@ -90,17 +90,75 @@ var _ = Describe("Horizontal pod autoscaling", func() {
})
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: CPU)"
,
func
()
{
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: CPU)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
5
,
700
,
f
)
rc
=
NewResourceConsumer
(
"rc"
,
5
,
700
,
0
,
f
)
createHorizontalPodAutoscaler
(
rc
,
"0.3"
)
create
CPU
HorizontalPodAutoscaler
(
rc
,
"0.3"
)
rc
.
WaitForReplicas
(
3
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeCPU
(
100
)
rc
.
ConsumeCPU
(
100
)
rc
.
WaitForReplicas
(
1
)
rc
.
WaitForReplicas
(
1
)
rc
.
CleanUp
()
rc
.
CleanUp
()
})
})
// Memory tests
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
0
,
800
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"300"
)
rc
.
WaitForReplicas
(
3
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
0
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"700"
)
rc
.
WaitForReplicas
(
1
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
0
,
700
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"100"
)
rc
.
WaitForReplicas
(
5
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
0
,
700
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"300"
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeMem
(
100
)
rc
.
WaitForReplicas
(
1
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
1
,
0
,
500
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"200"
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeMem
(
1000
)
rc
.
WaitForReplicas
(
5
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
3
,
0
,
0
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"300"
)
rc
.
WaitForReplicas
(
1
)
rc
.
ConsumeMem
(
700
)
rc
.
WaitForReplicas
(
3
)
rc
.
CleanUp
()
})
It
(
"[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: Memory)"
,
func
()
{
rc
=
NewResourceConsumer
(
"rc"
,
5
,
0
,
700
,
f
)
createMemoryHorizontalPodAutoscaler
(
rc
,
"300"
)
rc
.
WaitForReplicas
(
3
)
rc
.
ConsumeMem
(
100
)
rc
.
WaitForReplicas
(
1
)
rc
.
CleanUp
()
})
})
})
func
createHorizontalPodAutoscaler
(
rc
*
ResourceConsumer
,
cpu
string
)
{
func
create
CPU
HorizontalPodAutoscaler
(
rc
*
ResourceConsumer
,
cpu
string
)
{
hpa
:=
&
experimental
.
HorizontalPodAutoscaler
{
hpa
:=
&
experimental
.
HorizontalPodAutoscaler
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
rc
.
name
,
Name
:
rc
.
name
,
...
@@ -108,10 +166,10 @@ func createHorizontalPodAutoscaler(rc *ResourceConsumer, cpu string) {
...
@@ -108,10 +166,10 @@ func createHorizontalPodAutoscaler(rc *ResourceConsumer, cpu string) {
},
},
Spec
:
experimental
.
HorizontalPodAutoscalerSpec
{
Spec
:
experimental
.
HorizontalPodAutoscalerSpec
{
ScaleRef
:
&
experimental
.
SubresourceReference
{
ScaleRef
:
&
experimental
.
SubresourceReference
{
Kind
:
"replicationController"
,
Kind
:
kind
,
Name
:
rc
.
name
,
Name
:
rc
.
name
,
Namespace
:
rc
.
framework
.
Namespace
.
Name
,
Namespace
:
rc
.
framework
.
Namespace
.
Name
,
Subresource
:
"scale"
,
Subresource
:
subresource
,
},
},
MinCount
:
1
,
MinCount
:
1
,
MaxCount
:
5
,
MaxCount
:
5
,
...
@@ -121,3 +179,26 @@ func createHorizontalPodAutoscaler(rc *ResourceConsumer, cpu string) {
...
@@ -121,3 +179,26 @@ func createHorizontalPodAutoscaler(rc *ResourceConsumer, cpu string) {
_
,
errHPA
:=
rc
.
framework
.
Client
.
Experimental
()
.
HorizontalPodAutoscalers
(
rc
.
framework
.
Namespace
.
Name
)
.
Create
(
hpa
)
_
,
errHPA
:=
rc
.
framework
.
Client
.
Experimental
()
.
HorizontalPodAutoscalers
(
rc
.
framework
.
Namespace
.
Name
)
.
Create
(
hpa
)
expectNoError
(
errHPA
)
expectNoError
(
errHPA
)
}
}
// argument memory is in megabytes
func
createMemoryHorizontalPodAutoscaler
(
rc
*
ResourceConsumer
,
memory
string
)
{
hpa
:=
&
experimental
.
HorizontalPodAutoscaler
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
rc
.
name
,
Namespace
:
rc
.
framework
.
Namespace
.
Name
,
},
Spec
:
experimental
.
HorizontalPodAutoscalerSpec
{
ScaleRef
:
&
experimental
.
SubresourceReference
{
Kind
:
kind
,
Name
:
rc
.
name
,
Namespace
:
rc
.
framework
.
Namespace
.
Name
,
Subresource
:
subresource
,
},
MinCount
:
1
,
MaxCount
:
5
,
Target
:
experimental
.
ResourceConsumption
{
Resource
:
api
.
ResourceMemory
,
Quantity
:
resource
.
MustParse
(
memory
+
"M"
)},
},
}
_
,
errHPA
:=
rc
.
framework
.
Client
.
Experimental
()
.
HorizontalPodAutoscalers
(
rc
.
framework
.
Namespace
.
Name
)
.
Create
(
hpa
)
expectNoError
(
errHPA
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment