summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lucas <jflucas@research.att.com>2019-02-08 14:21:58 -0500
committerJack Lucas <jflucas@research.att.com>2019-02-15 17:05:55 -0500
commit5caf1654683a567da7e4158e4e7e108dd2232a13 (patch)
tree02370038eff60f8393d0a50533e75d1fd4340af6
parentba636576dd196fd8f22b461763320abcd785c751 (diff)
Move ph and dh to Helm
-- Helm charts for ph and dh -- New container to do Consul k-v storage and service reg -- Bootstrap container no longer deploys ph and dh -- Healthcheck looks for ph and dh as Helm deployments -- Updated/added licensing information Issue-ID: DCAEGEN2-1091 Issue-ID: DCAEGEN2-1092 Change-Id: I5340bee6fba1340d4c05b0f37ddfb539c543469e Signed-off-by: Jack Lucas <jflucas@research.att.com>
-rw-r--r--consul-loader-container/Dockerfile23
-rw-r--r--consul-loader-container/README.md11
-rwxr-xr-xconsul-loader-container/consul_store.sh94
-rw-r--r--consul-loader-container/pom.xml172
-rw-r--r--healthcheck-container/healthcheck.js6
-rw-r--r--healthcheck-container/package.json2
-rw-r--r--healthcheck-container/pom.xml4
-rwxr-xr-xk8s-bootstrap-container/bootstrap.sh20
-rwxr-xr-xk8s-bootstrap-container/load-blueprints.sh17
-rw-r--r--k8s-bootstrap-container/pom.xml4
-rw-r--r--pom.xml7
11 files changed, 329 insertions, 31 deletions
diff --git a/consul-loader-container/Dockerfile b/consul-loader-container/Dockerfile
new file mode 100644
index 0000000..868b41f
--- /dev/null
+++ b/consul-loader-container/Dockerfile
@@ -0,0 +1,23 @@
+# ============LICENSE_START=======================================================
+# org.onap.dcae
+# ================================================================================
+# Copyright (c) 2019 AT&T Intellectual Property. 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=========================================================
+#
+FROM ubuntu:16.04
+RUN apt-get update && apt-get install -y curl && mkdir -p /opt/app
+COPY *.sh /opt/app/
+WORKDIR /opt/app
+ENTRYPOINT ["/opt/app/consul_store.sh"]
diff --git a/consul-loader-container/README.md b/consul-loader-container/README.md
new file mode 100644
index 0000000..f3869d7
--- /dev/null
+++ b/consul-loader-container/README.md
@@ -0,0 +1,11 @@
+# DCAE Consul Loader Container
+
+The Dockerfile in this directory builds an image that can be used to spin up a container (typical a Kubernetes init container) that can load
+service registrations and key-value pairs into a Consul instance. This capability supports moving certain DCAE platform components from
+deployment using a Cloudify blueprint and the ONAP Kubernetes plugin to a Helm-based deployment. An init container can do the Consul
+setup previously handled by the ONAP Kubernetes plugin and the ONAP DCAE bootstrap script.
+
+The entrypoint for the container is the script `consul_store.sh`. See the documentation for `consul_store.sh` to see how to provide arguments to the script
+as well as how to use environment variables to set the Consul API protocol, host, and port.
+
+Note that the container runs the script to completion. It is not intended to be a long-running service. \ No newline at end of file
diff --git a/consul-loader-container/consul_store.sh b/consul-loader-container/consul_store.sh
new file mode 100755
index 0000000..4e64fc3
--- /dev/null
+++ b/consul-loader-container/consul_store.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+# ================================================================================
+# Copyright (c) 2019 AT&T Intellectual Property. 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=========================================================
+
+# Push service registrations and key-value pairs to consul
+#
+# Environment variables control the consul address used:
+# -- CONSUL_PROTO: The protocol (http or https) used to access consul. DEFAULT: http
+# -- CONSUL_HOST: The Consul host address. DEFAULT: consul
+# -- CONSUL_PORT: The Consul API port. DEFAULT: 8500
+#
+# Command line options
+# --service name|address|port : Register a service with name 'name', address 'address', and port 'port'.
+# --key keyname|filepath: Register a key-value pair with key 'keyname' and the contents of a file at 'filepath' as its value
+# A command can include multiple instances of each option.
+
+CONSUL_ADDR=${CONSUL_PROTO:-http}://${CONSUL_HOST:-consul}:${CONSUL_PORT:-8500}
+KV_URL=${CONSUL_ADDR}/v1/kv
+REG_URL=${CONSUL_ADDR}/v1/catalog/register
+
+# Register a service into Consul so that it can be discovered via the Consul service discovery API
+# $1: Name under which service is registered
+# $2: Address (typically DNS name, but can be IP) of the service
+# $3: Port used by the service
+function register_service {
+ service="{\"Node\": \"dcae\", \"Address\": \"$2\", \"Service\": {\"Service\": \"$1\", \"Address\": \"$2\", \"Port\": $3}}"
+ echo $service
+ curl -v -X PUT --data-binary "${service}" -H 'Content-Type: application/json' $REG_URL
+}
+
+# Store the contents of a file into Consul KV store
+# $1: Key under which content is stored
+# $2: Path to file whose content will be the value associated with the key
+function put_key {
+ curl -v -X PUT --data-binary @$2 -H 'Content-Type: application/json' ${KV_URL}/$1
+}
+
+set -x
+
+# Check Consul readiness
+# The readiness container waits for a "consul-server" container to be ready,
+# but this isn't always enough. We need the Consul API to be up and for
+# the cluster to be formed, otherwise our Consul accesses might fail.
+# Wait for Consul API to come up
+until curl ${CONSUL_ADDR}/v1/agent/services
+do
+ echo Waiting for Consul API
+ sleep 60
+done
+# Wait for a leader to be elected
+until [[ "$(curl -Ss {$CONSUL_ADDR}/v1/status/leader)" != '""' ]]
+do
+ echo Waiting for leader
+ sleep 30
+done
+
+while (( "$#" ))
+do
+ case $1 in
+
+ "--service")
+ # ${2//|/ } turns all of the | characters in argument 2 into spaces
+ # () uses the space delimited string to initialize an array
+ # this turns an argument like inventory-api|inventory.onap|8080 into
+ # a three-element array with elements "inventory-api", "inventory.onap", and "8080"
+ s=(${2//|/ })
+ register_service ${s[@]}
+ shift 2;
+ ;;
+ "--key")
+ # See above for explanation of (${2//|/ })
+ kv=(${2//|/ })
+ put_key ${kv[@]}
+ shift 2;
+ ;;
+ *)
+ echo "ignoring $1"
+ shift
+ ;;
+ esac
+done
diff --git a/consul-loader-container/pom.xml b/consul-loader-container/pom.xml
new file mode 100644
index 0000000..dd68443
--- /dev/null
+++ b/consul-loader-container/pom.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0"?>
+<!--
+================================================================================
+Copyright (c) 2019 AT&T Intellectual Property. 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=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.dcaegen2.deployments</groupId>
+ <artifactId>deployments</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.dcaegen2.deployments</groupId>
+ <artifactId>consul-loader-container</artifactId>
+ <name>dcaegen2-deployments-consul-loader-container</name>
+ <version>1.0.0</version>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <sonar.skip>true</sonar.skip>
+ <sonar.sources>.</sonar.sources>
+ <!-- customize the SONARQUBE URL -->
+ <!-- sonar.host.url>http://localhost:9000</sonar.host.url -->
+ <!-- below are language dependent -->
+ <!-- for Python -->
+ <sonar.language>py</sonar.language>
+ <sonar.pluginName>Python</sonar.pluginName>
+ <sonar.inclusions>**/*.py</sonar.inclusions>
+ <!-- for JavaScaript -->
+ <!--
+ <sonar.language>js</sonar.language>
+ <sonar.pluginName>JS</sonar.pluginName>
+ <sonar.inclusions>**/*.js</sonar.inclusions>
+ -->
+ </properties>
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <!-- plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.4.1</version>
+ <configuration>
+ <descriptors>
+ <descriptor>assembly/dep.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin -->
+ <!-- now we configure custom action (calling a script) at various lifecycle phases -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <id>clean phase script</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>clean</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>generate-sources script</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>generate-sources</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>compile script</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>compile</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>package script</id>
+ <phase>package</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>package</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test script</id>
+ <phase>test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>test</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>install script</id>
+ <phase>install</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>install</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>deploy script</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>${project.artifactId}</argument>
+ <argument>deploy</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/healthcheck-container/healthcheck.js b/healthcheck-container/healthcheck.js
index 1d6fccb..c4f2dd7 100644
--- a/healthcheck-container/healthcheck.js
+++ b/healthcheck-container/healthcheck.js
@@ -29,14 +29,14 @@ const helmDeps =
'dcae-cloudify-manager',
'dcae-config-binding-service',
'dcae-inventory-api',
- 'dcae-servicechange-handler'
+ 'dcae-servicechange-handler',
+ 'dcae-deployment-handler',
+ 'dcae-policy-handler'
];
// List of deployments expected to be created by CM at boot time
const bootDeps =
[
- 'dep-deployment-handler',
- 'dep-policy-handler',
'dep-dcae-ves-collector',
'dep-dcae-tca-analytics',
'dep-dcae-prh',
diff --git a/healthcheck-container/package.json b/healthcheck-container/package.json
index 31f1493..cc20578 100644
--- a/healthcheck-container/package.json
+++ b/healthcheck-container/package.json
@@ -1,7 +1,7 @@
{
"name": "k8s-healthcheck",
"description": "DCAE healthcheck server",
- "version": "1.2.2",
+ "version": "1.2.4",
"main": "healthcheck.js",
"author": "author",
"license": "(Apache-2.0)"
diff --git a/healthcheck-container/pom.xml b/healthcheck-container/pom.xml
index e728a66..abc7965 100644
--- a/healthcheck-container/pom.xml
+++ b/healthcheck-container/pom.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
================================================================================
-Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (c) 2018-2019 AT&T Intellectual Property. 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.
@@ -27,7 +27,7 @@ limitations under the License.
<groupId>org.onap.dcaegen2.deployments</groupId>
<artifactId>healthcheck-container</artifactId>
<name>dcaegen2-deployments-healthcheck-container</name>
- <version>1.2.3</version>
+ <version>1.2.4</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/k8s-bootstrap-container/bootstrap.sh b/k8s-bootstrap-container/bootstrap.sh
index 76504a7..0c55559 100755
--- a/k8s-bootstrap-container/bootstrap.sh
+++ b/k8s-bootstrap-container/bootstrap.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# ================================================================================
-# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018-2019 AT&T Intellectual Property. 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.
@@ -123,15 +123,8 @@ set -e
# Consul service registration data
CBS_REG='{"ID": "dcae-cbs0", "Name": "config_binding_service", "Address": "config-binding-service", "Port": 10000}'
CBS_REG1='{"ID": "dcae-cbs1", "Name": "config-binding-service", "Address": "config-binding-service", "Port": 10000}'
-INV_REG='{"ID": "dcae-inv0", "Name": "inventory", "Address": "inventory", "Port": 8080}'
HE_REG='{"ID": "dcae-he0", "Name": "holmes-engine-mgmt", "Address": "holmes-engine-mgmt", "Port": 9102}'
HR_REG='{"ID": "dcae-hr0", "Name": "holmes-rule-mgmt", "Address": "holmes-rule-mgmt", "Port": 9101}'
-
-# Cloudify Manager will always be in the ONAP namespace.
-CM_REG='{"ID": "dcae-cm0", "Name": "cloudify_manager", "Port": 80, "Address": "dcae-cloudify-manager.'${ONAP_NAMESPACE}'"}'
-# Policy handler will be looked up from a plugin on CM. If DCAE components are running in a different k8s
-# namespace than CM (which always runs in the common ONAP namespace), then the policy handler address must
-# be qualified with the DCAE namespace.
PH_REG='{"ID": "dcae-ph0", "Name": "policy_handler", "Port": 25577, "Address": "policy-handler'
if [ ! -z "${DCAE_NAMESPACE}" ]
then
@@ -139,8 +132,6 @@ then
fi
PH_REG="${PH_REG}\"}"
-
-
# Set up profile to access Cloudify Manager
cfy profiles use -u admin -t default_tenant -p "${CMPASS}" "${CMADDR}"
@@ -178,7 +169,7 @@ do
done
# Put service registrations into the local Consul configuration directory
-for sr in CBS_REG CBS_REG1 INV_REG HE_REG HR_REG CM_REG PH_REG
+for sr in CBS_REG CBS_REG1 HE_REG HR_REG PH_REG
do
echo '{"service" : ' ${!sr} ' }'> /opt/consul/config/${sr}.json
done
@@ -204,13 +195,6 @@ set +e
deploy pgaas_initdb k8s-pgaas-initdb.yaml k8s-pgaas-initdb-inputs.yaml &
PG_PID=$!
wait ${PG_PID}
-# deployment_handler and policy_handler can be deployed simultaneously
-INV_PID=$!
-deploy deployment_handler k8s-deployment_handler.yaml k8s-deployment_handler-inputs.yaml &
-DH_PID=$!
-deploy policy_handler k8s-policy_handler.yaml k8s-policy_handler-inputs.yaml&
-PH_PID=$!
-wait ${INV_PID} ${DH_PID} ${PH_PID}
# Deploy service components
# tca, ves, prh, hv-ves, datafile-collector can be deployed simultaneously
diff --git a/k8s-bootstrap-container/load-blueprints.sh b/k8s-bootstrap-container/load-blueprints.sh
index 098c022..e42a72e 100755
--- a/k8s-bootstrap-container/load-blueprints.sh
+++ b/k8s-bootstrap-container/load-blueprints.sh
@@ -1,4 +1,19 @@
#!/bin/bash
+# ================================================================================
+# Copyright (c) 2018-2019 AT&T Intellectual Property. 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=========================================================
# Load DCAE blueprints/inputs onto container
# $1 Blueprint repo base URL
# Expect blueprints to be at <base URL>/blueprints
@@ -7,10 +22,8 @@ set -x
BLUEPRINTS=\
"
-k8s-deployment_handler.yaml \
k8s-holmes-engine.yaml \
k8s-holmes-rules.yaml \
-k8s-policy_handler.yaml \
k8s-pgaas-initdb.yaml \
k8s-tca.yaml \
k8s-ves.yaml \
diff --git a/k8s-bootstrap-container/pom.xml b/k8s-bootstrap-container/pom.xml
index bfcbdd2..c1eb884 100644
--- a/k8s-bootstrap-container/pom.xml
+++ b/k8s-bootstrap-container/pom.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
================================================================================
-Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (c) 2018-2019 AT&T Intellectual Property. 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.
@@ -27,7 +27,7 @@ limitations under the License.
<groupId>org.onap.dcaegen2.deployments</groupId>
<artifactId>k8s-bootstrap-container</artifactId>
<name>dcaegen2-deployments-k8s-bootstrap-container</name>
- <version>1.4.8</version>
+ <version>1.4.9</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/pom.xml b/pom.xml
index 17109c4..f05745d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
org.onap.dcae
================================================================================
-Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
@@ -43,6 +43,7 @@ limitations under the License.
<module>tca-cdap-container</module>
<module>healthcheck-container</module>
<module>tls-init-container</module>
+ <module>consul-loader-container</module>
</modules>
<profiles>
<profile>
@@ -97,7 +98,7 @@ limitations under the License.
</configuration>
</plugin>
<!-- first disable the default Java plugins at various stages -->
- <!-- maven-resources-plugin is called during "*resource" phases by default behavior. it prepares
+ <!-- maven-resources-plugin is called during "*resource" phases by default behavior. it prepares
the resources dir. we do not need it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -128,7 +129,7 @@ limitations under the License.
</execution>
</executions>
</plugin>
- <!-- maven-install-plugin is called during "install" phase by default behavior. it tries to copy stuff under
+ <!-- maven-install-plugin is called during "install" phase by default behavior. it tries to copy stuff under
target dir to ~/.m2. we do not need it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>