diff options
author | John O Loughlin <john.oloughlin@intel.com> | 2018-05-15 11:43:05 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-06 09:02:37 +0000 |
commit | b5cafe95acef8a14def98192b6de96b92b574cef (patch) | |
tree | 8f6e7a415824cab93be2b239e8683715758bfe39 /yardstick/orchestrator/kubernetes.py | |
parent | ab8629071966fb46a4eeac473cda3352424fa350 (diff) |
Add "resources" parameter in Kubernetes context
This new parameter, "resources", will allow the user to automatically
add resources in a pod definition per container.
Example of yaml definition in Kubernetes:
apiVersion: v1
kind: Pod
metadata:
name: frontend
spec:
containers:
- name: db
image: mysql
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
Example of definition in a Yardstick context:
context:
type: Kubernetes
servers:
host:
resources: # There are two possible keys in this dict:
# "requests" and "limits".
limits: <dictionary>
requests: <dictionary>
Resources in containers [1].
[1] https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
JIRA:YARDSTICK-1171
Change-Id: I163d72d9d3e88b538fca73eb4dbf38613aa23ff4
Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
Diffstat (limited to 'yardstick/orchestrator/kubernetes.py')
-rw-r--r-- | yardstick/orchestrator/kubernetes.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py index f690ab3e9..07a7ab1b6 100644 --- a/yardstick/orchestrator/kubernetes.py +++ b/yardstick/orchestrator/kubernetes.py @@ -22,6 +22,7 @@ class ContainerObject(object): SSH_MOUNT_PATH = '/tmp/.ssh/' IMAGE_DEFAULT = 'openretriever/yardstick' COMMAND_DEFAULT = '/bin/bash' + RESOURCES = ['requests', 'limits'] def __init__(self, name, ssh_key, **kwargs): self._name = name @@ -32,6 +33,7 @@ class ContainerObject(object): self._volume_mounts = kwargs.get('volumeMounts', []) self._security_context = kwargs.get('securityContext') self._env = kwargs.get('env', []) + self._resources = kwargs.get('resources', {}) def _create_volume_mounts(self): """Return all "volumeMounts" items per container""" @@ -64,6 +66,11 @@ class ContainerObject(object): for env in self._env: container['env'].append({'name': env['name'], 'value': env['value']}) + if self._resources: + container['resources'] = {} + for res in (res for res in self._resources if + res in self.RESOURCES): + container['resources'][res] = self._resources[res] return container |