diff options
author | Marek Wolczanski <marek.wolczanski@cloudify.co> | 2017-10-03 14:55:19 +0200 |
---|---|---|
committer | Marek Wolczanski <marek.wolczanski@cloudify.co> | 2017-10-03 15:27:26 +0200 |
commit | 63f2cc936ed6e6790f287195694f6d067decdd89 (patch) | |
tree | e79b62b7fc3e099708b6707454b4c52ee3e581da /cloudify-onap | |
parent | b9644b17f8545dedd3ede40f778b33f9b4ecf480 (diff) |
Cloudify support for OOM
Issue-ID: OOM-106
Change-Id: Ie0a37ef378fd1907825da181c81502c6fbe9134c
Signed-off-by: Marek Wolczanski <marek.wolczanski@cloudify.co>
Diffstat (limited to 'cloudify-onap')
18 files changed, 1126 insertions, 0 deletions
diff --git a/cloudify-onap/blueprint.yaml b/cloudify-onap/blueprint.yaml new file mode 100644 index 0000000000..96d297dbd3 --- /dev/null +++ b/cloudify-onap/blueprint.yaml @@ -0,0 +1,188 @@ +tosca_definitions_version: cloudify_dsl_1_3 + +description: > + Blueprint deploys all ONAP kubernetes resources defined in YAML files on existing kubernetes cluster + The following pre-setup steps are assumed, but not required: + - Create Cloudify Example Environment: https://github.com/cloudify-examples/cloudify-environment-setup. + - Create Kubernetes Cluster: https://github.com/cloudify-examples/simple-kubernetes-blueprint. + +imports: + - https://raw.githubusercontent.com/cloudify-cosmo/cloudify-manager/4.1/resources/rest-service/cloudify/types/types.yaml + # Plugin required: https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/1.2.1rc1/cloudify_kubernetes_plugin-1.2.1rc1-py27-none-linux_x86_64-centos-Core.wgn + - https://raw.githubusercontent.com/cloudify-incubator/cloudify-kubernetes-plugin/1.2.1/plugin.yaml +# - https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/archive/1.2.1.zip + - plugins/onap-installation-plugin/plugin.yaml + +inputs: + kubernetes_configuration_file_content: + description: > + File content of kubernetes master YAML configuration + default: + apiVersion: v1 + clusters: + - cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS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LM0tuK3BHUVBZd2x1UEFoSEZQZUdlZ1gvTnBlNXJjMVZGRUtLUkRQRVFRS0xrcE5TZ2IKNzgwZ2ZMTkxJUTJsQnczZHRjazcyelkyK0dlWlp3MEM2ckk5QUhBekg3ZXpZY0pvT2VmVjArZE9zV2lJNVB4UgowZnNYSlNEOVR4SDVVMlRSQ25KZ214M1ZLTGl5OTZyOGsrOTdkWlAvN3h2Q3dGSU9wc2I2UGcxdjNxZz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= + server: https://192.168.120.5:6443 + name: kubernetes + contexts: + - context: + cluster: kubernetes + user: kubernetes-admin + name: kubernetes-admin@kubernetes + current-context: kubernetes-admin@kubernetes + kind: Config + preferences: {} + users: + - name: kubernetes-admin + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJRUFMaVFKV0d2ZmN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpFd01ESXhNekV6TWpkYUZ3MHhPREV3TURJeE16RXpNamxhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXVOWFFJSlNzSmdtWndXMTEKcEtRZTV5TkQ1THBUdDY5dENKeEpoWXZPbElUOTRwVmdtVnBLNjhlMUNhQ2YxYkt0N2hCMUFOSVJHam8xMTYxNgpGUVRkaE5ZN0tnZFFUNGsrMC9mV0hBZzdCYnhKSDFCdEVvOGorTFk0dDRMNUVCS1l2dTN4Z21NS2E3SGMxZiszCkRQdWtndDZUZm1JazZEM0JkTHQyays2ZDhMclAzYmtkVmQwS1o2OWtnRnBuSWxtNkdrQWhrZWRleE5PQ21vRE8KU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TJibk8wbnA1aldhbVprdGR1blRNMGg2dmdLQTF5UnNnejFjNApncmtZUkp5V1JhRElYb0YzOVdvMWJrbHZvaWN5NURqWUtBK0hKWUVUT0pmOC9odzJ1WngzTk54bm5UZXpJSVA5CnVDZHlJSDhRNFU1VkloeWVXTDV5WlR6WGs3YlhyRVllZjB3cW81UUhBb0dBZlhiZkFXZ01UdE5QRXl2NHBnWWwKK09qM25vSmlRZ1ZZSVo0dEg5UW1uVkI3YVA4OXAzaWpxYldSZVpxL3paQUR4aS9ZREc3TG9zT3gxYWJWOTc5WApyZlU0ZXo4NFV3alRKaEx4alVSMHpycWlYajdOYlhSZk1ud2tjb1IrM2RIamUvNytwZUdlMWJKays2YlZxTHhFCnllR2hoUzdxWUJOTnpxZnp1S0Nic0trQ2dZRUF6N2g4ZXNEekVJOFpYekJrakZJK2c4ZWJOSVdkZzFtSlVRT3oKSmxaN1czK1FUaDNZWHZEaXVUaFZieWwvU0pVSndvRmoxd2cveE1jTHgrY3ZzMGNUV3hpY1RmNEwwYmdSUTRFegpzRzh0ZGdjeldwYjFiS3NGc2ZLMm5Vc0pVV016dWoySDVGblJLUjh3UmNaR3VOQjU2VHNGSTBza1FLNlpVa3lVCnJmclhOSVVDZ1lFQW83NGp6NnBJbDgwOU51dERZeHVON3J4RzYrTVMwRkVRa2tTSGdtZTlvN0Y0QjNWRHJ6WE4Ka1g3dC95cm1ieHBjK0R2VmUzWm1hWHE1QXJzdjRVbW5Za1ArNCs0L2REcWdmbjd3ZmVKUkpzU1Uzd2V0YWJnRwpDQW5xMFpLR3RJWWhud1h5cWF6elBsUUFteFIxWUdDczIxL05kUVJvWDdsOFdyaUJmbkpVM3hZPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= + + namespace_prefix: + type: string + description: > + Kubernetes namespace name prefix which will be uese for all ONAP apps + default: onap + +dsl_definitions: + options: &app_options + namespace: + concat: [{ get_input: namespace_prefix }, '-', { get_property: [SELF, name] }] + +node_templates: + kubernetes_master: + type: cloudify.kubernetes.nodes.Master + properties: + configuration: + file_content: { get_input: kubernetes_configuration_file_content } + + onap_environment: + type: cloudify.onap.kubernetes.Environment + properties: + namespace: { get_input: namespace_prefix } + init_pod: kubernetes/config + options: + namespace: { get_input: namespace_prefix } + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + +# mso_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: mso +# path: kubernetes/mso +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# + message_router_app: + type: cloudify.onap.kubernetes.App + properties: + name: message-router + path: kubernetes/message-router + options: *app_options + relationships: + - type: cloudify.kubernetes.relationships.managed_by_master + target: kubernetes_master + - type: cloudify.relationships.depends_on + target: onap_environment +# +# sdc_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: sdc +# path: kubernetes/sdc +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# aai_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: aai +# path: kubernetes/aai +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# robot_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: robot +# path: kubernetes/robot +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# vid_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: vid +# path: kubernetes/vid +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# sdnc_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: sdnc +# path: kubernetes/sdnc +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# portal_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: portal +# path: kubernetes/portal +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# policy_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: policy +# path: kubernetes/policy +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment +# +# appc_app: +# type: cloudify.onap.kubernetes.App +# properties: +# name: appc +# path: kubernetes/appc +# options: *app_options +# relationships: +# - type: cloudify.kubernetes.relationships.managed_by_master +# target: kubernetes_master +# - type: cloudify.relationships.depends_on +# target: onap_environment diff --git a/cloudify-onap/docker-custom-readiness/Dockerfile b/cloudify-onap/docker-custom-readiness/Dockerfile new file mode 100644 index 0000000000..d42456d336 --- /dev/null +++ b/cloudify-onap/docker-custom-readiness/Dockerfile @@ -0,0 +1,21 @@ +from ubuntu:16.04 + +ENV no_proxy "localhost,127.0.0.1,.cluster.local,$KUBERNETES_SERVICE_HOST" +# Setup Corporate proxy +ENV https_proxy ${HTTPS_PROXY} +ENV http_proxy ${HTTP_PROXY} + +# Additional packages +RUN apt-get update +RUN apt-get install -y apt-utils git wget curl dnsutils python python-pip jq net-tools coreutils vim + +RUN pip install requests pyyaml kubernetes==1.0.2 + + +ENV CERT="/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" +ENV TOKEN="/var/run/secrets/kubernetes.io/serviceaccount/token" + +COPY ready.py /root/ready.py +RUN chmod a+x /root/ready.py +#ENTRYPOINT /root/ready.py + diff --git a/cloudify-onap/docker-custom-readiness/ready.py b/cloudify-onap/docker-custom-readiness/ready.py new file mode 100644 index 0000000000..22b24d345d --- /dev/null +++ b/cloudify-onap/docker-custom-readiness/ready.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +#from kubernetes import client, config +import kubernetes +import time, argparse, logging, sys, os, base64 +import yaml + +#setup logging +log = logging.getLogger(__name__) +handler = logging.StreamHandler(sys.stdout) +handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) +handler.setLevel(logging.DEBUG) +log.addHandler(handler) +log.setLevel(logging.DEBUG) + + +def is_ready(container_name): + log.info( "Checking if " + container_name + " is ready") + + kubernetes.config.kube_config.KubeConfigLoader(config_dict=get_k8s_config_env()).load_and_set() + client = kubernetes.client + namespace = get_namespace_env() + v1 = client.CoreV1Api() + + ready = False + + try: + response = v1.list_namespaced_pod(namespace=namespace, watch=False) + for i in response.items: + for s in i.status.container_statuses: + if s.name == container_name: + log.debug ( "response %s" % response ) + ready = s.ready + if not ready: + log.info( container_name + " is not ready.") + else: + log.info( container_name + " is ready!") + else: + continue + return ready + except Exception as e: + log.error("Exception when calling list_namespaced_pod: %s\n" % e) + + +def get_k8s_config_env(): + try: + k8s_config_env = os.environ.get("K8S_CONFIG_B64") + decoded = base64.b64decode(k8s_config_env) + return yaml.load(decoded) + except KeyError as ke: + raise Exception("K8S_CONFIG_B64 variable is not set.") + + +def get_namespace_env(): + try: + namespace_env = os.environ.get("NAMESPACE") + return namespace_env + except KeyError as ke: + raise Exception("NAMESPACE variable is not set.") + + +def main(args):#from kubernetes import client, config + + # args are a list of container names + for container_name in args: + # 5 min, TODO: make configurable + timeout = time.time() + 60 * 10 + while True: + ready = is_ready(container_name) + if ready is True: + break + elif time.time() > timeout: + log.warning( "timed out waiting for '" + container_name + "' to be ready") + exit(1) + else: + time.sleep(5) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Process some names.') + parser.add_argument('--container-name', action='append', required=True, help='A container name') + args = parser.parse_args() + arg_dict = vars(args) + + for arg in arg_dict.itervalues(): + main(arg) diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/__init__.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/__init__.py new file mode 100644 index 0000000000..19a30ba43d --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/__init__.py @@ -0,0 +1,14 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/app.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/app.py new file mode 100644 index 0000000000..fc8af2eea4 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/app.py @@ -0,0 +1,47 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + + +from cloudify.decorators import operation + +from common import namespace +from common import resources_services +from common import workarounds + + +@operation +def configure_docker_secret(**kwargs): + workarounds.configure_secret() + + +@operation +def create_namespace(**kwargs): + namespace.do_create_namespace() + + +@operation +def create_resources_services(**kwargs): + resources_services.create_resoruces() + + +@operation +def delete_namespace(**kwargs): + namespace.do_delete_namespace() + + +@operation +def delete_resources_services(**kwargs): + resources_services.delete_resoruces() + diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/__init__.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/__init__.py new file mode 100644 index 0000000000..19a30ba43d --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/__init__.py @@ -0,0 +1,14 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/constants.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/constants.py new file mode 100644 index 0000000000..493a44f16f --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/constants.py @@ -0,0 +1,20 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +HELM_URL = 'https://kubernetes-helm.storage.googleapis.com/helm-canary-linux-amd64.tar.gz' +OOM_GIT_URL = 'https://gerrit.onap.org/r/oom.git' + +RT_HELM_CLI_PATH = "helm_cli_path" +RT_APPS_ROOT_PATH = "app_root_path" diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/deployment_result.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/deployment_result.py new file mode 100644 index 0000000000..48d49e0403 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/deployment_result.py @@ -0,0 +1,27 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +from cloudify import ctx + + +def save_deployment_result(key): + result = ctx.instance.runtime_properties['kubernetes'] + ctx.instance.runtime_properties[key] = result + ctx.instance.runtime_properties['kubernetes'] = {} + + +def set_deployment_result(key): + result = ctx.instance.runtime_properties.pop(key) + ctx.instance.runtime_properties['kubernetes'] = result
\ No newline at end of file diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/helm.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/helm.py new file mode 100644 index 0000000000..4404f6f832 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/helm.py @@ -0,0 +1,62 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +import urllib +import tarfile +import os +import tempfile +from git import Repo + +def get_helm_path(url): + tarball = _fetch_helm(url) + helm_dir = _get_tmp_file_name() + _untar_helm_archive(tarball, helm_dir) + helm_binary_path = _find_file('helm', helm_dir) + return helm_binary_path + + +def get_apps_root_path(git_url): + dst_repo_path = _get_tmp_file_name() + Repo.clone_from(git_url, dst_repo_path) + apps_root = format(dst_repo_path) + return apps_root + +def _fetch_helm(url): + dst_tar_path = _get_tmp_file_name() + + file = urllib.URLopener() + file.retrieve(url, dst_tar_path) + + return dst_tar_path + +def _untar_helm_archive(tar_path, helm_dir): + helm_tar = tarfile.open(tar_path) + helm_tar.extractall(helm_dir) + helm_tar.close() + + +def _find_file(filename, base_path): + for root, dirs, files in os.walk(base_path): + for name in files: + if name == filename: + return os.path.abspath(os.path.join(root, name)) + + raise Exception('Cannot find helm binary') + + +def _get_tmp_file_name(): + return '{}/{}'.format(tempfile._get_default_tempdir(), next(tempfile._get_candidate_names())) + + diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/init_pod.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/init_pod.py new file mode 100644 index 0000000000..1376818b7b --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/init_pod.py @@ -0,0 +1,63 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +from cloudify import ctx +import yaml + +import constants +import resources_services + +SERVICES_FILE_PARTS_SEPARATOR = '---' + + +def do_create_init_pod(): + ctx.logger.info('Creating init pod') + + yaml_config = resources_services.render_chart( + ctx.node.properties["init_pod"], + _retrieve_root_path(), + _retrieve_helm_cli_path() + ) + yaml_content_part = yaml_config.split(SERVICES_FILE_PARTS_SEPARATOR)[2] + enhanced_yaml = _add_openstack_envs(yaml_content_part) + + resources_services.create_resource(enhanced_yaml) + + ctx.logger.info('Init pod created successfully') + + +def do_delete_init_pod(): + ctx.logger.info('Deleting init pod') + + ctx.logger.info('Init pod deleted successfully') + +def _add_openstack_envs(yaml_content): + input_dict = yaml.load(yaml_content) + + container_dict = input_dict['spec']['containers'][0] + container_dict.pop('envFrom') + + openstack_envs = ctx.node.properties["openstack_envs"] + for item in openstack_envs.items(): + ctx.logger.debug("adding item = {}".format(item)) + container_dict['env'].append(item) + + return input_dict + +def _retrieve_root_path(): + return ctx.instance.runtime_properties.get(constants.RT_APPS_ROOT_PATH, None) + +def _retrieve_helm_cli_path(): + return ctx.instance.runtime_properties.get(constants.RT_HELM_CLI_PATH, None)
\ No newline at end of file diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/namespace.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/namespace.py new file mode 100644 index 0000000000..d1336768ac --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/namespace.py @@ -0,0 +1,101 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +import cloudify_kubernetes.tasks as kubernetes_plugin +from cloudify import ctx +from cloudify.exceptions import NonRecoverableError + +import deployment_result + + +def do_create_namespace(): + namespace = _retrieve_namespace() + ctx.logger.info('Creating namespace: {0}'.format(namespace)) + + namespace_resource_template = _prepare_namespace_resource_template( + namespace + ) + + ctx.logger.debug( + 'Kubernetes object which will be deployed: {0}' + .format(namespace_resource_template) + ) + + kubernetes_plugin.custom_resource_create(**namespace_resource_template) + deployment_result.save_deployment_result('namespace') + ctx.logger.info('Namespace created successfully') + + +def do_delete_namespace(): + namespace = _retrieve_namespace() + ctx.logger.info('Deleting namespace: {0}'.format(namespace)) + + namespace_resource_template = _prepare_namespace_resource_template( + namespace + ) + + ctx.logger.debug( + 'Kubernetes object which will be deleted: {0}' + .format(namespace_resource_template) + ) + + deployment_result.set_deployment_result('namespace') + kubernetes_plugin.custom_resource_delete(**namespace_resource_template) + ctx.logger.info('Namespace deleted successfully') + + + +def _retrieve_namespace(): + + default_namespace = ctx.node.properties.get('options', {}).get('namespace') + namespace = ctx.node.properties.get('namespace', default_namespace) + + if not namespace: + raise NonRecoverableError( + 'Namespace is not defined (node={})'.format(ctx.node.name) + ) + + return namespace + + +def _prepare_namespace_resource_template(name): + return { + 'definition': { + 'apiVersion': 'v1', + 'kind': 'Namespace', + 'metadata': { + 'name': name, + 'labels': { + 'name': name + }, + }, + }, + 'api_mapping': { + 'create': { + 'api': 'CoreV1Api', + 'method': 'create_namespace', + 'payload': 'V1Namespace' + }, + 'read': { + 'api': 'CoreV1Api', + 'method': 'read_namespace', + }, + 'delete': { + 'api': 'CoreV1Api', + 'method': 'delete_namespace', + 'payload': 'V1DeleteOptions' + } + } + } diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/resources_services.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/resources_services.py new file mode 100644 index 0000000000..268068f00c --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/resources_services.py @@ -0,0 +1,230 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +import subprocess + +import cloudify_kubernetes.tasks as kubernetes_plugin +import yaml +from cloudify import ctx +from cloudify.exceptions import NonRecoverableError + +import constants +import deployment_result +import time +import ast +import json +import base64 + +SERVICES_FILE_PARTS_SEPARATOR = '---' + + +def create_resoruces(): + ctx.logger.info('Creating resources') + apps_path = _retrieve_root_path() + + if not apps_path: + ctx.logger.warn( + 'Apps dir is not defined. Skipping!' + ) + + return + + helm_app = ctx.node.properties.get('path', None) + + yaml_file = prepare_content(helm_app) + + yaml_content_parts = yaml_file.split(SERVICES_FILE_PARTS_SEPARATOR) + + for yaml_content_part in yaml_content_parts: + if yaml_content_part: + yaml_content = _apply_readiness_workaround(yaml_content_part) + if yaml_content: + create_resource(yaml_content) + + ctx.logger.info('Resource created successfully') + +def delete_resoruces(): + + ctx.logger.info('Deleting resources') + apps_path = _retrieve_root_path() + + if not apps_path: + ctx.logger.warn( + 'Apps dir is not defined. Skipping!' + ) + return + + helm_app = ctx.node.properties.get('path', None) + + yaml_file = prepare_content(helm_app) + + yaml_content_parts = yaml_file.split(SERVICES_FILE_PARTS_SEPARATOR) + + for yaml_content_part in yaml_content_parts: + if yaml_content_part: + yaml_content = _apply_readiness_workaround(yaml_content_part) + if yaml_content: + delete_resource(yaml_content) + + ctx.logger.info('Resources deleted successfully') + + +def prepare_content(resource): + helm_path = _retrieve_helm_cli_path() + yaml_file = render_chart(resource, _retrieve_root_path(), helm_path) + + return yaml_file + + +def create_resource(yaml_content_dict): + ctx.logger.debug("Loading yaml: {}".format(yaml_content_dict)) + + if yaml_content_dict.get('kind', '') == 'PersistentVolumeClaim': + ctx.logger.debug("PersistentVolumeClaim custom handling") + kubernetes_plugin.custom_resource_create(definition=yaml_content_dict, api_mapping=_get_persistent_volume_mapping_claim_api()) + else: + kubernetes_plugin.resource_create(definition=yaml_content_dict) + + deployment_result.save_deployment_result('resource_{0}'.format(yaml_content_dict['metadata']['name'])) + +def delete_resource(yaml_content_dict): + ctx.logger.debug("Loading yaml: {}".format(yaml_content_dict)) + + deployment_result.save_deployment_result('resource_{0}'.format(yaml_content_dict['metadata']['name'])) + if yaml_content_dict.get('kind', '') == 'PersistentVolumeClaim': + ctx.logger.debug("PersistentVolumeClaim custom handling") + kubernetes_plugin.custom_resource_delete(definition=yaml_content_dict, api_mapping=_get_persistent_volume_mapping_claim_api()) + else: + kubernetes_plugin.resource_delete(definition=yaml_content_dict) + + +def render_chart(app, app_root_path, helm_cli_path): + app_chart_path = "{}/{}/".format(app_root_path, app) + ctx.logger.debug('App chart path = {}'.format(app_chart_path)) + return _exec_helm_template(helm_cli_path, app_chart_path) + + +def _exec_helm_template(helm_path, chart): + cmd = '{0} template {1}'.format(helm_path, chart) + ctx.logger.debug('Executing helm template cmd: {}'.format(cmd)) + rendered = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE).stdout.read().decode() + + return rendered + +def _get_persistent_volume_mapping_claim_api(): + api_mapping = { + 'create' : { + 'api': 'CoreV1Api', + 'method': 'create_namespaced_persistent_volume_claim', + 'payload': 'V1PersistentVolumeClaim' + }, + 'read' : { + 'api': 'CoreV1Api', + 'method': 'read_namespaced_persistent_volume_claim', + }, + 'delete': { + 'api': 'CoreV1Api', + 'method': 'delete_namespaced_persistent_volume_claim', + 'payload': 'V1DeleteOptions' + } + } + + return api_mapping + + +def _apply_readiness_workaround(yaml_file): + b64_env = _get_k8s_b64_env() + + input_dict = yaml.load(yaml_file) + + try: + init_containers = input_dict['spec']['template']['metadata']['annotations'][ + 'pod.beta.kubernetes.io/init-containers'] + init_cont_list = eval(init_containers) + + new_init_cont_list = list() + new_cont = None + for init_cont in init_cont_list: + if "oomk8s/readiness-check" in init_cont['image']: + init_cont['image'] = "clfy/oomk8s-cfy-readiness-check:1.0.1" + #init_cont['imagePullPolicy'] = "IfNotPresent" + init_cont['env'].append(b64_env) + new_cont = init_cont + new_init_cont_list.append(json.dumps(init_cont)) + + new_payload = ",".join(new_init_cont_list) + + if new_cont: + input_dict['spec']['template']['metadata']['annotations'].pop('pod.beta.kubernetes.io/init-containers') + input_dict['spec']['template']['metadata']['annotations']['pod.beta.kubernetes.io/init-containers'] = '[{}]'.format(new_payload) + + + except KeyError as ke: + ctx.logger.debug('Readiness section is not found.') + + return input_dict + + +def _get_k8s_b64(): + target_relationship = _retrieve_managed_by_master() + + k8s_config = target_relationship.node.properties.get('configuration').get('file_content') + + if not k8s_config: + raise Exception("Cannot find kubernetes config") + + k8s_config_plain = yaml.dump(k8s_config, allow_unicode=True) + + k8s_config_b64 = base64.b64encode(k8s_config_plain) + + return k8s_config_b64 + + +def _get_k8s_b64_env(): + env = dict() + env['name'] = 'K8S_CONFIG_B64' + env['value'] = _get_k8s_b64() + return env + + +def _retrieve_root_path(): + target_relationship = _retrieve_depends_on() + + apps_root_path = target_relationship.instance.runtime_properties.get(constants.RT_APPS_ROOT_PATH, None) + + ctx.logger.debug("Retrived apps root path = {}".format(apps_root_path)) + + return apps_root_path + +def _retrieve_helm_cli_path(): + target_relationship = _retrieve_depends_on() + + helm_cli_path = target_relationship.instance.runtime_properties.get(constants.RT_HELM_CLI_PATH, None) + + ctx.logger.debug("Retrived helm clis path = {}".format(helm_cli_path)) + + return helm_cli_path + +def _retrieve_depends_on(): + result = None + for relationship in ctx.instance.relationships: + if relationship.type == 'cloudify.relationships.depends_on': + return relationship.target + +def _retrieve_managed_by_master(): + result = None + for relationship in ctx.instance.relationships: + if relationship.type == 'cloudify.kubernetes.relationships.managed_by_master': + return relationship.target diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/workarounds.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/workarounds.py new file mode 100644 index 0000000000..fe3e892c5b --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/common/workarounds.py @@ -0,0 +1,67 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + +from cloudify import ctx +from cloudify.exceptions import NonRecoverableError + +from fabric import api as fabric_api + +def _retrieve_namespace(): + namespace = ctx.node.properties.get( + 'namespace', + ctx.node.properties + .get('options', {}) + .get('namespace', None) + ) + + if not namespace: + raise NonRecoverableError( + 'Namespace is not defined (node={})'.format(ctx.node.name) + ) + + return namespace + + +def configure_secret(): + namespace = _retrieve_namespace() + ctx.logger.info( + 'Configuring docker secrets for namespace: {0}'.format(namespace) + ) + + command = 'kubectl create secret ' \ + 'docker-registry onap-docker-registry-key ' \ + '--docker-server=nexus3.onap.org:10001 ' \ + '--docker-username=docker ' \ + '--docker-password=docker ' \ + '--docker-email=email@email.com ' \ + '--namespace={0}'.format(namespace) + + ctx.logger.info('Command "{0}" will be executed'.format(command)) + + with fabric_api.settings( + **ctx.node.properties.get('ssh_credentials')): + fabric_api.run(command) + + ctx.logger.info('Docker secrets configured successfully') + + +def _get_fabric_env(): + result = dict() + + result['host_string'] = ctx.node.properties.get('ssh_credentials')['host_string'] + result['user'] = ctx.node.properties.get('ssh_credentials')['user'] + result['key'] = ctx.node.properties.get('ssh_credentials')['key'] + + return result diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/environment.py b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/environment.py new file mode 100644 index 0000000000..741f28ec32 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/environment.py @@ -0,0 +1,58 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + + +from cloudify import ctx +from cloudify.decorators import operation + +from common import constants +from common import helm +from common import init_pod, namespace + + +@operation +def create_init_pod(**kwargs): + init_pod.do_create_init_pod() + pass + + +@operation +def create_namespace(**kwargs): + namespace.do_create_namespace() + + +@operation +def delete_init_pod(**kwargs): + init_pod.do_delete_init_pod() + + +@operation +def delete_namespace(**kwargs): + namespace.do_delete_namespace() + + +@operation +def setup_helm_templates(**kwargs): + helm_url = constants.HELM_URL + ctx.instance.runtime_properties[constants.RT_HELM_CLI_PATH] = helm.get_helm_path(helm_url) + ctx.logger.debug('Helm cli path = {}'.format(ctx.instance.runtime_properties[constants.RT_HELM_CLI_PATH])) + + oom_git_url = constants.OOM_GIT_URL + ctx.instance.runtime_properties[constants.RT_APPS_ROOT_PATH] = helm.get_apps_root_path(oom_git_url) + ctx.logger.debug('Apps root path = {}'.format(ctx.instance.runtime_properties[constants.RT_APPS_ROOT_PATH])) + + + + diff --git a/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/requirements.txt b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/requirements.txt new file mode 100644 index 0000000000..9d8d880932 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/k8s_installer/requirements.txt @@ -0,0 +1 @@ +https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/archive/1.2.1.zip
\ No newline at end of file diff --git a/cloudify-onap/plugins/onap-installation-plugin/plugin.yaml b/cloudify-onap/plugins/onap-installation-plugin/plugin.yaml new file mode 100755 index 0000000000..f88b50bc78 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/plugin.yaml @@ -0,0 +1,87 @@ +plugins: + onap: + executor: central_deployment_agent + package_name: onap-installation-plugin + package_version: '1.0.0' + source: onap-installation-plugin + # install_arguments: '--process-dependency-links' + +node_types: + cloudify.onap.kubernetes.Environment: + derived_from: cloudify.nodes.Root + properties: + namespace: + type: string + init_pod: + type: string + description: > + Path to init pod chart + openstack_envs: + description: > + ONAP parameters defined at the onap-parameters.yaml file + default: {} + options: + description: > + For compatibility with kubernetes plugin. + To be removed in the future. + default: {} + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: onap.k8s_installer.environment.create_namespace + executor: central_deployment_agent + configure: + implementation: onap.k8s_installer.environment.setup_helm_templates + executor: central_deployment_agent + start: + implementation: onap.k8s_installer.environment.create_init_pod + executor: central_deployment_agent + stop: + implementation: onap.k8s_installer.environment.delete_init_pod + executor: central_deployment_agent + delete: + implementation: onap.k8s_installer.environment.delete_namespace + executor: central_deployment_agent + + cloudify.onap.kubernetes.App: + derived_from: cloudify.nodes.Root + properties: + name: + type: string + description: > + Name of ONAP app + path: + type: string + description: > + Paths (relative, blueprint prespective) to app chart directory + required: false + options: + description: > + For compatibility with kubernetes plugin. + To be removed in the future. + default: {} + ssh_credentials: + description: > + Workaround for docker secret settings + via fabric plugin + default: + host_string: { get_secret: kubernetes_master_ip } + user: { get_secret: agent_user } + key: { get_secret: agent_key_private } + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: onap.k8s_installer.app.create_namespace + executor: central_deployment_agent + configure: + implementation: onap.k8s_installer.app.configure_docker_secret + executor: central_deployment_agent + start: + implementation: onap.k8s_installer.app.create_resources_services + executor: central_deployment_agent + stop: + implementation: onap.k8s_installer.app.delete_resources_services + executor: central_deployment_agent + delete: + implementation: onap.k8s_installer.app.delete_namespace + executor: central_deployment_agent diff --git a/cloudify-onap/plugins/onap-installation-plugin/requirements.txt b/cloudify-onap/plugins/onap-installation-plugin/requirements.txt new file mode 100644 index 0000000000..9d8d880932 --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/requirements.txt @@ -0,0 +1 @@ +https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/archive/1.2.1.zip
\ No newline at end of file diff --git a/cloudify-onap/plugins/onap-installation-plugin/setup.py b/cloudify-onap/plugins/onap-installation-plugin/setup.py new file mode 100755 index 0000000000..d413daa4ac --- /dev/null +++ b/cloudify-onap/plugins/onap-installation-plugin/setup.py @@ -0,0 +1,40 @@ +######## +# Copyright (c) 2017 GigaSpaces Technologies Ltd. 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. + + +from setuptools import setup + +try: + import cloudify_kubernetes +except ImportError: + import pip + pip.main(['install', 'https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/archive/1.2.1.zip']) + +setup( + name='onap-installation-plugin', + version='1.0.0', + author='', + author_email='', + packages=['k8s_installer', 'k8s_installer.common'], + install_requires=[ + 'cloudify-plugins-common>=3.3.1', + 'cloudify-kubernetes-plugin==1.2.1', + #'/tmp/k8spl/cloudify-kubernetes-plugin' + 'pyyaml', + 'gitpython', + 'paramiko==1.18.3', + 'fabric==1.13.1' + ] +) |