aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/orchestrator/kubernetes.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/orchestrator/kubernetes.py')
-rw-r--r--yardstick/orchestrator/kubernetes.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index bee4d4a78..3e2572fcc 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -11,6 +11,7 @@ import copy
import re
from oslo_serialization import jsonutils
+import six
from yardstick.common import constants
from yardstick.common import exceptions
@@ -22,7 +23,7 @@ class ContainerObject(object):
SSH_MOUNT_PATH = '/tmp/.ssh/'
IMAGE_DEFAULT = 'openretriever/yardstick'
- COMMAND_DEFAULT = '/bin/bash'
+ COMMAND_DEFAULT = ['/bin/bash', '-c']
RESOURCES = ('requests', 'limits')
PORT_OPTIONS = ('containerPort', 'hostIP', 'hostPort', 'name', 'protocol')
IMAGE_PULL_POLICY = ('Always', 'IfNotPresent', 'Never')
@@ -31,8 +32,9 @@ class ContainerObject(object):
self._name = name
self._ssh_key = ssh_key
self._image = kwargs.get('image', self.IMAGE_DEFAULT)
- self._command = [kwargs.get('command', self.COMMAND_DEFAULT)]
- self._args = kwargs.get('args', [])
+ self._command = self._parse_commands(
+ kwargs.get('command', self.COMMAND_DEFAULT))
+ self._args = self._parse_commands(kwargs.get('args', []))
self._volume_mounts = kwargs.get('volumeMounts', [])
self._security_context = kwargs.get('securityContext')
self._env = kwargs.get('env', [])
@@ -40,6 +42,14 @@ class ContainerObject(object):
self._ports = kwargs.get('ports', [])
self._image_pull_policy = kwargs.get('imagePullPolicy')
+ @staticmethod
+ def _parse_commands(command):
+ if isinstance(command, six.string_types):
+ return [command]
+ elif isinstance(command, list):
+ return command
+ raise exceptions.KubernetesContainerCommandType()
+
def _create_volume_mounts(self):
"""Return all "volumeMounts" items per container"""
volume_mounts_items = [self._create_volume_mounts_item(vol)