aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/orchestrator/kubernetes.py
AgeCommit message (Collapse)AuthorFilesLines
2018-07-31Merge "Check for network already created k8"Emma Foley1-1/+1
2018-07-24kubernetes_utils: avoid 404 error code in delete_network()Mytnyk, Volodymyr1-1/+1
JIRA: YARDSTICK-1316 Change-Id: I792c873b42aba80be62ff7a93f6d02ea89e42356 Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-07-23Merge "kubernetes_utils: avoid 404 error code in ↵Rodolfo Alonso Hernandez1-1/+1
delete_custom_resource_definition()"
2018-07-23Merge "kubernetes_utils: avoid 404 error code in delete_service()"Rodolfo Alonso Hernandez1-1/+1
2018-07-20kubernetes_utils: avoid 404 error code in delete_custom_resource_definition()Mytnyk, Volodymyr1-1/+1
JIRA: YARDSTICK-1317 Change-Id: I2dc924334199761d63dce9aebe9ce200ca0fddf8 Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-07-20Check for network already created k8John O Loughlin1-1/+1
When creating a network the host should be checked to see if the network is already created. If the required network is already there it should be used. JIRA: YARDSTICK-1315 Change-Id: I09b114a728364ee56397af70cc48f1b7904f06cc Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
2018-07-19Add "stdin" and "tty" parameters to Kubernetes containerRodolfo Alonso Hernandez1-0/+6
JIRA: YARDSTICK-1330 Change-Id: I05303a1d0783421472883806f97441dd63f7f740 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-19kubernetes_utils: avoid 404 error code in delete_service()Mytnyk, Volodymyr1-1/+1
JIRA: YARDSTICK-1321 Change-Id: Id0f3a5d93f11674fd3908a7f5cf7214afcfa3600 Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-07-19Accept strings and lists as container "args" and "commands"Rodolfo Alonso Hernandez1-3/+13
Accept strings and list of strings as "args" and "commands" in a Kubernetes container. JIRA: YARDSTICK-1329 Change-Id: I56470741072fb7f9a62d695c51fcb0cc3f3ff1b9 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-19Merge "Add "imagePullPolicy" parameter in Kubernetes container"Rodolfo Alonso Hernandez1-0/+6
2018-07-19Add "imagePullPolicy" parameter in Kubernetes containerRodolfo Alonso Hernandez1-0/+6
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>
2018-07-19Kubernetes NodePort must have 'name' if multiple createdRodolfo Alonso Hernandez1-6/+18
In Kubernetes context, service NodePort can contain more than one port defined. Actually, by default port SSH (22) is always created. If more than one port is defined in the service template, 'name' parameter is mandatory. Names must be lowercase, containing alphanumeric characters or '-'. Verification regex used by Kubernetes: [a-z0-9]([-a-z0-9]*[a-z0-9])? JIRA: YARDSTICK-1324 Change-Id: I82791761d8eae24196c2f16aee9900af28d44c57 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-13Add interface and network information to Kubernetes contextRodolfo Alonso Hernandez1-1/+10
Add to "Kubernetes" context the "interfaces" information when retrieving a server. This information is needed for NSPerf test cases. The interface information comes from the resource controller network list. Each replication controller will have one port per network defined. JIRA: YARDSTICK-1303 Change-Id: Ifb0e17df295c042a643128c705a93876af999bad Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-10Merge "Add network elements as a dict in Kubernetes context"Rodolfo Alonso Hernandez1-5/+6
2018-07-10Add "tolerations" parameter in Kubernetes contextRodolfo Alonso Hernandez1-1/+17
This new parameter, "torelations", is applied to pods and allow (but not require) the pods to schedule onto node with matching tains [1]. Example of "tolerations" definition in a Kubernetes pod: spec: containers: [...] tolerations: - key: <key defined in the taint> value: <key value to match with the taint> effect: <effect in case of match> operator: <matching operator> - key: ... Example of "tolerations" definition in a Yardstick test case: context: type: Kubernetes servers: host: containers: [...] tolerations: - key: ... value: ... effect: ... operator: ... NOTE: if any toleration is defined, a default one will be applied in order to allow any replication controller to create the pods in any Kubernetes node. This default toleration is defined as: spec: tolerations: - operator: "Exists" [1] https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ JIRA: YARDSTICK-1254 Change-Id: I32fb9c7086b4218c323218738057f634eb6ffff4 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-10Add "ports" parameters in Kubernetes contextJohn O'Loughlin1-1/+12
This new parameter, "ports", will allow the user to automatically to add port variables in a pod definition: context: type: Kubernetes servers: host: image: ... commands: ... ports: - containerPort: <port value> # Mandatory hostIP: <host IP> # Optional hostPort: <host port> # Optional name: <port name> # Optional protocol: <protocol name> # Optional The port type and the definition must be one of the supported ones in Kubernetes [1]. Container port definition, V1 API, Kubernetes Python library v6.0.0 [2] [1] https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/ [2] https://github.com/kubernetes-client/python/blob/6.0.0/kubernetes/client/models/v1_container_port.py JIRA: YARDSTICK-1183 Change-Id: I3673dbeec8d380cb2f8b1dacf6c25c7cdbc37e28 Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
2018-07-10Add "restartPolicy" parameter in Kubernetes policyJohn O Loughlin1-1/+7
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>
2018-07-06Add network elements as a dict in Kubernetes contextRodolfo Alonso Hernandez1-5/+6
Like in Heat context, network elements should be defined in a dictionary, using the network name as the entry key. Previous implementation: context: networks: - name: ... plugin: ... args: ... New implementation: context: networks: net_name_1: plugin: ... args: ... net_name_2: ... JIRA: YARDSTICK-1160 Change-Id: I786b06555af509440604305e2c3c2c9fe521bef8 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-06Add "resources" parameter in Kubernetes contextJohn O Loughlin1-0/+7
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>
2018-07-06Add "env" parameter in Kubernetes contextJohn O Loughlin1-0/+6
This new parameter, "env", will allow the user to automatically to add environment variables in a pod definition Example of definition in a context: context: type: Kubernetes servers: host: image: ... commands: ... env: - <variable name>: <variable value> - <variable name>: <variable value> The volume type and the definition must be one of the supported ones in Kubernetes [1]. [1] https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes JIRA: YARDSTICK-1161 Change-Id: Icf372a98c090063f10c9217755519ab92ba9b0ba Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
2018-06-14Create user defined "NodePort" services per podRodolfo Alonso Hernandez1-20/+37
This feature will give the user the ability to create user defined "NodePort" services per pod, a part from the default SSH port created, by default, for each pod created. Example of Kubernetes yaml definition: apiVersion: v1 kind: Servicemeta data: name: pod-1-service-nodeport spec: type: NodePort ports: - name: web port: 80 targetPort: 8888 nodePort: 33333 clusterIP: 10.254.0.8 selector: app: pod-1 Example of Yardstick test case definition: context: type: Kubernetes servers: host: containers: - image: ... securityContext: allowPrivilegeEscalation: false - image: ... node_ports: - port: <port number> # Mandatory name: <port name> # Optional targetPort: <port name> # Optional, default: targetPort=port nodePort: <port number> # Optional, assigned by Kubernetes Kubernetes service, type "NodePort" [1] [1] https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport JIRA: YARDSTICK-1181 Change-Id: Ia7730e4569d5526d573402a98c27d55c5c82cdef Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Change "KubernetesObject" class name to "ReplicationController"Rodolfo Alonso Hernandez1-6/+5
The class name "KubernetesObject" is not accurate. This class holds the definition of a Kubernetes replication controller. The suggested name is therefore "ReplicationControllerObject". JIRA: YARDSTICK-1180 Change-Id: I9ee9228f9528cb779e54a9bc178760b6e24c85c2 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Specify the networks to be used per podRodolfo Alonso Hernandez1-1/+18
If CRD "Network" is defined and network items are created, each pod (server) can have access to one or several networks. This is defined in the metadata section, as "annotations.networks" [1]. Example of Kubernetes pod definition with networks: apiVersion: v1 kind: Pod metadata: name: test-pod annotations: networks: '[{"name": "flannel"}]' Example of Yardstick server definition with networks: context: type: Kubernetes servers: host: containers: - name: ... networks: - flannel # These names must be defined in # context.networks ... networks: - name: flannel plugin: flannel Kubernetes annotations [2]. [1]https://github.com/intel/multus-cni/tree/b9446232cdf4f1b6f2bea583291973cc97e963f4#configuring-multus-to-use-kubeconfig-and-a-default-network [2]https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ JIRA: YARDSTICK-1178 Change-Id: I6e7b4bacf10810833ec733c14d44e5db613675e3 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add new Kubernetes resource kind: "Network"Rodolfo Alonso Hernandez1-4/+95
Add a new Kubernetes resource kind: "Network" [1] [2] Kubernetes network plugins (alpha definition): [3] Network definition example in Kubernetes: apiVersion: "kubernetes.com/v1" kind: Network metadata: name: flannel plugin: flannel args: '[ {delegate": {"isDefaultGateway": true}} ]' Proposed Kubernetes context network definition: context: networks: - name: flannel plugin: flannel args: (string) - name: sriov_upload plugin: sriov args: (string) [1]https://builders.intel.com/docs/networkbuilders/multiple-network-interfaces-in-kubernetes-application-note.pdf [2]http://cdn.opensourcecloud.cn/zt/k8s/01.pdf [3]https://kubernetes.io/docs/concepts/cluster-administration/network-plugins/ JIRA: YARDSTICK-1160 Change-Id: I71a49ac14e3d28ded91d2ed3cd9cc527e40303f7 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add new Kubernetes resource kind: "CustomResourceDefinition"Rodolfo Alonso Hernandez1-0/+45
Custom resource definition example in Kubernetes: apiVersion: "apiextensions.k8s.io/v1beta" kind: CustomResourceDefinition metadata: name: networks.kubernetes.com spec: group: kubernetes.com version: v1 scope: Namespaced names: plural: networks singular: network kind: Network Proposed Kubernetes context network definition: context: custom_resources:     - name: network        # name of the resource (singular)       version: v1          # optional, "v1" by default       scope: Namespaced    # optional, "Namespaced" by default From this definition, we will extract the Kubernetes parameters: - metadata.name: custom_resources.name + "s" + context_name + ".com" - spec.group: context_name + ".com" - spec.scope: custom_resources.scope - spec.version: custom_resources.version - spec.names.plural: custom_resources.name + "s" - spec.names.singular: custom_resources.name - spec.names.kind: custom_resources.name with first capital letter [1] https://kubernetes.io/docs/concepts/api-extension/custom-resources/ JIRA: YARDSTICK-1163 Change-Id: If8980dc3f6ddf9c6949bf15be8011aa98482ddc9 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add "securityContext" parameter in Kubernetes contextRodolfo Alonso Hernandez1-5/+17
This new parameter, "securityContext", will allow the user to define the privilege and access control settings for a pod or a container [1]. Example of "securityContext" definition in the pod (if only one container is defined): context:   type: Kubernetes   servers:     host:       image: ...       securityContext:         runAsUser: 1000         fsGroup: 2000  Example of "securityContext" definition in the pod and the container (if several containers are defined):      context:   type: Kubernetes   servers:     host:       securityContext:         runAsUser: 1000         fsGroup: 2000        containers:         - image: ...           securityContext:             allowPrivilegeEscalation: false         - image: ... [1] https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ JIRA: YARDSTICK-1156 Change-Id: I597a300c68cd834522a284b1cca0faa918493342 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Define several containers per pod in a replication controllerRodolfo Alonso Hernandez1-34/+53
Add the ability to define not only one but many containers per pod in a replication controller descriptor. This feature must be backwards compatible; all current test cases using the "single container" server definition must be accepted. Example of single container pod definition: context: type: Kubernetes servers: host: image: ... commands: ... volumes: - name: volume1 # mandatory <volume type definition> # mandatory Example of several container pod definition: context: type: Kubernetes servers: host: containers: # if this key is present, all container specific parameters (image, commands, args, volumeMounts, etc.) must be defined per container - image: ... commands: ... - image: ... commands: ... volumes: - name: volume1 # mandatory <volume type definition> # mandatory NOTE: other parameters, like "volumes" or "nodeSelector", are common to all containers in the pod. JIRA: YARDSTICK-1155 Change-Id: Ib95668c68e9c09e6de3f1aa41c903cc52e6809ad Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add "volumeMounts" parameter in Kubernetes contextRodolfo Alonso Hernandez1-23/+35
This new parameter, "volumeMounts", will allow the user to automatically create new volumes mounted inside the container. Example of Kubernetes context definition: context: type: Kubernetes servers: host: volumeMounts: - name: volume1 # mandatory mountPath: /dev/hugepages # mandatory readOnly: True # optional, default=False JIRA: YARDSTICK-1151 Change-Id: Ic00b45e6d603a9f85e3f0e25becdf0bce14e637c Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add "volumes" parameter in Kubernetes contextRodolfo Alonso Hernandez1-19/+35
This new parameter, "volumes", will allow the user to automatically create new volumes. Example of Kubernetes context definition: context: type: Kubernetes servers: host: image: ... commands: ... volumes: - name: volume1 # mandatory <volume type definition> # mandatory The volume type and the definition must be one of the supported ones in Kubernetes [1]. [1] https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes JIRA: YARDSTICK-1152 Change-Id: I44a91c605f047de4f286407e28fb5aa2e921b00a Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-05-09Avoid "volumeMounts" with "configMap" fixed permissionsRodolfo Alonso Hernandez1-1/+1
To access to the container without using a password, the jumphost RSA public key is copied to each container, using "volumeMounts" defined as "configMap", to /root/.ssh/authorized_keys. To work properly, the following permissions must be set: - /root/.ssh: 700 - /root/.ssh/authorized_keys: 600 Because of [1][2], the mounted folders have fixed permissions and cannot be modified. [1]https://groups.google.com/forum/#!topic/kubernetes-dev/eTnfMJSqmaM [2]https://github.com/kubernetes/kubernetes/issues/28317 JIRA: YARDSTICK-1149 Change-Id: I821064da56699c5b4f509d233c33e55af119fd56 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2017-09-26Merge "Add nodeSelector to enable selecting the desired Kubernetes running ↵Rex Lee1-1/+9
node when creating containers for Kubernetes context"
2017-09-21Add service in kubernetes contextchenjiankun1-1/+32
JIRA: YARDSTICK-803 Currently kubernetes test case can only run in master node. We need to support it run in jump server. So I add service and use nodePort type. Then we can login the pod using nodePort. Change-Id: Ia7900d263f1c5323f132435addec27ad10547ef9 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-09-21Add nodeSelector to enable selecting the desiredTrevor Tao1-1/+9
Kubernetes running node when creating containers for Kubernetes context For example, a yaml file may looks like: servers: host: image: xxx command: /bin/bash nodeSelector: xxx: yyy Synchronously change the unit test for this function Change-Id: If74c9dad9b1a70395bb79f34708a0fde04e7e650 Signed-off-by: Trevor Tao <trevor.tao@arm.com>
2017-07-17Kubernetes (k8s) supportchenjiankun1-0/+130
JIRA: YARDSTICK-682 We decide to support k8s in E release. We need to discuss with openretriver team and then rewrite the ping test case under k8s as the first step. Change-Id: I3f81ebca8de5c1f3a8b7d42581cd7342dc320239 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>