From 4c8f0c7fd6605ae846d2eb77c42db6fc9193e9d4 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 8 Jul 2020 16:22:12 +0000 Subject: [PATCH] Installer: refactor file generation, improved ng-ui and light-ui separation, fixes in PLA Change-Id: Iacc435e6ebb9fa695ed7d0df1ff6a06d5ceb0edc Signed-off-by: garciadeblas --- installers/docker/docker-compose-lightui.yaml | 45 ++++ installers/docker/docker-compose-ngui.yaml | 237 +----------------- installers/docker/osm_pla/docker-compose.yaml | 9 +- installers/full_install_osm.sh | 93 ++++--- 4 files changed, 110 insertions(+), 274 deletions(-) create mode 100644 installers/docker/docker-compose-lightui.yaml diff --git a/installers/docker/docker-compose-lightui.yaml b/installers/docker/docker-compose-lightui.yaml new file mode 100644 index 00000000..1b23edd2 --- /dev/null +++ b/installers/docker/docker-compose-lightui.yaml @@ -0,0 +1,45 @@ +## +# Copyright 2019 ETSI +# +# 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. +## + +######################################################################## + +version: '3' +networks: + netOSM: + external: + name: ${OSM_NETWORK:-netosm} + #driver: overlay + #driver_opts: + # com.docker.network.driver.mtu: "1446" +services: + light-ui: + image: ${DOCKER_USER:-opensourcemano}/light-ui:${TAG:-8} + networks: + - netOSM + environment: + OSM_SERVER: nbi + #depends_on: + # - nbi + env_file: + - ./lwui.env + ports: + - "${OSM_UI_PORTS:-80:80}" + logging: + driver: "json-file" + options: + max-size: "100m" + max-file: "2" + diff --git a/installers/docker/docker-compose-ngui.yaml b/installers/docker/docker-compose-ngui.yaml index 77e3d847..5f52a11e 100644 --- a/installers/docker/docker-compose-ngui.yaml +++ b/installers/docker/docker-compose-ngui.yaml @@ -1,5 +1,5 @@ ## -# Copyright 2019 ETSI +# Copyright 2019-2020 ETSI # # 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 @@ -17,14 +17,6 @@ ######################################################################## version: '3' -volumes: - ro: - ro_db: - mongo_db: - mon_db: - pol_db: - osm_packages: - prom_db: networks: netOSM: external: @@ -33,220 +25,10 @@ networks: #driver_opts: # com.docker.network.driver.mtu: "1446" services: - zookeeper: - image: wurstmeister/zookeeper:${ZOOKEEPER_TAG:-latest} -# ports: -# - "2181:2181" - networks: - - netOSM - healthcheck: - test: echo stat | nc localhost 2181 - interval: 10s - timeout: 10s - retries: 3 - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - kafka: - image: wurstmeister/kafka:${KAFKA_TAG:-latest} - ports: - - "9092" - networks: - - netOSM - environment: - KAFKA_ADVERTISED_HOST_NAME: kafka - KAFKA_ADVERTISED_PORT: 9092 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LOG_RETENTION_HOURS: 24 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - healthcheck: - test: zookeeper-shell.sh zookeeper:2181 ls /brokers/ids 2>&1 | grep "Node does not exist" && exit 1 || exit 0 - interval: 20s - timeout: 10s - retries: 5 - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - #depends_on: - # - zookeeper - mongo: - image: mongo -# ports: -# - "27017:27017" - networks: - - netOSM - volumes: - - mongo_db:/data/db - prometheus: - image: prom/prometheus:${PROMETHEUS_TAG:-latest} - hostname: prometheus - ports: - - "${OSM_PROM_PORTS:-9091:9090}" - volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - - prom_db:/prometheus - networks: - - netOSM - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - prometheus-cadvisor: - image: google/cadvisor:${PROMETHEUS_CADVISOR_TAG:-latest} - ports: - - "${OSM_PROM_CADVISOR_PORTS:-8080:8080}" - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /dev/disk/:/dev/disk:ro - networks: - - netOSM - keystone: - image: ${DOCKER_USER:-opensourcemano}/keystone:${TAG:-8} - networks: - - netOSM - environment: - DB_HOST: mysql - env_file: - - ./keystone.env - ports: - - "${OSM_KEYSTONE_PORTS:-5000:5000}" - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - nbi: - image: ${DOCKER_USER:-opensourcemano}/nbi:${TAG:-8} - networks: - - netOSM - volumes: - - osm_packages:/app/storage - environment: - OSMNBI_DATABASE_HOST: mongo - OSMNBI_MESSAGE_HOST: kafka - env_file: - - ./nbi.env - ports: - - "${OSM_NBI_PORTS:-9999:9999}" - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - #depends_on: - # - kafka - # - mongo - lcm: - image: ${DOCKER_USER:-opensourcemano}/lcm:${TAG:-8} - networks: - - netOSM - volumes: - - osm_packages:/app/storage - environment: - OSMLCM_RO_HOST: ro - OSMLCM_DATABASE_HOST: mongo - OSMLCM_MESSAGE_HOST: kafka - env_file: - - ./lcm.env - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - #depends_on: - # - kafka - # - mongo - # - ro - mysql: - image: mysql:5 - networks: - netOSM: - aliases: - - ro-db - volumes: - - ro_db:/var/lib/mysql - env_file: - - ./ro-db.env - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" -# ports: -# - "3306:3306" - ro: - image: ${DOCKER_USER:-opensourcemano}/ro:${TAG:-8} - networks: - - netOSM - environment: - RO_DB_HOST: mysql - env_file: - - ./ro.env - #depends_on: - # - mysql - volumes: - - ro:/var/log/osm - ports: - - "${OSM_RO_PORTS:-9090:9090}" - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" - mon: - image: ${DOCKER_USER:-opensourcemano}/mon:${TAG:-8} - networks: - - netOSM - volumes: - - mon_db:/app/database - environment: - OSMMON_MESSAGE_HOST: kafka - OSMMON_MESSAGE_PORT: 9092 - env_file: - - ./mon.env - ports: - - "${OSM_MON_PORTS:-8662:8662}" - #depends_on: - # - kafka - logging: - driver: "json-file" - options: - max-file: 5 - max-size: 10m - pol: - image: ${DOCKER_USER:-opensourcemano}/pol:${TAG:-8} - networks: - - netOSM - volumes: - - pol_db:/app/database - environment: - OSMPOL_MESSAGE_HOST: kafka - OSMPOL_MESSAGE_PORT: 9092 - env_file: - - ./pol.env - #depends_on: - # - kafka - # - mon - logging: - driver: "json-file" - options: - max-file: 5 - max-size: 10m ng-ui: image: ${DOCKER_USER:-opensourcemano}/ng-ui:${TAG:-8} networks: - netOSM - #depends_on: - # - nbi ports: - "${OSM_UI_PORTS:-80:80}" logging: @@ -254,21 +36,4 @@ services: options: max-size: "100m" max-file: "2" - grafana: - image: grafana/grafana - volumes: - - ./files/dashboards-osm.yml:/etc/grafana/provisioning/dashboards/dashboards-osm.yml - - ./files/osm-sample-dashboard.json:/etc/grafana/provisioning/dashboards/osm-sample-dashboard.json - - ./files/osm-system-dashboard.json:/etc/grafana/provisioning/dashboards/osm-system-dashboard.json - - ./files/datasource-prometheus.yml:/etc/grafana/provisioning/datasources/datasource-prometheus.yml - hostname: grafana - ports: - - "${OSM_GRAFANA_PORTS:-3000:3000}" - networks: - - netOSM - logging: - driver: "json-file" - options: - max-size: "100m" - max-file: "2" diff --git a/installers/docker/osm_pla/docker-compose.yaml b/installers/docker/osm_pla/docker-compose.yaml index 93699ef5..aae303ff 100644 --- a/installers/docker/osm_pla/docker-compose.yaml +++ b/installers/docker/osm_pla/docker-compose.yaml @@ -17,9 +17,16 @@ ######################################################################## version: '3' +networks: + netOSM: + external: + name: ${OSM_NETWORK:-netosm} + #driver: overlay + #driver_opts: + # com.docker.network.driver.mtu: "1446" services: pla: - image: ${DOCKER_USER:-opensourcemano}/pla:${TAG:-7} + image: ${DOCKER_USER:-opensourcemano}/pla:${TAG:-8} networks: - netOSM logging: diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index f268618d..bb0f5740 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -569,6 +569,48 @@ function cmp_overwrite() { fi } +function generate_docker_compose_files() { + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml + if [ -n "$NGUI" ]; then + # For NG-UI + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose-ngui.yaml $OSM_DOCKER_WORK_DIR/docker-compose-ui.yaml + else + # Docker-compose + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose-lightui.yaml $OSM_DOCKER_WORK_DIR/docker-compose-ui.yaml + fi + if [ -n "$INSTALL_PLA" ]; then + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_pla/docker-compose.yaml $OSM_DOCKER_WORK_DIR/osm_pla/docker-compose.yaml + fi +} + +function generate_k8s_manifest_files() { + #Kubernetes resources + $WORKDIR_SUDO cp -bR ${OSM_DEVOPS}/installers/docker/osm_pods $OSM_DOCKER_WORK_DIR + if [ -n "$NGUI" ]; then + $WORKDIR_SUDO rm -f $OSM_K8S_WORK_DIR/light-ui.yaml + else + $WORKDIR_SUDO rm -f $OSM_K8S_WORK_DIR/ng-ui.yaml + fi +} + +function generate_prometheus_grafana_files() { + [ -n "$KUBERNETES" ] && return + # Prometheus files + $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/prometheus + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus/prometheus.yml + + # Grafana files + $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/grafana + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/dashboards-osm.yml $OSM_DOCKER_WORK_DIR/grafana/dashboards-osm.yml + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/datasource-prometheus.yml $OSM_DOCKER_WORK_DIR/grafana/datasource-prometheus.yml + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-sample-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-sample-dashboard.json + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-system-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-system-dashboard.json + + # Prometheus Exporters files + $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/prometheus_exporters + $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus_exporters/node_exporter.service $OSM_DOCKER_WORK_DIR/prometheus_exporters/node_exporter.service +} + function generate_docker_env_files() { echo "Doing a backup of existing env files" $WORKDIR_SUDO cp $OSM_DOCKER_WORK_DIR/keystone-db.env{,~} @@ -582,38 +624,6 @@ function generate_docker_env_files() { $WORKDIR_SUDO cp $OSM_DOCKER_WORK_DIR/ro.env{,~} echo "Generating docker env files" - if [ -n "$KUBERNETES" ]; then - #Kubernetes resources - $WORKDIR_SUDO cp -bR ${OSM_DEVOPS}/installers/docker/osm_pods $OSM_DOCKER_WORK_DIR - [ -n "$NGUI" ] && $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_pods/ng-ui.yaml $OSM_K8S_WORK_DIR/ng-ui.yaml && $WORKDIR_SUDO rm $OSM_K8S_WORK_DIR/light-ui.yaml - else - if [ -n "$NGUI" ]; then - # For NG-UI - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose-ngui.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml - else - # Docker-compose - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml - fi - if [ -n "$INSTALL_PLA" ]; then - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/osm_pla/docker-compose.yaml $OSM_DOCKER_WORK_DIR/osm_pla/docker-compose.yaml - fi - - # Prometheus files - $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/prometheus - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus/prometheus.yml - - # Grafana files - $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/grafana - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/dashboards-osm.yml $OSM_DOCKER_WORK_DIR/grafana/dashboards-osm.yml - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/datasource-prometheus.yml $OSM_DOCKER_WORK_DIR/grafana/datasource-prometheus.yml - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-sample-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-sample-dashboard.json - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-system-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-system-dashboard.json - - # Prometheus Exporters files - $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR/prometheus_exporters - $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus_exporters/node_exporter.service $OSM_DOCKER_WORK_DIR/prometheus_exporters/node_exporter.service - fi - # LCM if [ ! -f $OSM_DOCKER_WORK_DIR/lcm.env ]; then echo "OSMLCM_DATABASE_COMMONKEY=${OSM_DATABASE_COMMONKEY}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env @@ -810,8 +820,6 @@ function deploy_osm_services() { } function deploy_osm_pla_service() { - # corresponding to parse_yaml - [ ! $OSM_DOCKER_TAG == "7" ] && $WORKDIR_SUDO sed -i "s/opensourcemano\/pla:.*/opensourcemano\/pla:$OSM_DOCKER_TAG/g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml # corresponding to namespace_vol $WORKDIR_SUDO sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml # corresponding to deploy_osm_services @@ -861,6 +869,7 @@ function parse_yaml() { for osm in $osm_services; do $WORKDIR_SUDO sed -i "s/opensourcemano\/$osm:.*/$DOCKER_USER\/$osm:$TAG/g" $OSM_K8S_WORK_DIR/$osm.yaml done + $WORKDIR_SUDO sed -i "s/opensourcemano\/pla:.*/$DOCKER_USER\/\/pla:$OSM_DOCKER_TAG/g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml } function namespace_vol() { @@ -936,9 +945,10 @@ function deploy_lightweight() { pushd $OSM_DOCKER_WORK_DIR if [ -n "$INSTALL_PLA" ]; then - sg docker -c ". ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml -c $OSM_DOCKER_WORK_DIR/osm_pla/docker-compose.yaml $OSM_STACK_NAME" + track deploy_osm_pla + sg docker -c ". ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml -c $OSM_DOCKER_WORK_DIR/docker-compose-ui.yaml -c $OSM_DOCKER_WORK_DIR/osm_pla/docker-compose.yaml $OSM_STACK_NAME" else - sg docker -c ". ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml $OSM_STACK_NAME" + sg docker -c ". ./osm_ports.sh; docker stack deploy -c $OSM_DOCKER_WORK_DIR/docker-compose.yaml -c $OSM_DOCKER_WORK_DIR/docker-compose-ui.yaml $OSM_STACK_NAME" fi popd @@ -1165,7 +1175,15 @@ EOF [ -z "$DOCKER_NOBUILD" ] && generate_docker_images track docker_build + if [ -n "$KUBERNETES" ]; then + generate_k8s_manifest_files + else + generate_docker_compose_files + fi + track manifest_files + generate_prometheus_grafana_files generate_docker_env_files + track env_files if [ -n "$KUBERNETES" ]; then if [ -n "$INSTALL_K8S_MONITOR" ]; then @@ -1177,13 +1195,14 @@ EOF remove_k8s_namespace $OSM_STACK_NAME deploy_cni_provider kube_secrets - [ ! $OSM_DOCKER_TAG == "7" ] && parse_yaml $OSM_DOCKER_TAG + [ ! $OSM_DOCKER_TAG == "8" ] && parse_yaml $OSM_DOCKER_TAG namespace_vol taint_master_node deploy_osm_services if [ -n "$INSTALL_PLA"]; then # optional PLA install deploy_osm_pla_service + track deploy_osm_pla fi track deploy_osm_services_k8s install_k8s_storageclass -- 2.25.1