Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions hot/ubuntu-14.04/kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down