From c0923a0a0ad2c4e3750fb0d5a308f65c5cf21287 Mon Sep 17 00:00:00 2001 From: Glyn Davies Date: Mon, 26 Sep 2016 11:24:39 +1300 Subject: [PATCH] updated kubernetes example to use new openstack client --- hot/ubuntu-14.04/kubernetes/Makefile | 82 +++++++++---------- .../templates/kubernetes-network.yaml | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/hot/ubuntu-14.04/kubernetes/Makefile b/hot/ubuntu-14.04/kubernetes/Makefile index 7f3dfe6..43894b2 100644 --- a/hot/ubuntu-14.04/kubernetes/Makefile +++ b/hot/ubuntu-14.04/kubernetes/Makefile @@ -2,9 +2,9 @@ KEY_PAIR ?= NETWORK_NAME ?= k8s-network MASTER_NAME ?= k8s-master MINION_NAME ?= k8s-minion -NETWORK_EXISTS = $(shell heat stack-list | grep $(NETWORK_NAME)) -MASTER_EXISTS = $(shell heat stack-list | grep $(MASTER_NAME)) -MINONS_EXIST = $(shell heat stack-list | grep $(MINION_NAME)) +NETWORK_EXISTS = $(shell openstack stack list | grep $(NETWORK_NAME)) +MASTER_EXISTS = $(shell openstack stack list | grep $(MASTER_NAME)) +MINONS_EXIST = $(shell openstack stack list | grep $(MINION_NAME)) START ?= 1 FINISH ?= 3 NUMBERS := $(shell seq $(START) $(FINISH)) @@ -17,109 +17,109 @@ endif all: build clean_minions: - # $(foreach var,$(NUMBERS), heat stack-delete $(MINION_NAME)$(var);) + # $(foreach var,$(NUMBERS), openstack stack delete --yes $(MINION_NAME)$(var);) for MINION in $(NUMBERS) ; \ do \ - MINONS_EXIST=`heat stack-list 2>/dev/null | grep $(MINION_NAME)$${MINION}`; \ + MINONS_EXIST=`openstack stack list 2>/dev/null | grep $(MINION_NAME)$${MINION}`; \ if [ -n "$$MINONS_EXIST" ] ; then \ - heat stack-delete -y $(MINION_NAME)$${MINION}; \ + openstack stack delete --yes $(MINION_NAME)$${MINION}; \ while [ -n "$$MINONS_EXIST" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(MINION_NAME); \ + openstack stack list 2>/dev/null | grep $(MINION_NAME); \ sleep 3; \ - MINONS_EXIST=`heat stack-list 2>/dev/null | grep $(MINION_NAME)$${MINION}` ; \ + MINONS_EXIST=`openstack stack list 2>/dev/null | grep $(MINION_NAME)$${MINION}` ; \ done ; \ fi ; \ done ; true - heat stack-list + openstack stack list clean: clean_minions ifneq "$(strip $(MASTER_EXISTS))" "" - heat stack-delete -y $(MASTER_NAME) - MASTER_EXISTS=`heat stack-list 2>/dev/null | grep $(MASTER_NAME)`; \ + openstack stack delete --yes $(MASTER_NAME) + MASTER_EXISTS=`openstack stack list 2>/dev/null | grep $(MASTER_NAME)`; \ while [ -n "$$MASTER_EXISTS" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(MASTER_NAME); \ + openstack stack list 2>/dev/null | grep $(MASTER_NAME); \ sleep 3; \ - MASTER_EXISTS=`heat stack-list 2>/dev/null | grep $(MASTER_NAME)` ; \ + MASTER_EXISTS=`openstack stack list 2>/dev/null | grep $(MASTER_NAME)` ; \ done ; true - heat stack-list + openstack stack list endif - heat stack-list + openstack stack list clean_network: ifneq "$(strip $(NETWORK_EXISTS))" "" - heat stack-delete $(NETWORK_NAME) - NETWORK_EXISTS=`heat stack-list 2>/dev/null | grep $(NETWORK_NAME)`; \ + openstack stack delete --yes $(NETWORK_NAME) + NETWORK_EXISTS=`openstack stack list 2>/dev/null | grep $(NETWORK_NAME)`; \ while [ -n "$$NETWORK_EXISTS" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(NETWORK_NAME); \ + openstack stack list 2>/dev/null | grep $(NETWORK_NAME); \ sleep 3; \ - NETWORK_EXISTS=`heat stack-list 2>/dev/null | grep $(NETWORK_NAME)` ; \ + NETWORK_EXISTS=`openstack stack list 2>/dev/null | grep $(NETWORK_NAME)` ; \ done ; true - heat stack-list + openstack stack list endif - heat stack-list + openstack stack list realclean: clean clean_network build_network: ifeq "$(strip $(NETWORK_EXISTS))" "" - heat stack-create -f templates/kubernetes-network.yaml -e templates/environment.yaml -P key-pair=$(KEY_PAIR) $(NETWORK_NAME) + openstack stack create -t templates/kubernetes-network.yaml -e templates/environment.yaml --parameter key-pair=$(KEY_PAIR) $(NETWORK_NAME) # wait for 5 seconds so atleast the network is up sleep 5 endif - NETWORK_EXISTS=`heat stack-list 2>/dev/null | grep $(NETWORK_NAME) | grep CREATE_COMPLETE`; \ + NETWORK_EXISTS=`openstack stack list 2>/dev/null | grep $(NETWORK_NAME) | grep CREATE_COMPLETE`; \ while [ -z "$$NETWORK_EXISTS" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(NETWORK_NAME); \ + openstack stack list 2>/dev/null | grep $(NETWORK_NAME); \ sleep 3; \ - NETWORK_EXISTS=`heat stack-list 2>/dev/null | grep $(NETWORK_NAME) | grep CREATE_COMPLETE` ; \ + NETWORK_EXISTS=`openstack stack list 2>/dev/null | grep $(NETWORK_NAME) | grep CREATE_COMPLETE` ; \ done ; true - heat output-show $(NETWORK_NAME) private_net_id + openstack stack output show $(NETWORK_NAME) private_net_id build_master: ifeq "$(strip $(MASTER_EXISTS))" "" - NET_ID=`heat output-show $(NETWORK_NAME) private_net_id | tr -d '"'`; \ - heat stack-create -f templates/kubernetes-master.yaml -e templates/environment.yaml -P key-pair=$(KEY_PAIR) -P private_net_id=$${NET_ID} $(MASTER_NAME) + NET_ID=`openstack network show $(NETWORK_NAME) -c id -f value`; \ + openstack stack create -t templates/kubernetes-master.yaml -e templates/environment.yaml --parameter key-pair=$(KEY_PAIR) --parameter private_net_id=$${NET_ID} $(MASTER_NAME) # wait for 15 seconds so atleast the network is up sleep 15 endif - MASTER_EXISTS=`heat stack-list 2>/dev/null | grep $(MASTER_NAME) | grep CREATE_COMPLETE`; \ + MASTER_EXISTS=`openstack stack list 2>/dev/null | grep $(MASTER_NAME) | grep CREATE_COMPLETE`; \ while [ -z "$$MASTER_EXISTS" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(MASTER_NAME); \ + openstack stack list 2>/dev/null | grep $(MASTER_NAME); \ sleep 3; \ - MASTER_EXISTS=`heat stack-list 2>/dev/null | grep $(MASTER_NAME) | grep CREATE_COMPLETE` ; \ + MASTER_EXISTS=`openstack stack list 2>/dev/null | grep $(MASTER_NAME) | grep CREATE_COMPLETE` ; \ done ; true - heat output-show $(MASTER_NAME) floating_ip + openstack stack output show $(MASTER_NAME) floating_ip build_minions: build_master - # $(foreach var,$(NUMBERS), heat stack-create -f templates/kubernetes-minion.yaml -e templates/environment.yaml $(MINION_NAME)$(var);) - NET_ID=`heat output-show $(NETWORK_NAME) private_net_id | tr -d '"'`; \ + # $(foreach var,$(NUMBERS), openstack stack create -t templates/kubernetes-minion.yaml -e templates/environment.yaml $(MINION_NAME)$(var);) + NET_ID=`openstack network show $(NETWORK_NAME) -c id -f value`; \ echo "Minions to build: $(START)/$(FINISH)/$(NUMBERS)"; \ for MINION in $(NUMBERS) ; \ do \ - MINONS_EXIST=`heat stack-list 2>/dev/null | grep $(MINION_NAME)$${MINION}`; \ + MINONS_EXIST=`openstack stack list 2>/dev/null | grep $(MINION_NAME)$${MINION}`; \ if [ -z "$$MINONS_EXIST" ] ; then \ - heat stack-create -f templates/kubernetes-minion.yaml -e templates/environment.yaml -P key-pair=$(KEY_PAIR) -P private_net_id=$${NET_ID} $(MINION_NAME)$${MINION}; \ + openstack stack create -t templates/kubernetes-minion.yaml -e templates/environment.yaml --parameter key-pair=$(KEY_PAIR) --parameter private_net_id=$${NET_ID} $(MINION_NAME)$${MINION}; \ while [ -z "$$MINONS_EXIST" ] ; \ do \ echo "waiting ..."; \ - heat stack-list 2>/dev/null | grep $(MINION_NAME); \ + openstack stack list 2>/dev/null | grep $(MINION_NAME); \ sleep 3; \ - MINONS_EXIST=`heat stack-list 2>/dev/null | grep $(MINION_NAME)$${MINION} | grep CREATE_COMPLETE` ; \ + MINONS_EXIST=`openstack stack list 2>/dev/null | grep $(MINION_NAME)$${MINION} | grep CREATE_COMPLETE` ; \ done ; \ fi ; \ done ; true - heat stack-list - heat output-show $(MASTER_NAME) floating_ip + openstack stack list + openstack stack output show $(MASTER_NAME) floating_ip build: build_network build_master build_minions @@ -135,7 +135,7 @@ stop_tunnel: build_master start_tunnel: build_master stop_tunnel # "Launch tunnel for 8080 ..." which kubectl || (echo "kubectl command not found in PATH"; exit -1;) - MASTER_IP=`heat output-show $(MASTER_NAME) floating_ip | tr -d '"'`; \ + MASTER_IP=`openstack stack output show $(MASTER_NAME) floating_ip | tr -d '"'`; \ ssh -f -N ubuntu@$${MASTER_IP} -L 8080:localhost:8080 start_dns: build_master diff --git a/hot/ubuntu-14.04/kubernetes/templates/kubernetes-network.yaml b/hot/ubuntu-14.04/kubernetes/templates/kubernetes-network.yaml index 5280337..f813abc 100755 --- a/hot/ubuntu-14.04/kubernetes/templates/kubernetes-network.yaml +++ b/hot/ubuntu-14.04/kubernetes/templates/kubernetes-network.yaml @@ -74,7 +74,7 @@ resources: type: OS::Neutron::Net properties: admin_state_up: true - name: k8s-net + name: k8s-network private_subnet: type: OS::Neutron::Subnet