Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 2 | # ================================================================================ |
| 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 Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 18 | # 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 Lucas | 0a48eea | 2018-05-10 20:50:54 +0000 | [diff] [blame] | 22 | # 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 Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 24 | # Consul address with port in CONSUL variable |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 25 | # Plugin wagon files in /wagons |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 26 | # 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 Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 29 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 30 | set -ex |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 31 | |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 32 | # Consul service registration data |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 33 | CBS_REG='{"ID": "dcae-cbs0", "Name": "config_binding_service", "Address": "config-binding-service", "Port": 10000}' |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 34 | CBS_REG1='{"ID": "dcae-cbs1", "Name": "config-binding-service", "Address": "config-binding-service", "Port": 10000}' |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 35 | INV_REG='{"ID": "dcae-inv0", "Name": "inventory", "Address": "inventory", "Port": 8080}' |
Jack Lucas | 0a48eea | 2018-05-10 20:50:54 +0000 | [diff] [blame] | 36 | # Cloudify Manager will always be in the ONAP namespace. |
| 37 | CM_REG='{"ID": "dcae-cm0", "Name": "cloudify_manager", "Port": 80, "Address": "dcae-cloudify-manager.'${ONAP_NAMESPACE}'"}' |
Jack Lucas | bb206c7 | 2018-05-10 18:55:45 +0000 | [diff] [blame] | 38 | # 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 Lucas | 0a48eea | 2018-05-10 20:50:54 +0000 | [diff] [blame] | 41 | PH_REG='{"ID": "dcae-ph0", "Name": "policy_handler", "Port": 25577, "Address": "policy-handler' |
Jack Lucas | bb206c7 | 2018-05-10 18:55:45 +0000 | [diff] [blame] | 42 | if [ ! -z "${DCAE_NAMESPACE}" ] |
| 43 | then |
| 44 | PH_REG="${PH_REG}.${DCAE_NAMESPACE}" |
| 45 | fi |
| 46 | PH_REG="${PH_REG}\"}" |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 47 | |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 48 | # Deploy components |
| 49 | # $1 -- name (for bp and deployment) |
| 50 | # $2 -- blueprint name |
| 51 | # $3 -- inputs file name |
| 52 | function deploy { |
| 53 | cfy install -b $1 -d $1 -i /inputs/$3 /blueprints/$2 |
| 54 | } |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 55 | # Set up profile to access Cloudify Manager |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 56 | cfy profiles use -u admin -t default_tenant -p "${CMPASS}" "${CMADDR}" |
| 57 | |
| 58 | # Output status, for debugging purposes |
| 59 | cfy status |
| 60 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 61 | # Load configurations into Consul |
| 62 | for config in /dcae-configs/*.json |
| 63 | do |
| 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} |
| 69 | done |
| 70 | |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 71 | # For backward compatibility, load some platform services into Consul service registry |
| 72 | # Some components still rely on looking up a service in Consul |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 73 | curl -v -X PUT -H "Content-Type: application/json" --data "${CBS_REG}" ${CONSUL}/v1/agent/service/register |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 74 | curl -v -X PUT -H "Content-Type: application/json" --data "${CBS_REG1}" ${CONSUL}/v1/agent/service/register |
| 75 | curl -v -X PUT -H "Content-Type: application/json" --data "${CM_REG}" ${CONSUL}/v1/agent/service/register |
| 76 | curl -v -X PUT -H "Content-Type: application/json" --data "${INV_REG}" ${CONSUL}/v1/agent/service/register |
Jack Lucas | 2415db8 | 2018-04-30 01:23:45 +0000 | [diff] [blame] | 77 | curl -v -X PUT -H "Content-Type: application/json" --data "${PH_REG}" ${CONSUL}/v1/agent/service/register |
Jack Lucas | 5b12c6d | 2018-04-04 21:47:28 +0000 | [diff] [blame] | 78 | |
| 79 | # Store the CM password into a Cloudify secret |
| 80 | cfy secret create -s ${CMPASS} cmpass |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 81 | |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 82 | # Load plugins onto CM |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 83 | # Allow "already loaded" error |
| 84 | # (If there are other problems, will |
| 85 | # be caught in deployments.) |
| 86 | set +e |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 87 | for wagon in /wagons/*.wgn |
| 88 | do |
| 89 | cfy plugins upload ${wagon} |
| 90 | done |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 91 | set -e |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 92 | |
Lusheng Ji | dda9b82 | 2018-05-04 16:02:38 -0400 | [diff] [blame] | 93 | set +e |
| 94 | # (don't let failure of one stop the script. this is likely due to image pull taking too long) |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 95 | # Deploy platform components |
| 96 | deploy config_binding_service k8s-config_binding_service.yaml k8s-config_binding_service-inputs.yaml |
| 97 | deploy inventory k8s-inventory.yaml k8s-inventory-inputs.yaml |
| 98 | deploy deployment_handler k8s-deployment_handler.yaml k8s-deployment_handler-inputs.yaml |
| 99 | deploy policy_handler k8s-policy_handler.yaml k8s-policy_handler-inputs.yaml |
Jack Lucas | bac8d42 | 2018-04-27 22:11:51 +0000 | [diff] [blame] | 100 | deploy pgaas_initdb k8s-pgaas-initdb.yaml k8s-pgaas-initdb-inputs.yaml |
| 101 | |
| 102 | # Deploy service components |
Jack Lucas | 2415db8 | 2018-04-30 01:23:45 +0000 | [diff] [blame] | 103 | deploy tca k8s-tca.yaml k8s-tca-inputs.yaml |
| 104 | deploy ves k8s-ves.yaml k8s-ves-inputs.yaml |
| 105 | # holmes_rules must be deployed before holmes_engine |
| 106 | deploy holmes_rules k8s-holmes-rules.yaml k8s-holmes_rules-inputs.yaml |
| 107 | deploy holmes_engine k8s-holmes-engine.yaml k8s-holmes_engine-inputs.yaml |
| 108 | set -e |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 109 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 110 | # Display deployments, for debugging purposes |
| 111 | cfy deployments list |