aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/orchestrator
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-18 12:02:58 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-19 08:07:29 +0000
commitc8facac8b67176e61ab2e00b312cc2deafe57b79 (patch)
tree89a1a89240475f35b70e699552a1b1b90008f8ae /yardstick/orchestrator
parent3eb7c80aa614456b05e08651a55f7450e6864c79 (diff)
Add "imagePullPolicy" parameter in Kubernetes container
The configuration parameter "imagePullPolicy" defines how Kubernetes retrieves de image. By default, Kubernetes will always try to pull the latest image from the repository [1]. Three possible arguments are accepted: - Always - IfNotPresent - Never Example of Kubernetes pod definition: containers: - name: vcmts-pktgen-pod-0 image: openretriever/yardstick imagePullPolicy: IfNotPresent Example of Yardstick definition: context: name: k8syardstick type: Kubernetesservers: vnf: image: openretriever/yardstick imagePullPolicy: IfNotPresent [1] https://kubernetes.io/docs/concepts/containers/images/ JIRA: YARDSTICK-1328 Change-Id: I83bfb01670eef22218b1affd7d37af14e32a622e Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/orchestrator')
-rw-r--r--yardstick/orchestrator/kubernetes.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index 98832908c..ec3588371 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -24,6 +24,7 @@ class ContainerObject(object):
COMMAND_DEFAULT = '/bin/bash'
RESOURCES = ('requests', 'limits')
PORT_OPTIONS = ('containerPort', 'hostIP', 'hostPort', 'name', 'protocol')
+ IMAGE_PULL_POLICY = ('Always', 'IfNotPresent', 'Never')
def __init__(self, name, ssh_key, **kwargs):
self._name = name
@@ -36,6 +37,7 @@ class ContainerObject(object):
self._env = kwargs.get('env', [])
self._resources = kwargs.get('resources', {})
self._ports = kwargs.get('ports', [])
+ self._image_pull_policy = kwargs.get('imagePullPolicy')
def _create_volume_mounts(self):
"""Return all "volumeMounts" items per container"""
@@ -82,6 +84,10 @@ class ContainerObject(object):
for res in (res for res in self._resources if
res in self.RESOURCES):
container['resources'][res] = self._resources[res]
+ if self._image_pull_policy:
+ if self._image_pull_policy not in self.IMAGE_PULL_POLICY:
+ raise exceptions.KubernetesContainerWrongImagePullPolicy()
+ container['imagePullPolicy'] = self._image_pull_policy
return container