From 05e95de3b9736160b4229232903e86706fb782e1 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Mon, 20 Apr 2020 13:25:47 -0400 Subject: Remove ContainerizedPlatformContainer from types Also allow environment variables to specified via docker_config Issue-ID: DCAEGEN2-1791 Issue-ID: DCAEGEN2-2215 Change-Id: If6b3b206856031d3c2aa3a5f787c1be30bdc4afd Signed-off-by: Jack Lucas --- k8s/ChangeLog.md | 4 ++ k8s/README.md | 10 ++-- k8s/k8s-node-type.yaml | 106 ++++++------------------------------------ k8s/k8sclient/k8sclient.py | 8 +--- k8s/k8splugin/__init__.py | 5 +- k8s/k8splugin/tasks.py | 113 ++------------------------------------------- k8s/msb/__init__.py | 19 -------- k8s/msb/msb.py | 64 ------------------------- k8s/pom.xml | 2 +- k8s/requirements.txt | 2 +- k8s/setup.py | 6 +-- k8s/tests/test_tasks.py | 8 ++-- k8s/tox.ini | 2 +- 13 files changed, 39 insertions(+), 310 deletions(-) delete mode 100644 k8s/msb/__init__.py delete mode 100644 k8s/msb/msb.py diff --git a/k8s/ChangeLog.md b/k8s/ChangeLog.md index f56bd96..81a4156 100644 --- a/k8s/ChangeLog.md +++ b/k8s/ChangeLog.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [3.0.0] +* DCAEGEN2-1791 - eliminate the ContainerizedPlatformComponent type +* DCAEGEN2-2215 - allow environment variables to be set via docker_config + ## [1.7.2] * DCAEGEN2-2006 Reduce code complexity The k8sclient.k8sclient.deploy function parameter 'resources' is now an optional diff --git a/k8s/README.md b/k8s/README.md index dfe9937..3fdbf1a 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -1,13 +1,13 @@ # ONAP DCAE Kubernetes Plugin for Cloudify -This directory contains a Cloudify plugin used to orchestrate the deployment of containerized DCAE platform and service components into a Kubernetes ("k8s") +This directory contains a Cloudify plugin used to orchestrate the deployment of containerized DCAE service components into a Kubernetes ("k8s") environment. This work is based on the [ONAP DCAE Docker plugin] (../docker). This plugin is *not* a generic Kubernetes plugin that exposes the full set of Kubernetes features. In fact, the plugin largely hides the fact that we're using Kubernetes from both component developers and blueprint authors. The Cloudify node type definitions are very similar to the Cloudify type definitions used in the ONAP DCAE Docker plugin. -For the node types `ContainerizedPlatformComponent`, `ContainerizedServiceComponent`, and `ContainerizedServiceComponentUsingDmaap`, this plugin +For the node types `ContainerizedServiceComponent` and `ContainerizedServiceComponentUsingDmaap`, this plugin creates the following Kubernetes entities: - A Kubernetes `Deployment` containing information about what containers to run and what volume to mount. @@ -108,12 +108,10 @@ mode | Readable, writeable: `ro`, `rw` #### `ports` -List of strings - Used to bind container ports to host ports. Each item is of the format: `:` or +List of strings - Used to bind container ports to host ports. Each item is of the format: `:` or /:, where can be "TCP", "tcp", "UDP", or "udp". If the first format is used, the protocol defaults to TCP. -Note that `ContainerizedPlatformComponent` has the property pair `host_port` and `container_port`. This pair will be merged with the input parameters ports. - ```yaml ports: - '8000:31000' @@ -251,7 +249,7 @@ To form the application configuration: This also applies to data router feeds. ## Additional Operations Supported by the Plugin -In addition to supporting the Cloudify `install` and `uninstall` workflows, the plugin provides two standalone operations that can be invoked using the Cloudify [`execute_operation` workflow](https://docs.cloudify.co/4.3.0/working_with/workflows/built-in-workflows/). The `dcae.nodes.ContainerizedApplication`, `dcae.nodes.ContainerizedPlatformComponent`, `dcae.nodes.ContainerizedServiceComponent`, and `dcae.nodes.ContainerizedServiceComponentUsingDmaap` node types support these operations. +In addition to supporting the Cloudify `install` and `uninstall` workflows, the plugin provides two standalone operations that can be invoked using the Cloudify [`execute_operation` workflow](https://docs.cloudify.co/4.3.0/working_with/workflows/built-in-workflows/). The `dcae.nodes.ContainerizedApplication`, `dcae.nodes.ContainerizedServiceComponent`, and `dcae.nodes.ContainerizedServiceComponentUsingDmaap` node types support these operations. Currently, there's no convenient high-level interface to trigger these operations, but they could potentially be exposed through some kind of dashboard. diff --git a/k8s/k8s-node-type.yaml b/k8s/k8s-node-type.yaml index c14623a..3220bba 100644 --- a/k8s/k8s-node-type.yaml +++ b/k8s/k8s-node-type.yaml @@ -23,35 +23,10 @@ plugins: k8s: executor: 'central_deployment_agent' package_name: k8splugin - package_version: 2.0.0 + package_version: 3.0.0 data_types: - dcae.types.MSBRegistration: - description: > - Information for registering an HTTP service into MSB. It's optional to do so, - but if MSB registration is desired at least the port property must be provided. - If 'port' property is not provided, the plugin will not do the registration. - (The properties all have to be declared as not required, otherwise the - 'msb_registration' property on the node would also be required.) - properties: - port: - description: The container port at which the service is exposed - type: string - required: false - version: - description: The version identifier for the service - type: string - required: false - url_path: - description: The URL path (e.g., "/api", not the full URL) to the service endpoint - type: string - required: false - uses_ssl: - description: Set to true if service endpoint uses SSL (TLS) - type: boolean - required: false - dcae.types.LoggingInfo: description: > Information for setting up centralized logging via ELK using a "sidecar" container. @@ -106,7 +81,7 @@ node_types: application_config: default: {} description: > - Application configuration for this Docker component. The data structure is + Application configuration for this component. The data structure is expected to be a complex map (native YAML) and to be constructed and filled by the creator of the blueprint. @@ -114,7 +89,7 @@ node_types: default: {} description: > Copied from the auxiliary portion of the component spec that contains things - like healthcheck definitions for the Docker component. Health checks are + like healthcheck definitions for the component. Health checks are optional. resource_config: @@ -147,7 +122,7 @@ node_types: description: > Set to true if the orchestrator should always pull a new copy of the image before deploying. By default the orchestrator pulls only if the image is - not already present on the Docker host where the container is being launched. + not already present on the host where the container is being launched. default: false location_id: @@ -167,17 +142,14 @@ node_types: update_image: implementation: k8s.k8splugin.update_image - # The ContainerizedServiceComponent node type is to be used for DCAE service components that - # are to be run in a Docker container. This node type goes beyond that of a ordinary Docker - # plugin where it has DCAE platform specific functionality: - # - # * Generation of the service component name - # * Managing of service component configuration information + # The ContainerizedServiceComponent node type is to be used for DCAE service components. # - # The plugin deploys the container into a Kubernetes cluster with a very specific choice + # The plugin deploys the component into a Kubernetes cluster with a very specific choice # of Kubernetes elements that are deliberately not under the control of the blueprint author. # The idea is to deploy all service components in a consistent way, with the details abstracted - # away from the blueprint author. + # away from the blueprint author. The plugin is responsible for: + # * Generation of the service component name + # * Managing of service component configuration information dcae.nodes.ContainerizedServiceComponent: derived_from: dcae.nodes.ContainerizedComponent properties: @@ -202,10 +174,12 @@ node_types: service_component_name_override: type: string description: > - Manually override and set the name for this Docker container node. If this + Manually override and set the name for this component. If this is set, then the name will not be auto-generated. Using this feature provides a service component with a fixed name that's known in advance, but care must be taken - to avoid attempting to deploy two components with the same name. + to avoid attempting to deploy two components with the same name. If the component + exposes any ports, the k8s Service created by the plugin will use service_component_name_override + as the DNS host name. default: Null interfaces: @@ -214,10 +188,10 @@ node_types: # Generate service component name and populate config into Consul implementation: k8s.k8splugin.create_for_components start: - # Create Docker container and start + # Create k8s entities for the component and start implementation: k8s.k8splugin.create_and_start_container_for_components stop: - # Stop and remove Docker container + # Stop and remove k8s entities associated with the component implementation: k8s.k8splugin.stop_and_remove_container delete: # Delete configuration from Consul @@ -282,56 +256,6 @@ node_types: # Generate service component name, populate config into Consul, set up runtime properties for DMaaP plugin implementation: k8s.k8splugin.create_for_components_with_streams - # ContainerizedPlatformComponent is intended for DCAE platform services. Unlike the components, - # platform services have well-known names and well-known ports. - dcae.nodes.ContainerizedPlatformComponent: - derived_from: dcae.nodes.ContainerizedComponent - properties: - name: - description: > - Container name used to register with Consul - dns_name: - required: false - description: > - Name to be registered in the DNS for the service provided by the container. - If not provided, the 'name' field is used. - This is a work-around for the Kubernetes restriction on having '_' in a DNS name. - Having this field allows a component to look up its configuration using a name that - includes a '_' while providing a legal Kubernetes DNS name. - - host_port: - type: integer - description: > - Network port that the platform service is expecting to expose on the host - default: 0 - - container_port: - type: integer - description: > - Network port that the platform service exposes in the container - default: 0 - - msb_registration: - type: dcae.types.MSBRegistration - description: > - Information for registering with MSB - required: false - - interfaces: - cloudify.interfaces.lifecycle: - create: - # Populate config into Consul - implementation: k8s.k8splugin.create_for_platforms - start: - # Create Docker container and start - implementation: k8s.k8splugin.create_and_start_container_for_platforms - stop: - # Stop and remove Docker container - implementation: k8s.k8splugin.stop_and_remove_container - delete: - # Delete configuration from Consul - implementation: k8s.k8splugin.cleanup_discovery - # ContainerizedApplication is intended to be more of an all-purpose Docker container node # for non-componentized applications. dcae.nodes.ContainerizedApplication: diff --git a/k8s/k8sclient/k8sclient.py b/k8s/k8sclient/k8sclient.py index bd83322..e73d96a 100644 --- a/k8s/k8sclient/k8sclient.py +++ b/k8s/k8sclient/k8sclient.py @@ -21,7 +21,6 @@ import os import re import uuid -from msb import msb from kubernetes import config, client, stream # Default values for readiness probe @@ -442,7 +441,6 @@ def deploy(namespace, component_name, image, replicas, always_pull, k8sconfig, * {"host":{"path": "/path/on/host"}, "container":{"bind":"/path/on/container","mode":"rw_or_ro"} - ports: array of strings in the form "container_port:host_port" - env: map of name-value pairs ( {name0: value0, name1: value1...} - - msb_list: array of msb objects, where an msb object is as described in msb/msb.py. - log_info: an object with info for setting up ELK logging, with the form: {"log_directory": "/path/to/container/log/directory", "alternate_fb_path" : "/alternate/sidecar/log/path"} - tls_info: an object with info for setting up TLS (HTTPS), with the form: @@ -521,12 +519,8 @@ def deploy(namespace, component_name, image, replicas, always_pull, k8sconfig, * if port_map: service_ports, exposed_ports = _process_port_map(port_map) - # If there are ports to be exposed via MSB, set up the annotation for the service - msb_list = kwargs.get("msb_list") - annotations = msb.create_msb_annotation(msb_list) if msb_list else '' - # Create a ClusterIP service for access via the k8s network - service = _create_service_object(_create_service_name(component_name), component_name, service_ports, annotations, labels, "ClusterIP") + service = _create_service_object(_create_service_name(component_name), component_name, service_ports, None, labels, "ClusterIP") core.create_namespaced_service(namespace, service) cip_service_created = True deployment_description["services"].append(_create_service_name(component_name)) diff --git a/k8s/k8splugin/__init__.py b/k8s/k8splugin/__init__.py index aa4ceda..7ca69b7 100644 --- a/k8s/k8splugin/__init__.py +++ b/k8s/k8splugin/__init__.py @@ -1,7 +1,7 @@ # ============LICENSE_START======================================================= # org.onap.dcae # ================================================================================ -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,5 @@ # __version__ = '0.1.0' from .tasks import create_for_components, create_for_components_with_streams, \ - create_for_platforms, create_and_start_container, \ - create_and_start_container_for_components, create_and_start_container_for_platforms, \ + create_and_start_container, create_and_start_container_for_components, \ stop_and_remove_container, cleanup_discovery, policy_update, scale, update_image \ No newline at end of file diff --git a/k8s/k8splugin/tasks.py b/k8s/k8splugin/tasks.py index 21f70c1..5a32602 100644 --- a/k8s/k8splugin/tasks.py +++ b/k8s/k8splugin/tasks.py @@ -197,20 +197,6 @@ def create_for_components_with_streams(**create_inputs): **_generate_component_name( **create_inputs))))) -@merge_inputs_for_create -@monkeypatch_loggers -@operation -def create_for_platforms(**create_inputs): - """Create step for platform components - - This interface is responible for: - - 1. Populating config information into Consul - """ - _done_for_create( - **_setup_for_discovery( - **create_inputs)) - def _verify_k8s_deployment(location, service_component_name, max_wait): """Verify that the k8s Deployment is ready @@ -256,7 +242,6 @@ def _create_and_start_container(container_name, image, **kwargs): - always_pull: boolean. If true, sets image pull policy to "Always" so that a fresh copy of the image is always pull. Otherwise, sets image pull policy to "IfNotPresent" - - msb_list: array of msb objects, where an msb object is as described in msb/msb.py. - log_info: an object with info for setting up ELK logging, with the form: {"log_directory": "/path/to/container/log/directory", "alternate_fb_path" : "/alternate/sidecar/log/path"}" - tls_info: an object with information for setting up the component to act as a TLS server, with the form: @@ -287,7 +272,6 @@ def _create_and_start_container(container_name, image, **kwargs): resources=resource_config, volumes=kwargs.get("volumes", []), ports=kwargs.get("ports", []), - msb_list=kwargs.get("msb_list"), tls_info=kwargs.get("tls_info"), env=env, labels=kwargs.get("labels", {}), @@ -352,13 +336,6 @@ def _enhance_docker_params(**kwargs): envs = kwargs.get("envs", {}) - # Set tags on this component for its Consul registration as a service - tags = [kwargs.get("deployment_id", None), kwargs["service_id"]] - tags = [ str(tag) for tag in tags if tag is not None ] - # Registrator will use this to register this component with tags. Must be - # comma delimited. - envs["SERVICE_TAGS"] = ",".join(tags) - kwargs["envs"] = envs def combine_params(key, docker_config, kwargs): @@ -371,6 +348,9 @@ def _enhance_docker_params(**kwargs): kwargs = combine_params("ports", docker_config, kwargs) kwargs = combine_params("volumes", docker_config, kwargs) + # Merge env vars from kwarg inputs and docker_config + kwargs["envs"].update(docker_config.get("envs", {})) + return kwargs @@ -424,17 +404,6 @@ def _done_for_start(**kwargs): ctx.logger.info("Done starting: {0}".format(kwargs["name"])) return kwargs -def _setup_msb_registration(service_name, msb_reg): - return { - "serviceName" : service_name, - "port" : msb_reg.get("port", "80"), - "version" : msb_reg.get("version", "v1"), - "url" : msb_reg.get("url_path", "/v1"), - "protocol" : "REST", - "enable_ssl" : msb_reg.get("uses_ssl", False), - "visualRange" : "1" -} - @wrap_error_handling_start @merge_inputs_for_start @monkeypatch_loggers @@ -451,82 +420,6 @@ def create_and_start_container_for_components(**start_inputs): **_create_and_start_component( **_parse_cloudify_context(**start_inputs)))) -@wrap_error_handling_start -@monkeypatch_loggers -@operation -def create_and_start_container_for_platforms(**kwargs): - """Initiate Kubernetes deployment for platform components - - This operation method is to be used with the ContainerizedPlatformComponent - node type. - """ - # Capture node properties - image = ctx.node.properties["image"] - docker_config = ctx.node.properties.get("docker_config", {}) - resource_config = ctx.node.properties.get("resource_config", {}) - kwargs["resource_config"] = resource_config - if "healthcheck" in docker_config: - kwargs["readiness"] = docker_config["healthcheck"] - if "livehealthcheck" in docker_config: - kwargs["liveness"] = docker_config["livehealthcheck"] - if "dns_name" in ctx.node.properties: - service_component_name = ctx.node.properties["dns_name"] - else: - service_component_name = ctx.node.properties["name"] - - # Set some labels for the Kubernetes pods - # The name segment is required and must be 63 characters or less - kwargs["labels"] = { - "cfydeployment" : ctx.deployment.id, - "cfynode": ctx.node.name[:63], - "cfynodeinstance": ctx.instance.id[:63] - } - - host_port = ctx.node.properties["host_port"] - container_port = ctx.node.properties["container_port"] - - # Cloudify properties are all required and Cloudify complains that None - # is not a valid type for integer. Defaulting to 0 to indicate to not - # use this and not to set a specific port mapping in cases like service - # change handler. - if container_port != 0: - # Doing this because other nodes might want to use this property - port_mapping = "{cp}:{hp}".format(cp=container_port, hp=host_port) - ports = kwargs.get("ports", []) + [ port_mapping ] - kwargs["ports"] = ports - if "ports" not in kwargs: - ctx.logger.warn("No port mappings defined. Will randomly assign port.") - - # All of the new node properties could be handled more DRYly! - # If a registration to MSB is required, then set up the registration info - if "msb_registration" in ctx.node.properties and "port" in ctx.node.properties["msb_registration"]: - kwargs["msb_list"] = [_setup_msb_registration(service_component_name, ctx.node.properties["msb_registration"])] - - # If centralized logging via ELK is desired, then set up the logging info - if "log_info" in ctx.node.properties and "log_directory" in ctx.node.properties["log_info"]: - kwargs["log_info"] = ctx.node.properties["log_info"] - - # Pick up TLS info if present - if "tls_info" in ctx.node.properties: - kwargs["tls_info"] = ctx.node.properties["tls_info"] - - # Pick up replica count and always_pull_image flag - if "replicas" in ctx.node.properties: - kwargs["replicas"] = ctx.node.properties["replicas"] - if "always_pull_image" in ctx.node.properties: - kwargs["always_pull_image"] = ctx.node.properties["always_pull_image"] - - # Pick up location - kwargs["k8s_location"] = _get_location() - - returned_args = _create_and_start_container(service_component_name, image, **kwargs) - - # Verify that the k8s deployment is ready - # - Set service component name into kwargs - # - max_wait is already in kwargs if it was set - returned_args[SERVICE_COMPONENT_NAME] = service_component_name - _verify_component(**returned_args) - @wrap_error_handling_start @monkeypatch_loggers @operation diff --git a/k8s/msb/__init__.py b/k8s/msb/__init__.py deleted file mode 100644 index 58d8f1c..0000000 --- a/k8s/msb/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. diff --git a/k8s/msb/msb.py b/k8s/msb/msb.py deleted file mode 100644 index 5883f29..0000000 --- a/k8s/msb/msb.py +++ /dev/null @@ -1,64 +0,0 @@ -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -# - -import uuid -import json - -MSB_ANNOTATION_KEY = 'msb.onap.org/service-info' - -def _sanitize_service_info(service_info): - ''' - Sanitize a dict containing the MSB annotation parameters for registering - a service with MSB. (Not bullet proof, but useful.) - MSB registration happens asynchronously from the installation flow: an MSB process - watches the k8s event stream for new Service creations and looks for the MSB annotation. - A bad annotation will fail silently. This sanitization process should make sure that something - gets put into the MSB's list of services, so that the problem can be seen. - - service_info is a dict containing the MSB annotation parameters. - -- serviceName: the name under which the service is to be registered (default: random--pretty useless!) - -- port: the container port on which the service can be contacted (default: "80"--nearly as useless) - -- version: the API version (default: "v1") - -- url: the path to the application's API endpoint (default: "/") - -- protocol: see the MSB documentation--the default is usually OK (default: "REST") - -- enable_ssl: a flag indicating if the service uses SSL (True) or not (False) (default: True) - -- visualRange: "1" means the service is exposed only in ONAP, "0" means externally (default: "1") - (Note this is a string value) - ''' - return { - 'serviceName': service_info.get('serviceName', str(uuid.uuid4())), - 'port': str(service_info.get('port', '80')), - 'version': service_info.get('version','v1'), - 'url': service_info.get('url','/'), - 'protocol': service_info.get('protocol','REST'), - 'enable_ssl': bool(service_info.get('enable_ssl', False)), - 'visualRange': str(service_info.get('visualRange', '1')) - } - -def create_msb_annotation(msb_service_list): - ''' - Creates an annotation that can be added to a k8s Service to trigger - registration with MSB. - msb_list is a list of dicts each containing MSB registration information for a - service. (One k8s Service can have multiple ports, each one of which can be - registered as an MSB service.) - ''' - return {MSB_ANNOTATION_KEY : json.dumps([_sanitize_service_info(service_info) for service_info in msb_service_list])} diff --git a/k8s/pom.xml b/k8s/pom.xml index 5193e71..9616361 100644 --- a/k8s/pom.xml +++ b/k8s/pom.xml @@ -27,7 +27,7 @@ limitations under the License. org.onap.dcaegen2.platform.plugins k8s k8s-plugin - 2.0.0-SNAPSHOT + 3.0.0-SNAPSHOT http://maven.apache.org UTF-8 diff --git a/k8s/requirements.txt b/k8s/requirements.txt index 6d72e4a..fc23d8e 100644 --- a/k8s/requirements.txt +++ b/k8s/requirements.txt @@ -1,6 +1,6 @@ setuptools<45.0.0 python-consul>=0.6.0 onap-dcae-dcaepolicy-lib>=2.4.1 -kubernetes>=9.0.0 +kubernetes==10.0.0 cloudify-common>=5.0.0; python_version<"3" cloudify-common @ git+https://github.com/cloudify-cosmo/cloudify-common@cy-1374-python3#egg=cloudify-common==5.0.0; python_version>="3" diff --git a/k8s/setup.py b/k8s/setup.py index 15a34ab..6c82295 100644 --- a/k8s/setup.py +++ b/k8s/setup.py @@ -22,14 +22,14 @@ from setuptools import setup setup( name='k8splugin', description='Cloudify plugin for containerized components deployed using Kubernetes', - version="2.0.0", + version="3.0.0", author='J. F. Lucas, Michael Hwang, Tommy Carpenter', - packages=['k8splugin','k8sclient','msb','configure'], + packages=['k8splugin','k8sclient','configure'], zip_safe=False, install_requires=[ 'python-consul>=0.6.0', 'onap-dcae-dcaepolicy-lib>=2.4.1', - 'kubernetes>=9.0.0', + 'kubernetes==10.0.0', 'cloudify-common>=5.0.0', ] ) diff --git a/k8s/tests/test_tasks.py b/k8s/tests/test_tasks.py index c6781bb..7f5d753 100644 --- a/k8s/tests/test_tasks.py +++ b/k8s/tests/test_tasks.py @@ -146,7 +146,7 @@ def test_enhance_docker_params(mockconfig): test_kwargs = { "docker_config": {}, "service_id": None } actual = tasks._enhance_docker_params(**test_kwargs) - assert actual == {'envs': {"SERVICE_TAGS": ""}, 'docker_config': {}, 'ports': [], 'volumes': [], "service_id": None } + assert actual == {'envs': {}, 'docker_config': {}, 'ports': [], 'volumes': [], "service_id": None } # Good - Test just docker config ports and volumes @@ -155,7 +155,7 @@ def test_enhance_docker_params(mockconfig): "service_id": None } actual = tasks._enhance_docker_params(**test_kwargs) - assert actual == {'envs': {"SERVICE_TAGS": ""}, 'docker_config': {'ports': ['1:1', '2:2'], + assert actual == {'envs': {}, 'docker_config': {'ports': ['1:1', '2:2'], 'volumes': [{'host': 'somewhere else', 'container': 'somewhere'}]}, 'ports': ['1:1', '2:2'], 'volumes': [{'host': 'somewhere else', 'container': 'somewhere'}], "service_id": None} @@ -169,7 +169,7 @@ def test_enhance_docker_params(mockconfig): "service_id": None } actual = tasks._enhance_docker_params(**test_kwargs) - assert actual == {'envs': {"SERVICE_TAGS": ""}, 'docker_config': {'ports': ['1:1', '2:2'], + assert actual == {'envs': {}, 'docker_config': {'ports': ['1:1', '2:2'], 'volumes': [{'host': 'somewhere else', 'container': 'somewhere'}]}, 'ports': ['1:1', '2:2', '3:3', '4:4'], 'volumes': [{'host': 'somewhere else', 'container': 'somewhere'}, {'host': 'nowhere else', 'container': @@ -181,7 +181,7 @@ def test_enhance_docker_params(mockconfig): "deployment_id": "abc" } actual = tasks._enhance_docker_params(**test_kwargs) - assert actual["envs"] == {"SERVICE_TAGS": "abc,zed"} + assert actual["envs"] == {} def test_notify_container(mockconfig): diff --git a/k8s/tox.ini b/k8s/tox.ini index 24fb8d5..5b750e3 100644 --- a/k8s/tox.ini +++ b/k8s/tox.ini @@ -13,7 +13,7 @@ deps= pytest-cov commands= coverage erase - pytest --junitxml xunit-results.{envname}.xml --cov configure --cov k8sclient --cov k8splugin --cov msb + pytest --junitxml xunit-results.{envname}.xml --cov configure --cov k8sclient --cov k8splugin [testenv:cov] skip_install = true -- cgit 1.2.3-korg