From 1365d5faf34f84a2f427bada95f4bc67a15c5bec Mon Sep 17 00:00:00 2001 From: RehanRaza Date: Thu, 29 Jul 2021 16:52:59 +0200 Subject: [PATCH] Add docker-compose for control loop version of ORU usecase Change-Id: I8a5561566283f355f74130fe886fd571ca4b54af Issue-ID: NONRTRIC-554 Signed-off-by: RehanRaza --- .../controlloop-rest-payloads/commission.yaml | 8 +-- .../docker-compose-controlloop/README.md | 49 +++++++++++++ .../config/db/bootstrap-database.sh | 28 ++++++++ .../config/db/create-db.sql | 13 ++++ .../docker-compose-controlloop/config/ks.jks | Bin 0 -> 2647 bytes .../docker-compose-controlloop/docker-compose.yml | 80 +++++++++++++++++++++ .../scriptversion/helm/chartmuseum_init.sh | 41 +++++++++++ 7 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/README.md create mode 100755 test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/bootstrap-database.sh create mode 100644 test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/create-db.sql create mode 100644 test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/ks.jks create mode 100644 test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/docker-compose.yml create mode 100755 test/usecases/oruclosedlooprecovery/scriptversion/helm/chartmuseum_init.sh diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/controlloop-rest-payloads/commission.yaml b/test/usecases/oruclosedlooprecovery/scriptversion/controlloop-rest-payloads/commission.yaml index 7e913482..6d9bdd23 100644 --- a/test/usecases/oruclosedlooprecovery/scriptversion/controlloop-rest-payloads/commission.yaml +++ b/test/usecases/oruclosedlooprecovery/scriptversion/controlloop-rest-payloads/commission.yaml @@ -117,7 +117,7 @@ topology_template: version: 0.1.0 releaseName: oru-app # repository can point to a helm repo or a path in local file system where chart is stored - repository: local + repository: chartmuseum namespace: nonrtric org.onap.domain.linkmonitor.MessageGeneratorK8SMicroserviceControlLoopElement: version: 1.2.3 @@ -137,7 +137,7 @@ topology_template: version: 0.1.0 releaseName: message-generator # repository can point to a helm repo or a path in local file system where chart is stored - repository: local + repository: chartmuseum namespace: nonrtric overrideParams: image.tag: v2 @@ -159,7 +159,7 @@ topology_template: version: 0.1.0 releaseName: sdnr-simulator # repository can point to a helm repo or a path in local file system where chart is stored - repository: local + repository: chartmuseum namespace: nonrtric org.onap.domain.linkmonitor.DmaapMrK8SMicroserviceControlLoopElement: version: 1.2.3 @@ -179,5 +179,5 @@ topology_template: version: 0.1.0 releaseName: dmaap-mr # repository can point to a helm repo or a path in local file system where chart is stored - repository: local + repository: chartmuseum namespace: nonrtric \ No newline at end of file diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/README.md b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/README.md new file mode 100644 index 00000000..965da2b0 --- /dev/null +++ b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/README.md @@ -0,0 +1,49 @@ +This docker-compose will create a control loop that will deploy all components of the closed loop recovery use case into a k8s cluster using the k8s participant from CLAMP in ONAP. + +It will also bring up the chartmuseum registry that will be used by helm when deploying the charts. +The script named chartmuseum_init.sh will push all the charts into the chartmuseum. +This script is mounted into the k8s-participant docker container but can also be run locally. + +Depending on the type of k8s cluster and the operating system being used, different settings might need to be done for the k8s-participant docker container. For example, in case of minikube, the following should be added under k8s-participant (assuming that kube-config file of the host machine has been copied into the config directory): + +volumes: + - ./config/kube-config:/home/policy/.kube/config:ro + - ~/.minikube/profiles/minikube:/home/policy/.minikube/profiles/minikube + +This will mount the kube-config file into the k8s-participant docker container so that it is able to deploy services into the minikube instance running in the host machine. The minikube directory contains the client-certificate and client-key. + +Since the kube-api server is running in the host machine instead of the k8s-participant docker container, some extra steps are needed: + +1) Linux + +Run the following command in the host machine so that the localhost referred to in the kube-config file points to the host machine: + +iptables -A INPUT -i docker0 -j ACCEPT + +2) Mac + +Mac OS does not seem to have the iptables command. However, in order to refer to the host machine from inside the docker container, one may use "host.docker.internal" but this gives rise to another problem: + +Unable to connect to the server: x509: certificate is valid for minikubeCA, control-plane.minikube.internal, kubernetes.default.svc.cluster.local, kubernetes.default.svc, kubernetes.default, kubernetes, localhost, not host.docker.internal + +As a workaround, the TLS can be disabled. So, the following part should be modified in the kube-config file: + +- cluster: + server: https://host.docker.internal: + insecure-skip-tls-verify: true + + +## License + +Copyright (C) 2021 Nordix Foundation. +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/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/bootstrap-database.sh b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/bootstrap-database.sh new file mode 100755 index 00000000..ac2d0a50 --- /dev/null +++ b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/bootstrap-database.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +### +# ============LICENSE_START======================================================= +# ONAP CLAMP +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 2021 Nordix Foundation. 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============================================ +# =================================================================== +# +### + +mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < /docker-entrypoint-initdb.d/create-db.sql +mysql -uroot -p$MYSQL_ROOT_PASSWORD --execute "CREATE USER 'policy'@'%' IDENTIFIED BY 'P01icY';" +mysql -uroot -p$MYSQL_ROOT_PASSWORD --execute "GRANT ALL PRIVILEGES ON controlloop.* TO 'policy'@'%';" \ No newline at end of file diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/create-db.sql b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/create-db.sql new file mode 100644 index 00000000..bc644312 --- /dev/null +++ b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/db/create-db.sql @@ -0,0 +1,13 @@ +# +# Create CLDS database objects (tables, etc.) +# +# +CREATE DATABASE IF NOT EXISTS `cldsdb4`; +CREATE DATABASE IF NOT EXISTS `policyadmin`; +CREATE DATABASE IF NOT EXISTS `controlloop`; +USE `cldsdb4`; +DROP USER 'clds'; +CREATE USER 'clds'; +GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; +FLUSH PRIVILEGES; + diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/ks.jks b/test/usecases/oruclosedlooprecovery/scriptversion/docker-compose-controlloop/config/ks.jks new file mode 100644 index 0000000000000000000000000000000000000000..001c7e1a9aad185507bb401e71096a794e11ee44 GIT binary patch literal 2647 zcmY+Ec{mgb7sdx;G)DG)8zk9{oy6FQA&jwB*0Kx}%9gT>y<{1Z?Af!0B9lG)URf`Z zFv8en?0oL`eBZrKf1Kx>^S7zIe_BWbVf}e_LM0 zCbBa%?J{{x?MdzLfXFET?Iu7huxDAsdfd-cB6OQROQ0sQ)QEO_^v=#pRpt93vLB8w zXZNabI>@2JrMq#PJWSLgpXNTxexQao|7Ok7ZRC`b(>Fo7%;L%mp6Ibrv$YfmJTU1O z+g#eutaa0B@!CyjnLR(?l(BwtwfS9-bEdx3?QssT{9b6`ik#S6Qn%v9ect;VMy#T! zABB>5 zq>?*>V^5sV8=eH;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++j3c)kbzOh~)2YCLsydC5$~)jn1}n1MFnB*BgF7tWaaacQpd>s(%I=N=%$7ElF>M91OhtHizg_?8hlxMl!WcG|GVSu`ZEgufEYisv}u7@S^!W!R-n) zAz^629%0H*|KNfURU}5tW6fR4h)*p@tDHl!$$81@Q{chsnA*n`2D%fR=Zm;SqHv%z zw2-Wg1aSK@zrCAvq<2QxXVLtza$-xeaW4@JDawB{GwqvWkjT}{@AfM0B;2F9>XtfD zbC|ohq*(SQ#6K9C79@LF@@?ou@RH&9n|qEd&{)AzUsS7c*odM=-CG_;8gBR<)s%<% zK1h?OZWn56(sytLqIG?yAD5I0KPq8Md^G&2>cF-tBF<{HM_byT%&1s`z+dUtCBTZH zSb&!lAz8ef#f(2;N%lq2yCC#nk8UOiV-oeMzAsb_oGueS?2EcyWKu@u%yH26Q$Dp_ zkyqP zs>eHI)uNc0cQnD|{!DK#DgAy~c$}%aAXm{OHWxyuY{Hh`BFYiiw&XW1>Epvrf3x:/home/policy/.kube/config:ro + environment: + - TOPICSERVER=onap-dmaap + - KEYSTORE=/opt/app/policy/clamp/etc/ssl/policy-keystore.jks + - KEYSTORE_PASSWD=Pol1cy_0nap + entrypoint: sh -c "/home/policy/helm/chartmuseum_init.sh && /opt/app/policy/clamp/bin/kubernetes-participant.sh" + chartmuseum: + image: ghcr.io/helm/chartmuseum:v0.13.1 + container_name: chartmuseum + hostname: chartmuseum + volumes: + - ./charts:/charts + environment: + - STORAGE=local + - STORAGE_LOCAL_ROOTDIR=/charts +volumes: + db-vol: \ No newline at end of file diff --git a/test/usecases/oruclosedlooprecovery/scriptversion/helm/chartmuseum_init.sh b/test/usecases/oruclosedlooprecovery/scriptversion/helm/chartmuseum_init.sh new file mode 100755 index 00000000..4b0c7ee3 --- /dev/null +++ b/test/usecases/oruclosedlooprecovery/scriptversion/helm/chartmuseum_init.sh @@ -0,0 +1,41 @@ +# Copyright (C) 2021 Nordix Foundation. 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================================================= +# + +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd ${SHELL_FOLDER} + +# build dmaap-mr helm chart & push to chartmuseum +cd ${SHELL_FOLDER}/dmaap-mr/ +helm package . +curl --data-binary "@dmaap-mr-0.1.0.tgz" http://chartmuseum:8080/api/charts + +# build message-generator helm chart & push to chartmuseum +cd ${SHELL_FOLDER}/message-generator/ +helm package . +curl --data-binary "@message-generator-0.1.0.tgz" http://chartmuseum:8080/api/charts + +# build oru-app helm chart & push to chartmuseum +cd ${SHELL_FOLDER}/oru-app/ +helm package . +curl --data-binary "@oru-app-0.1.0.tgz" http://chartmuseum:8080/api/charts + +# build sdnr-simulator helm chart & push to chartmuseum +cd ${SHELL_FOLDER}/sdnr-simulator/ +helm package . +curl --data-binary "@sdnr-simulator-0.1.0.tgz" http://chartmuseum:8080/api/charts + +# add chartmuseum repo to helm +helm repo add chartmuseum http://chartmuseum:8080 \ No newline at end of file -- 2.16.6