summaryrefslogtreecommitdiffstats
path: root/kubernetes
diff options
context:
space:
mode:
authorMike Elliott <mike.elliott@amdocs.com>2017-08-14 16:21:40 -0400
committerMike Elliott <mike.elliott@amdocs.com>2017-08-15 08:09:33 -0400
commitd17accd32f4f7851dbe7b023f1997aa4e17938e8 (patch)
treea0add5147ff2e3a2da78c8117d237bcdb656758d /kubernetes
parent8fc4b23407fa42cde4c592491824e48c564245a1 (diff)
[OOM-117] Multiple ONAP instances same K8s cluster
Change-Id: Ie670dd37da819b33e32885d3be20cc8739fc2524 Signed-off-by: Mike Elliott <mike.elliott@amdocs.com>
Diffstat (limited to 'kubernetes')
-rw-r--r--kubernetes/README.md31
-rw-r--r--kubernetes/config/createConfig.sh47
-rwxr-xr-xkubernetes/config/docker/init/config-init.sh45
-rw-r--r--kubernetes/config/pod-config-init.yaml4
-rwxr-xr-xkubernetes/oneclick/createAll.bash35
5 files changed, 133 insertions, 29 deletions
diff --git a/kubernetes/README.md b/kubernetes/README.md
index 73339bf152..4760d9ec0d 100644
--- a/kubernetes/README.md
+++ b/kubernetes/README.md
@@ -2,3 +2,34 @@ ONAP on Kubernetes
====================
Under construction...
+
+
+Creating an ONAP deployment instance requires creating base configuration on the
+host node and then deploying the runtime containers.
+
+The following is an example of creating the first deployed instance in a K8s
+cluster. The name given to the instance is 'dev1'. This will serve as the
+Namespace prefix for each deployed ONAP component (ie. dev1-mso).
+
+ 1. oom/kubernetes/config/createConfig.sh -n dev1
+
+ 2. oom/kubernetes/oneclick/createAll.bash -n dev1
+
+To delete the runtime containers for the deployed instance, use the following:
+
+ 3. oom/kubernetes/oneclick/deleteAll.bash -n dev1
+
+Note that deleting the runtime containers does not remove the configuration
+created in step 1.
+
+
+To deploy more than one ONAP instance within the same Kubernetes cluster, you
+will need to specify an Instance number. This is currently required due to the
+use of NodePort ranges. NodePorts allow external IP:Port access to containers
+that are running inside a Kubernetes cluster.
+
+Example if this is the 2 instance of an ONAP deployment in the cluster:
+
+ 1. oom/kubernetes/config/createConfig.sh -n test
+
+ 2. oom/kubernetes/oneclick/createAll.bash -n test -i 2
diff --git a/kubernetes/config/createConfig.sh b/kubernetes/config/createConfig.sh
new file mode 100644
index 0000000000..f226ccae47
--- /dev/null
+++ b/kubernetes/config/createConfig.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+usage() {
+ cat <<EOF
+Usage: $0 [PARAMs]
+-u : Display usage
+-n [NAMESPACE] : Kubernetes namespace (required)
+EOF
+}
+
+create_namespace() {
+ kubectl create namespace $1
+}
+
+create_configuration() {
+ create_namespace $1
+ kubectl --namespace $1 create -f pod-config-init.yaml
+}
+
+#MAINs
+NS=
+
+while getopts ":n:u:" PARAM; do
+ case $PARAM in
+ u)
+ usage
+ exit 1
+ ;;
+ n)
+ NS=${OPTARG}
+ ;;
+ ?)
+ usage
+ exit
+ ;;
+ esac
+done
+
+if [[ -z $NS ]]; then
+ usage
+ exit 1
+fi
+
+printf "\n**** Creating configuration for ONAP instance: $NS\n"
+create_configuration $NS
+
+printf "**** Done ****\n"
diff --git a/kubernetes/config/docker/init/config-init.sh b/kubernetes/config/docker/init/config-init.sh
index bf0e644b6f..f751f4d1ca 100755
--- a/kubernetes/config/docker/init/config-init.sh
+++ b/kubernetes/config/docker/init/config-init.sh
@@ -1,26 +1,29 @@
#!/bin/bash
-#make owner directory
-mkdir -p /config-init/$OWNER/
+#make NAMESPACE directory
+mkdir -p /config-init/$NAMESPACE/
-#unzip the configs in the owners directory ensuring no overwriting of files
-cp -vnpr /opt/config/src/* /config-init/$OWNER/
+#unzip the configs in the NAMESPACEs directory ensuring no overwriting of files
+cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/
#ensure db directories exist.
-mkdir -p /config-init/$OWNER/appc/data/
-mkdir -p /config-init/$OWNER/dcae/pgaas/pgdata/
-mkdir -p /config-init/$OWNER/portal/mariadb/data/
-mkdir -p /config-init/$OWNER/sdnc/data/
-mkdir -p /config-init/$OWNER/vid/mariadb/data/
-mkdir -p /config-init/$OWNER/sdc/sdc-cs/CS/
-mkdir -p /config-init/$OWNER/sdc/sdc-es/ES/
-mkdir -p /config-init/$OWNER/sdc/logs/ASDC/ASDC-ES/
-mkdir -p /config-init/$OWNER/sdc/logs/ASDC/ASDC-CS/
-mkdir -p /config-init/$OWNER/sdc/logs/ASDC/ASDC-KB/
-mkdir -p /config-init/$OWNER/sdc/logs/ASDC/ASDC-BE/
-mkdir -p /config-init/$OWNER/sdc/logs/ASDC/ASDC-FE/
-mkdir -p /config-init/$OWNER/aai/opt/aai/logroot/
+mkdir -p /config-init/$NAMESPACE/appc/data/
+mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/
+mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/
+mkdir -p /config-init/$NAMESPACE/sdnc/data/
+mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/
+mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/
+mkdir -p /config-init/$NAMESPACE/sdc/sdc-es/ES/
+mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/
+mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/
+mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/
+mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/
+mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/
+mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/
-chmod -R 777 /config-init/$OWNER/sdc/logs/
-chmod -R 777 /config-init/$OWNER/aai/aai-config/
-chmod -R 777 /config-init/$OWNER/aai/aai-data/
-chmod -R 777 /config-init/$OWNER/aai/opt/aai/logroot/
+chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
+chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
+chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
+chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
+
+# replace the default 'onap' namespace qualification of K8s hostnames within the config files
+find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/onap-/$NAMESPACE-/g" {} \;
diff --git a/kubernetes/config/pod-config-init.yaml b/kubernetes/config/pod-config-init.yaml
index 858e88714b..372694ebe6 100644
--- a/kubernetes/config/pod-config-init.yaml
+++ b/kubernetes/config/pod-config-init.yaml
@@ -10,9 +10,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- - name: OWNER
- value: onapdemo
- image: oomk8s/config-init:1.0.0
+ image: oomk8s/config-init:1.0.1
imagePullPolicy: Always
volumeMounts:
- name: config-init-root
diff --git a/kubernetes/oneclick/createAll.bash b/kubernetes/oneclick/createAll.bash
index bc211eeb47..5e5f2dc76e 100755
--- a/kubernetes/oneclick/createAll.bash
+++ b/kubernetes/oneclick/createAll.bash
@@ -31,6 +31,28 @@ create_service() {
mv ../$2/all-services.yaml-- ../$2/all-services.yaml
}
+configure_app() {
+ # if previous configuration exists put back original template file
+ for file in ../$2/*.yaml; do
+ if [ -e "$file-template" ]; then
+ mv "$file-template" "${file%}"
+ fi
+ done
+
+ # replace the default 'onap' namespace qualification of K8s hostnames within
+ # the config files
+ # note: this will create a '-template' file within the component's directory
+ # this is not ideal and should be addressed (along with the replacement
+ # of sed commands for configuration) by the future configuration
+ # user stories (ie. OOM-51 to OOM-53)
+ find ../$2 -type f -exec sed -i -template "s/onap-/$1-/g" {} \;
+
+ # replace the default '/dockerdata-nfs/onapdemo' volume mount paths
+ find ../$2 -iname "*.yaml" -type f -exec sed -i -e 's/dockerdata-nfs\/[a-zA-Z0-9\\-]*\//dockerdata-nfs\/'"$1"'\//g' {} \;
+ rm -f ../$2/*.yaml-e
+}
+
+
#MAINs
NS=
INCL_SVC=true
@@ -98,23 +120,26 @@ if [[ "$INCL_SVC" == true ]]; then
fi
-printf "\n********** Creating up ONAP: ${ONAP_APPS[*]}\n"
+printf "\n********** Creating ONAP: ${ONAP_APPS[*]}\n"
for i in ${ONAP_APPS[@]}; do
- printf "\nCreating namespaces **********\n"
+ printf "\nCreating namespace **********\n"
create_namespace $NS $i
+ printf "\nCreating registry secret **********\n"
+ create_registry_key $NS $i $ONAP_DOCKER_REGISTRY_KEY $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
+
if [[ "$INCL_SVC" == true ]]; then
- printf "\nCreating services **********\n"
+ printf "\nCreating service **********\n"
create_service $NS $i $start $end
fi
printf "\n"
done
-printf "\n\n********** Creating deployments for ${ONAP_APPS[*]} ********** \n"
+printf "\n\n********** Creating deployments for ${ONAP_APPS[*]} ********** \n"
for i in ${ONAP_APPS[@]}; do
- create_registry_key $NS $i $ONAP_DOCKER_REGISTRY_KEY $ONAP_DOCKER_REGISTRY $DU $DP $ONAP_DOCKER_MAIL
+ configure_app $NS $i
/bin/bash $i.sh $NS $i 'create'
done