Merge "[kubernetes] Create actions to recreate pods and restart containers"
This commit is contained in:
commit
2bbc0f8936
@ -523,3 +523,12 @@ Methods:
|
||||
newSize => $newSize
|
||||
))
|
||||
- $.masterNode.instance.agent.call($template, $resources)
|
||||
|
||||
|
||||
restartContainers:
|
||||
Arguments:
|
||||
- podName:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
Body:
|
||||
- $.minionNodes.take($.nodeCount).pselect($.restartContainers(podName => $podName))
|
||||
|
@ -115,3 +115,17 @@ Methods:
|
||||
- $.setAttr(etcdConfigured, false)
|
||||
- $.setAttr(instanceDeployed, false)
|
||||
|
||||
|
||||
restartContainers:
|
||||
Arguments:
|
||||
- podName:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
Body:
|
||||
- $._environment.reporter.report($this, 'Restarting {0} containers on {1}'.format($podName, $.instance.name))
|
||||
- $resources: new(sys:Resources)
|
||||
- $template: $resources.yaml('RestartContainers.template').bind(dict(
|
||||
podName => $podName
|
||||
))
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- $._environment.reporter.report($this, '{0} containers on {1} restarted'.format($podName, $.instance.name))
|
||||
|
@ -0,0 +1,30 @@
|
||||
# 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: Restart Docker Containers
|
||||
|
||||
Parameters:
|
||||
podName: $podName
|
||||
|
||||
Body: |
|
||||
restartContainers(args.podName)
|
||||
|
||||
Scripts:
|
||||
restartContainers:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: restartContainers.sh
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# $1 - POD NAME AS A PART OF CONTAINER NAME
|
||||
|
||||
CONTAINERS=$(docker ps -q --filter "name=_$1-")
|
||||
if (( ${#CONTAINERS} > 0 )); then
|
||||
docker restart $CONTAINERS
|
||||
fi
|
@ -329,3 +329,21 @@ Methods:
|
||||
- $.kubernetesCluster.scaleRc(rcName => $._getReplicationControllerId(), newSize => $.replicas)
|
||||
Else:
|
||||
- $._environment.reporter.report($this, 'Cannot scale Pod up')
|
||||
|
||||
|
||||
recreatePod:
|
||||
Usage: Action
|
||||
Body:
|
||||
- $._environment.reporter.report($this, 'Recreating Pod {0}'.format($.name))
|
||||
- $.kubernetesCluster.deletePods(dict(id => $._getPodName()))
|
||||
- If: $.replicas = 0
|
||||
Then:
|
||||
- $._loadCurrentPodDefinition()
|
||||
- $.kubernetesCluster.createPod(definition => $._podDefinition, isNew => true)
|
||||
- $._environment.reporter.report($this, 'Pod {0} recreated'.format($.name))
|
||||
|
||||
|
||||
restartContainers:
|
||||
Usage: Action
|
||||
Body:
|
||||
- $.kubernetesCluster.restartContainers(podName => $._getPodName())
|
||||
|
Loading…
x
Reference in New Issue
Block a user