aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/orchestrator
diff options
context:
space:
mode:
authorJohn O Loughlin <john.oloughlin@intel.com>2018-05-15 16:20:33 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-10 10:29:48 +0100
commit028e92b1b2dcbaffd4a80061cc3d387877b59d62 (patch)
tree2c6e4c48c18829e7fa68cf4db31ccc6fb761dccc /yardstick/orchestrator
parent9e3cf5cb7b638c02419d34a3bbe890a6d82cd80c (diff)
Add "restartPolicy" parameter in Kubernetes policy
This new parameter, "restartPolicy", will allow define the restart policy per pod. Example of yaml definition in Kubernetes: apiVersion: v1 kind: Pod metadata: name: frontend spec: containers: - name: db ... restartPolicy: Always # Possible values: "Always", "OnFailure" and "Never" Example of definition in a Yardstick context: context: type: Kubernetes servers: host: containers: - name: ... restartPolicy: Always # Default value: "Always" Restart policy [1]. [1] https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy JIRA: YARDSTICK-1175 Change-Id: Id4317b909f98422e89d6d4553e8cfb0e1f593355 Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
Diffstat (limited to 'yardstick/orchestrator')
-rw-r--r--yardstick/orchestrator/kubernetes.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index 07a7ab1b6..2c401fc93 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -77,6 +77,7 @@ class ContainerObject(object):
class ReplicationControllerObject(object):
SSHKEY_DEFAULT = 'yardstick_key'
+ RESTART_POLICY = ('Always', 'OnFailure', 'Never')
def __init__(self, name, **kwargs):
super(ReplicationControllerObject, self).__init__()
@@ -87,6 +88,10 @@ class ReplicationControllerObject(object):
self._volumes = parameters.pop('volumes', [])
self._security_context = parameters.pop('securityContext', None)
self._networks = parameters.pop('networks', [])
+ self._restart_policy = parameters.pop('restartPolicy', 'Always')
+ if self._restart_policy not in self.RESTART_POLICY:
+ raise exceptions.KubernetesWrongRestartPolicy(
+ rpolicy=self._restart_policy)
containers = parameters.pop('containers', None)
if containers:
@@ -112,7 +117,8 @@ class ReplicationControllerObject(object):
"spec": {
"containers": [],
"volumes": [],
- "nodeSelector": {}
+ "nodeSelector": {},
+ "restartPolicy": self._restart_policy
}
}
}