summaryrefslogtreecommitdiffstats
path: root/tools/cloudify/k8s-cloudify.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/cloudify/k8s-cloudify.sh')
-rw-r--r--tools/cloudify/k8s-cloudify.sh33
1 files changed, 18 insertions, 15 deletions
diff --git a/tools/cloudify/k8s-cloudify.sh b/tools/cloudify/k8s-cloudify.sh
index bff85e4..cf6de93 100644
--- a/tools/cloudify/k8s-cloudify.sh
+++ b/tools/cloudify/k8s-cloudify.sh
@@ -9,23 +9,25 @@
#
# 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.
#
#. What this is: Setup script for Cloudify use with Kubernetes.
#. Prerequisites:
-#. - Kubernetes cluster installed per k8s-cluster.sh (in this repo)
+#. - OPNFV Models repo cloned into ~/models, i.e.
+#. git clone https://gerrit.opnfv.org/gerrit/models ~/models
+#. - Kubernetes cluster installed per tools/kubernetes/demo_deploy.sh and
+#. environment setup file ~/models/tools/k8s_env.sh as setup by demo_deploy.sh
#. Usage:
#. From a server with access to the kubernetes master node:
-#. $ git clone https://gerrit.opnfv.org/gerrit/models ~/models
-#. $ scp -r ~/models/tools/cloudify ubuntu@<k8s-master>:/home/ubuntu/.
+#. $ cd ~/models/tools/cloudify
+#. $ scp -r ~/models/tools/* ubuntu@<k8s-master>:/home/ubuntu/.
#. <k8s-master>: IP or hostname of kubernetes master server
#. $ ssh -x ubuntu@<k8s-master> cloudify/k8s-cloudify.sh prereqs
#. prereqs: installs prerequisites and configures ubuntu user for kvm use
#. $ ssh -x ubuntu@<k8s-master> bash cloudify/k8s-cloudify.sh setup
#. setup: installs cloudify CLI and Manager
-#. $ bash k8s-cloudify.sh demo <start|stop> <k8s-master>
+#. $ bash k8s-cloudify.sh demo <start|stop>
#. demo: control demo blueprint
#. start|stop: start or stop the demo
#. <k8s-master>: IP or hostname of kubernetes master server
@@ -51,8 +53,7 @@ function fail() {
function log() {
f=$(caller 0 | awk '{print $2}')
l=$(caller 0 | awk '{print $1}')
- echo ""
- echo "$f:$l ($(date)) $1"
+ echo; echo "$f:$l ($(date)) $1"
}
function prereqs() {
@@ -141,6 +142,7 @@ function setup () {
HOST_IP=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
# Forward host port 80 to VM
+ log "Setip iptables to forward $HOST_IP port 80 to Cloudify Manager VM at $VM_IP"
sudo iptables -t nat -I PREROUTING -p tcp -d $HOST_IP --dport 80 -j DNAT --to-destination $VM_IP:80
sudo iptables -I FORWARD -m state -d $VM_IP/32 --state NEW,RELATED,ESTABLISHED -j ACCEPT
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
@@ -159,7 +161,6 @@ function setup () {
function service_port() {
name=$1
- manager_ip=$2
tries=6
port="null"
while [[ "$port" == "null" && $tries -gt 0 ]]; do
@@ -177,7 +178,7 @@ function service_port() {
sleep 10
((tries--))
done
- if [[ "$port" == "" ]]; then
+ if [[ "$port" == "null" ]]; then
jq -r '.items' /tmp/json
fail "node_port not found for service"
fi
@@ -186,7 +187,6 @@ function service_port() {
function start() {
name=$1
bp=$2
- manager_ip=$3
log "start app $name with blueprint $bp"
log "copy kube config from k8s master for insertion into blueprint"
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
@@ -235,7 +235,7 @@ function start() {
function stop() {
name=$1
bp=$2
- manager_ip=$3
+
# TODO: fix the need for this workaround
log "try to first cancel all current executions"
curl -s -u admin:admin --header 'Tenant: default_tenant' \
@@ -282,6 +282,7 @@ function stop() {
-d "{\"deployment_id\":\"$bp\", \"workflow_id\":\"uninstall\"}" \
-o /tmp/json http://$manager_ip/api/v3.1/executions
id=$(jq -r ".id" /tmp/json)
+ log "uninstall execution id = $id"
status=""
tries=1
while [[ "$status" != "terminated" && $tries -lt 10 ]]; do
@@ -354,7 +355,6 @@ function demo() {
# echo "master-port: $(grep server ~/.kube/config | awk -F '/' '{print $3}' | awk -F ':' '{print $2}')" >>~/cloudify/blueprints/k8s-hello-world/inputs.yaml
# echo "file_content:" >>~/cloudify/blueprints/k8s-hello-world/inputs.yaml
# sed 's/^/ /' ~/.kube/config | tee -a ~/cloudify/blueprints/k8s-hello-world/inputs.yaml
- manager_ip=$2
cd ~/models/tools/cloudify/blueprints
if [[ "$1" == "start" ]]; then
@@ -376,6 +376,9 @@ function clean () {
}
dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
+source ~/k8s_env.sh
+manager_ip=$k8s_master
+
case "$1" in
"prereqs")
prereqs
@@ -387,13 +390,13 @@ case "$1" in
demo $2 $3
;;
"start")
- start $2 $3 $4
+ start $2 $3
;;
"stop")
- stop $2 $3 $4
+ stop $2 $3
;;
"port")
- service_port $2 $3
+ service_port $2
;;
"clean")
clean