[Kubernetes] Action to scale Pod up/down
Change-Id: I6b2737524955b1f72b6a692559d3942cbb60deb7 Closes-Bug: #1449599
This commit is contained in:
parent
6659c87a67
commit
17fea01068
Kubernetes
KubernetesCluster/package
KubernetesPod/package/Classes
@ -494,3 +494,17 @@ Methods:
|
||||
- $._environment.reporter.report($this, 'Got archive from Kubernetes')
|
||||
- Return: new(std:File, base64Content => $result.content,
|
||||
filename => 'application.tar.gz')
|
||||
|
||||
|
||||
scaleRc:
|
||||
Arguments:
|
||||
- rcName:
|
||||
Contract: $.string().notNull()
|
||||
- newSize:
|
||||
Contract: $.int().notNull()
|
||||
Body:
|
||||
- $template: $resources.yaml('ScaleRc.template').bind(dict(
|
||||
rcName => $rcName,
|
||||
newSize => $newSize
|
||||
))
|
||||
- $.masterNode.instance.agent.call($template, $resources)
|
||||
|
@ -0,0 +1,32 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
FormatVersion: 2.0.0
|
||||
Version: 1.0.0
|
||||
Name: Scale Pod
|
||||
|
||||
Parameters:
|
||||
rcName: $rcName
|
||||
newSize: $newSize
|
||||
|
||||
Body: |
|
||||
return scaleRc('{0} {1}'.format(args.rcName, args.newSize).stdout
|
||||
|
||||
Scripts:
|
||||
scaleRc:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: scale-rc.sh
|
||||
Files: []
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# $1 - RC name
|
||||
# $2 - new size
|
||||
|
||||
/opt/bin/kubectl scale rc $1 --replicas=$2
|
@ -35,6 +35,7 @@ Properties:
|
||||
|
||||
replicas:
|
||||
Contract: $.int().notNull().check($ >= 0)
|
||||
Usage: InOut
|
||||
|
||||
|
||||
Methods:
|
||||
@ -303,3 +304,26 @@ Methods:
|
||||
getInternalScopeId:
|
||||
Body:
|
||||
Return: $.kubernetesCluster.id()
|
||||
|
||||
scalePodDown:
|
||||
Usage: Action
|
||||
Body:
|
||||
- If: $.replicas > 1
|
||||
Then:
|
||||
- $._environment.reporter.report($this, 'Scaling Pod down')
|
||||
- $.replicas: $.replicas - 1
|
||||
- $.kubernetesCluster.scaleRc(rcName => $._getReplicationControllerId(), newSize => $.replicas)
|
||||
Else:
|
||||
- $._environment.reporter.report($this, 'Cannot scale Pod down')
|
||||
|
||||
|
||||
scalePodUp:
|
||||
Usage: Action
|
||||
Body:
|
||||
- If: $.replicas > 0
|
||||
Then:
|
||||
- $._environment.reporter.report($this, 'Scaling Pod up')
|
||||
- $.replicas: $.replicas + 1
|
||||
- $.kubernetesCluster.scaleRc(rcName => $._getReplicationControllerId(), newSize => $.replicas)
|
||||
Else:
|
||||
- $._environment.reporter.report($this, 'Cannot scale Pod up')
|
||||
|
Loading…
x
Reference in New Issue
Block a user