summaryrefslogtreecommitdiffstats
path: root/k8s-bootstrap-container
diff options
context:
space:
mode:
Diffstat (limited to 'k8s-bootstrap-container')
-rw-r--r--k8s-bootstrap-container/.gitignore4
-rw-r--r--k8s-bootstrap-container/Dockerfile-template49
-rw-r--r--k8s-bootstrap-container/README.md20
-rwxr-xr-xk8s-bootstrap-container/bootstrap.sh40
-rwxr-xr-xk8s-bootstrap-container/build-plugins.sh75
-rwxr-xr-xk8s-bootstrap-container/load-blueprints.sh23
-rw-r--r--k8s-bootstrap-container/pom.xml172
-rwxr-xr-xk8s-bootstrap-container/test-expand.sh6
8 files changed, 389 insertions, 0 deletions
diff --git a/k8s-bootstrap-container/.gitignore b/k8s-bootstrap-container/.gitignore
new file mode 100644
index 0000000..d615c60
--- /dev/null
+++ b/k8s-bootstrap-container/.gitignore
@@ -0,0 +1,4 @@
+.project
+Dockerfile
+.vscode/
+bootstrap-container.code-workspace
diff --git a/k8s-bootstrap-container/Dockerfile-template b/k8s-bootstrap-container/Dockerfile-template
new file mode 100644
index 0000000..300a9f6
--- /dev/null
+++ b/k8s-bootstrap-container/Dockerfile-template
@@ -0,0 +1,49 @@
+# ============LICENSE_START=======================================================
+# org.onap.dcae
+# ================================================================================
+# Copyright (c) 2018 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=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+FROM centos:7.4.1708
+LABEL maintainer="maintainer"
+
+ENV DCAE_REPO {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}
+ENV CCSDK_REPO {{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}
+ENV BP_REPO {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}
+
+# Install gcc
+RUN yum install -y gcc python-devel
+
+# Install pip
+RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
+ && python get-pip.py \
+ && rm get-pip.py \
+ && pip install cloudify==17.11.22
+
+# Get plugin archives and build wagons
+RUN mkdir scripts
+COPY build-plugins.sh scripts
+RUN scripts/build-plugins.sh ${DCAE_REPO} ${CCSDK_REPO} \
+ && rm scripts/build-plugins.sh
+
+# Load blueprints and input templates
+COPY load-blueprints.sh scripts
+RUN scripts/load-blueprints.sh ${BP_REPO} \
+ && rm scripts/load-blueprints.sh
+
+# Set up runtime script
+COPY bootstrap.sh scripts
+ENTRYPOINT exec "/scripts/bootstrap.sh" \ No newline at end of file
diff --git a/k8s-bootstrap-container/README.md b/k8s-bootstrap-container/README.md
new file mode 100644
index 0000000..614669b
--- /dev/null
+++ b/k8s-bootstrap-container/README.md
@@ -0,0 +1,20 @@
+# DCAE Bootstrap Container
+This container is responsible for loading plugins and wagons onto the
+DCAE Cloudify Manager instance and for launching DCAE components.
+
+The script builds plugins and loads blueprints for the DCAE components
+to be deployed into the container image
+at image build time. At run time, the main script in the container
+(`bootstrap.sh`) uploads the plugins to Cloudify Manager, then installs
+components using the blueprints.
+
+The container expects to be started with two environment variables:
+ - `CMADDR` -- the address of the target Cloudify Manager
+ - `CMPASS` -- the password for Cloudify Manager
+
+The container expects input files to use when deploying the blueprints.
+It expects to find them in /inputs. The normal method for launching
+the container is via a Helm Chart launched by OOM. That chart creates
+a Kubernetes ConfigMap containing the input files. The ConfigMap is
+mounted as a volume at /inputs.
+
diff --git a/k8s-bootstrap-container/bootstrap.sh b/k8s-bootstrap-container/bootstrap.sh
new file mode 100755
index 0000000..38da261
--- /dev/null
+++ b/k8s-bootstrap-container/bootstrap.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# Install DCAE via Cloudify Manager
+# Expects:
+# CM address (IP or DNS) in CMADDR environment variable
+# CM password in CMPASS environment variable (assumes user is "admin")
+# Plugin wagon files in /wagons
+
+set -x
+
+# Deploy components
+# $1 -- name (for bp and deployment)
+# $2 -- blueprint name
+# $3 -- inputs file name
+function deploy {
+ cfy install -b $1 -d $1 -i /inputs/$3 /blueprints/$2
+}
+# Set up profile to access CMs
+cfy profiles use -u admin -t default_tenant -p "${CMPASS}" "${CMADDR}"
+
+# Output status, for debugging purposes
+cfy status
+
+# Load plugins onto CM
+for wagon in /wagons/*.wgn
+do
+ cfy plugins upload ${wagon}
+done
+
+# Deploy platform components
+deploy config_binding_service k8s-config_binding_service.yaml k8s-config_binding_service-inputs.yaml
+deploy inventory k8s-inventory.yaml k8s-inventory-inputs.yaml
+deploy deployment_handler k8s-deployment_handler.yaml k8s-deployment_handler-inputs.yaml
+deploy policy_handler k8s-policy_handler.yaml k8s-policy_handler-inputs.yaml
+
+# Keep the container running
+# Useful to exec into it for debugging and uninstallation
+while true
+do
+ sleep 120
+done \ No newline at end of file
diff --git a/k8s-bootstrap-container/build-plugins.sh b/k8s-bootstrap-container/build-plugins.sh
new file mode 100755
index 0000000..9055194
--- /dev/null
+++ b/k8s-bootstrap-container/build-plugins.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+# ============LICENSE_START=======================================================
+# org.onap.dcae
+# ================================================================================
+# Copyright (c) 2018 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=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+
+# Pull plugin archives from repos
+# Build wagons
+# $1 is the DCAE repo URL
+# $2 is the CCSDK repo URL
+# (This script runs at Docker image build time)
+#
+set -x
+DEST=wagons
+
+# For DCAE, we get zips of the archives and build wagons
+DCAEPLUGINFILES=\
+"\
+k8splugin/1.0.0/k8splugin-1.0.0.tgz
+dcaepolicyplugin/2.1.0/dcaepolicyplugin-2.1.0.tgz \
+"
+
+# For CCSDK, we pull down the wagon files directly
+CCSDKPLUGINFILES=\
+"\
+plugins/pgaas-1.0.0-py27-none-any.wgn
+plugins/sshkeyshare-1.0.0-py27-none-any.wgn
+"
+
+# Build a set of wagon files from archives in a repo
+# $1 -- repo base URL
+# $2 -- list of paths to archive files in the repo
+function build {
+ for plugin in $2
+ do
+ # Could just do wagon create with the archive URL as source,
+ # but can't use a requirements file with that approach
+ mkdir work
+ target=$(basename ${plugin})
+ curl -Ss $1/${plugin} > ${target}
+ tar zxvf ${target} --strip-components=2 -C work
+ wagon create -t tar.gz -o ${DEST} -r work/requirements.txt --validate ./work
+ rm -rf work
+ done
+}
+
+# Copy a set of wagons from a repo
+# $1 -- repo baseURL
+# $2 -- list of paths to wagons in the repo
+function get_wagons {
+ for wagon in $2
+ do
+ target=$(basename ${wagon})
+ curl -Ss $1/${wagon} > ${DEST}/${target}
+ done
+}
+
+mkdir ${DEST}
+build $1 "${DCAEPLUGINFILES}"
+get_wagons $2 "${CCSDKPLUGINFILES}" \ No newline at end of file
diff --git a/k8s-bootstrap-container/load-blueprints.sh b/k8s-bootstrap-container/load-blueprints.sh
new file mode 100755
index 0000000..4b7270a
--- /dev/null
+++ b/k8s-bootstrap-container/load-blueprints.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Load DCAE blueprints/inputs onto container
+# $1 Blueprint repo base URL
+# Expect blueprints to be at <base URL>/blueprints
+
+set -x
+
+BLUEPRINTS=\
+"
+k8s-config_binding_service.yaml \
+k8s-deployment_handler.yaml \
+k8s-inventory.yaml \
+k8s-policy_handler.yaml
+"
+
+BPDEST=blueprints
+mkdir ${BPDEST}
+
+# Download blueprints
+for bp in ${BLUEPRINTS}
+do
+ curl -Ss $1/blueprints/${bp} > ${BPDEST}/$(basename ${bp})
+done
diff --git a/k8s-bootstrap-container/pom.xml b/k8s-bootstrap-container/pom.xml
new file mode 100644
index 0000000..6046a9c
--- /dev/null
+++ b/k8s-bootstrap-container/pom.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0"?>
+<!--
+================================================================================
+Copyright (c) 2018 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>k8s-bootstrap-container</artifactId>
+ <name>dcaegen2-deployments-k8s-bootstrap-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/k8s-bootstrap-container/test-expand.sh b/k8s-bootstrap-container/test-expand.sh
new file mode 100755
index 0000000..1e929f5
--- /dev/null
+++ b/k8s-bootstrap-container/test-expand.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+sed \
+ -e 's#{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}#https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2#' \
+ -e 's#{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}#https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins#' \
+ -e 's#{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}#https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.blueprints/R2#' \
+Dockerfile-template > Dockerfile \ No newline at end of file