Merge "[Kubernetes] Bunch of issues regarding scaling was fixed"

This commit is contained in:
Jenkins 2015-10-27 05:34:37 +00:00 committed by Gerrit Code Review
commit c4c20022ac
7 changed files with 93 additions and 9 deletions

View File

@ -39,12 +39,13 @@ Properties:
Usage: InOut
gatewayCount:
Contract: $.int().notNull()
Contract: $.int().notNull().check($ > 0)
Usage: InOut
gatewayNodes:
Contract:
- $.class(KubernetesGatewayNode).notNull()
- 1
dockerRegistry:
Contract: $.string()
@ -119,13 +120,16 @@ Methods:
- $.gatewayNodes.take($.gatewayCount).pselect($.deployInstance())
- $.masterNode.setupEtcd()
- $.minionNodes.skip($.nodeCount).select($.removeFromCluster())
- $.gatewayNodes.skip($.gatewayCount).select($.removeFromCluster())
- $.minionNodes.take($.nodeCount).select($.setupEtcd())
- $.gatewayNodes.take($.gatewayCount).select($.setupEtcd())
- $.masterNode.setupNode()
- Parallel:
- $.minionNodes.take($.nodeCount).pselect($.setupNode())
- $.minionNodes.skip($.nodeCount).pselect($.removeFromCluster())
- $.gatewayNodes.take($.gatewayCount).pselect($.setupNode())
- $._environment.stack.push()
@ -487,6 +491,18 @@ Methods:
- $._environment.reporter.report($this, 'The maximum number of nodes has been reached')
scaleGatewaysDown:
Usage: Action
Body:
- If: $.gatewayCount > 1
Then:
- $._environment.reporter.report($this, 'Removing gateway node')
- $.gatewayCount: $.gatewayCount - 1
- $.deploy()
Else:
- $._environment.reporter.report($this, 'No gateway nodes that can be removed')
exportConfig:
Usage: Action
Body:

View File

@ -69,5 +69,23 @@ Methods:
masterIp => $._cluster.masterNode.getIp()
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report(
$this, 'Gateway {0} is now available at {1}'.format($.instance.name, $.getIp(true)))
- $.setAttr(nodeConfigured, true)
removeFromCluster:
Body:
- If: $.getAttr(nodeConfigured, false)
Then:
- $._environment.reporter.report($this, 'Deleting Gateway Node')
- $resources: new(sys:Resources)
- $template: $resources.yaml('EtcdRemoveMember.template').bind(dict(
nodeId => $.getIp()
))
- $.instance.agent.call($template, $resources)
- $.instance.releaseResources()
- $._environment.reporter.report($this, 'Gateway {0} at {1} was deleted'.format($.instance.name, $.getIp(true)))
- $.setAttr(nodeConfigured, false)
- $.setAttr(etcdConfigured, false)
- $.setAttr(instanceDeployed, false)

View File

@ -89,10 +89,7 @@ Methods:
- $.instance.agent.call($template, $resources)
- $.setAttr(nodeConfigured, true)
- $msg: 'cAdvisor monitoring for Node {0} is now available at http://{1}:4194'
- $ip: $.getIp()
- If: $.exposeCAdvisor
Then:
- $ip: coalesce($.instance.floatingIpAddress, $.getIp())
- $ip: $.getIp($.exposeCAdvisor)
- $._environment.reporter.report($this, $msg.format($.instance.name, $ip))
@ -102,10 +99,17 @@ Methods:
Then:
- $._environment.reporter.report($this, 'Deleting Kubernetes Minion')
- $resources: new(sys:Resources)
- $template: $resources.yaml('EtcdRemoveMember.template').bind(dict(
nodeId => $.getIp()
))
- $.instance.agent.call($template, $resources)
- $template: $resources.yaml('RemoveMinion.template').bind(dict(
nodeId => $.getIp()
))
- $._cluster.masterNode.instance.agent.call($template, $resources)
- $.instance.releaseResources()
- $._environment.reporter.report($this, 'Node {0} deleted'.format($.instance.name))
- $._environment.reporter.report($this, 'Node {0} was deleted'.format($.instance.name))
- $.setAttr(nodeConfigured, false)
- $.setAttr(etcdConfigured, false)
- $.setAttr(instanceDeployed, false)

View File

@ -26,8 +26,17 @@ Properties:
Methods:
getIp:
Arguments:
- preferFloatingIp:
Contract: $.bool().notNull()
Default: false
Body:
Return: $.instance.ipAddresses[0]
- $ip: $.instance.ipAddresses[0]
- If: $preferFloatingIp
Then:
- Return: coalesce($.instance.floatingIpAddress, $ip)
Else:
- Return: $.instance.ipAddresses[0]
deployInstance:
@ -37,3 +46,4 @@ Methods:
setupEtcd:
setupNode:
removeFromCluster:

View File

@ -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: Remove etcd member
Parameters:
nodeId: $nodeId
Body: |
removeMember(args.nodeId)
Scripts:
removeMember:
Type: Application
Version: 1.0.0
EntryPoint: removeEtcdMember.sh
Files: []
Options:
captureStdout: false
captureStderr: false
verifyExitcode: false

View File

@ -18,7 +18,7 @@ Parameters:
nodeId: $nodeId
Body: |
return removeMinion('{0}'.format(args.nodeId)).stdout
removeMinion(args.nodeId)
Scripts:
removeMinion:

View File

@ -0,0 +1,4 @@
#!/bin/bash
NODE_ID=$(/opt/bin/etcdctl member list | grep $1 | cut -d':' -f1)
/opt/bin/etcdctl member remove $NODE_ID