#!/bin/bash # # Use this script to deploy an entire stack on Kubernetes: # - etcd cluster # - px daemonset # - influxdb on pvc # - Lighthouse # # Assumes running instance of Kubernetes 1.6 or above # # Note: Lots of timing issues that will go away once etcd-operator is in better shape # # Can't assume 'kubectl' is running on master, so need an IP to check liveliness of Lighthouse MASTER_IP=`kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}' | awk '{print $1}'` if [ -z "$MASTER_IP" ] then MASTER_IP=`kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' | awk '{print $1}'` fi # Adjust for CoreOS if needed if kubectl describe nodes | grep 'OS Image' | grep -i CoreOS > /dev/null then HEADERS=/lib/modules else HEADERS=/usr/src fi # Configure PX interfaces. # Default to cni0, or override. DIFACE=cni0 MIFACE=cni0 ####################################### function waitfor() { while true do if kubectl get $1 2>&1 | egrep 'No resources found|the server doesn.t have a resource type' then echo "Waiting for $1 ..." sleep 5 else break fi done } function waitfor_lighthouse() { while true do if ! kubectl get pod | grep px-lighthouse | grep Running > /dev/null then echo "Waiting for px-lighthouse startup ..." sleep 10 else if ! curl -X GET -H "Accept:application/json" -H "Authorization:Basic $AUTHKEY" http://${MASTER_IP}:30062 > /dev/null 2>&1 then echo "Waiting for px-lighthouse responsiveness ..." sleep 10 continue else echo "Lighthouse is running ..." break fi fi done } try_etcd() { cat <