blob: edfd0577fe055fa03b7113edd697861c9bc5c9b3 [file] [log] [blame]
Jack Lucas230ae892018-03-27 00:04:46 -04001#!/bin/bash
Jack Lucas5b12c6d2018-04-04 21:47:28 +00002# ================================================================================
3# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ============LICENSE_END=========================================================
17
Jack Lucas230ae892018-03-27 00:04:46 -040018# Install DCAE via Cloudify Manager
19# Expects:
20# CM address (IP or DNS) in CMADDR environment variable
21# CM password in CMPASS environment variable (assumes user is "admin")
Jack Lucas0a48eea2018-05-10 20:50:54 +000022# ONAP common Kubernetes namespace in ONAP_NAMESPACE environment variable
23# If DCAE components are deployed in a separate Kubernetes namespace, that namespace in DCAE_NAMESPACE variable.
Jack Lucas53f31102018-04-02 20:55:04 +000024# Consul address with port in CONSUL variable
Jack Lucas230ae892018-03-27 00:04:46 -040025# Plugin wagon files in /wagons
Jack Lucas53f31102018-04-02 20:55:04 +000026# Blueprints for components to be installed in /blueprints
27# Input files for components to be installed in /inputs
28# Configuration JSON files that need to be loaded into Consul in /dcae-configs
Jack Lucas230ae892018-03-27 00:04:46 -040029
Jack Lucas53f31102018-04-02 20:55:04 +000030set -ex
Jack Lucas230ae892018-03-27 00:04:46 -040031
Jack Lucas5b12c6d2018-04-04 21:47:28 +000032# Consul service registration data
Jack Lucas53f31102018-04-02 20:55:04 +000033CBS_REG='{"ID": "dcae-cbs0", "Name": "config_binding_service", "Address": "config-binding-service", "Port": 10000}'
Jack Lucas5b12c6d2018-04-04 21:47:28 +000034CBS_REG1='{"ID": "dcae-cbs1", "Name": "config-binding-service", "Address": "config-binding-service", "Port": 10000}'
Jack Lucas5b12c6d2018-04-04 21:47:28 +000035INV_REG='{"ID": "dcae-inv0", "Name": "inventory", "Address": "inventory", "Port": 8080}'
Jack Lucas0a48eea2018-05-10 20:50:54 +000036# Cloudify Manager will always be in the ONAP namespace.
37CM_REG='{"ID": "dcae-cm0", "Name": "cloudify_manager", "Port": 80, "Address": "dcae-cloudify-manager.'${ONAP_NAMESPACE}'"}'
Jack Lucasbb206c72018-05-10 18:55:45 +000038# Policy handler will be looked up from a plugin on CM. If DCAE components are running in a different k8s
39# namespace than CM (which always runs in the common ONAP namespace), then the policy handler address must
40# be qualified with the DCAE namespace.
Jack Lucas0a48eea2018-05-10 20:50:54 +000041PH_REG='{"ID": "dcae-ph0", "Name": "policy_handler", "Port": 25577, "Address": "policy-handler'
Jack Lucasbb206c72018-05-10 18:55:45 +000042if [ ! -z "${DCAE_NAMESPACE}" ]
43then
44 PH_REG="${PH_REG}.${DCAE_NAMESPACE}"
45fi
46PH_REG="${PH_REG}\"}"
Jack Lucas5b12c6d2018-04-04 21:47:28 +000047
Jack Lucas230ae892018-03-27 00:04:46 -040048# Deploy components
49# $1 -- name (for bp and deployment)
50# $2 -- blueprint name
51# $3 -- inputs file name
52function deploy {
53 cfy install -b $1 -d $1 -i /inputs/$3 /blueprints/$2
54}
Jack Lucas5b12c6d2018-04-04 21:47:28 +000055# Set up profile to access Cloudify Manager
Jack Lucas230ae892018-03-27 00:04:46 -040056cfy profiles use -u admin -t default_tenant -p "${CMPASS}" "${CMADDR}"
57
58# Output status, for debugging purposes
59cfy status
60
Jack Lucas53f31102018-04-02 20:55:04 +000061# Load configurations into Consul
62for config in /dcae-configs/*.json
63do
64 # The basename of the file is the Consul key
65 key=$(basename ${config} .json)
66 # Strip out comments, empty lines
67 egrep -v "^#|^$" ${config} > /tmp/dcae-upload
68 curl -v -X PUT -H "Content-Type: application/json" --data-binary @/tmp/dcae-upload ${CONSUL}/v1/kv/${key}
69done
70
Jack Lucas5b12c6d2018-04-04 21:47:28 +000071# For backward compatibility, load some platform services into Consul service registry
72# Some components still rely on looking up a service in Consul
Jack Lucas53f31102018-04-02 20:55:04 +000073curl -v -X PUT -H "Content-Type: application/json" --data "${CBS_REG}" ${CONSUL}/v1/agent/service/register
Jack Lucas5b12c6d2018-04-04 21:47:28 +000074curl -v -X PUT -H "Content-Type: application/json" --data "${CBS_REG1}" ${CONSUL}/v1/agent/service/register
75curl -v -X PUT -H "Content-Type: application/json" --data "${CM_REG}" ${CONSUL}/v1/agent/service/register
76curl -v -X PUT -H "Content-Type: application/json" --data "${INV_REG}" ${CONSUL}/v1/agent/service/register
Jack Lucas2415db82018-04-30 01:23:45 +000077curl -v -X PUT -H "Content-Type: application/json" --data "${PH_REG}" ${CONSUL}/v1/agent/service/register
Jack Lucas5b12c6d2018-04-04 21:47:28 +000078
79# Store the CM password into a Cloudify secret
80cfy secret create -s ${CMPASS} cmpass
Jack Lucas53f31102018-04-02 20:55:04 +000081
Jack Lucas230ae892018-03-27 00:04:46 -040082# Load plugins onto CM
Jack Lucas53f31102018-04-02 20:55:04 +000083# Allow "already loaded" error
84# (If there are other problems, will
85# be caught in deployments.)
86set +e
Jack Lucas230ae892018-03-27 00:04:46 -040087for wagon in /wagons/*.wgn
88do
89 cfy plugins upload ${wagon}
90done
Jack Lucas53f31102018-04-02 20:55:04 +000091set -e
Jack Lucas230ae892018-03-27 00:04:46 -040092
Lusheng Jidda9b822018-05-04 16:02:38 -040093set +e
94# (don't let failure of one stop the script. this is likely due to image pull taking too long)
Jack Lucas230ae892018-03-27 00:04:46 -040095# Deploy platform components
96deploy config_binding_service k8s-config_binding_service.yaml k8s-config_binding_service-inputs.yaml
97deploy inventory k8s-inventory.yaml k8s-inventory-inputs.yaml
98deploy deployment_handler k8s-deployment_handler.yaml k8s-deployment_handler-inputs.yaml
99deploy policy_handler k8s-policy_handler.yaml k8s-policy_handler-inputs.yaml
Jack Lucasbac8d422018-04-27 22:11:51 +0000100deploy pgaas_initdb k8s-pgaas-initdb.yaml k8s-pgaas-initdb-inputs.yaml
101
102# Deploy service components
Jack Lucas2415db82018-04-30 01:23:45 +0000103deploy tca k8s-tca.yaml k8s-tca-inputs.yaml
104deploy ves k8s-ves.yaml k8s-ves-inputs.yaml
105# holmes_rules must be deployed before holmes_engine
106deploy holmes_rules k8s-holmes-rules.yaml k8s-holmes_rules-inputs.yaml
107deploy holmes_engine k8s-holmes-engine.yaml k8s-holmes_engine-inputs.yaml
108set -e
Jack Lucas230ae892018-03-27 00:04:46 -0400109
Jack Lucas53f31102018-04-02 20:55:04 +0000110# Display deployments, for debugging purposes
111cfy deployments list