From 4c3a15fd4f628d096fcd1b39dbeecd8bfb9f0450 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Fri, 12 Jun 2015 17:06:53 -0700 Subject: [PATCH] make the nodeport scipt work for local cluster --- examples/k8petstore/k8petstore-nodeport.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/k8petstore/k8petstore-nodeport.sh b/examples/k8petstore/k8petstore-nodeport.sh index 966de7c3303..2709449dffc 100755 --- a/examples/k8petstore/k8petstore-nodeport.sh +++ b/examples/k8petstore/k8petstore-nodeport.sh @@ -232,8 +232,11 @@ $kubectl create -f bps-load-gen-rc.json --namespace=$NS #Get the IP addresses of all Kubernetes nodes. function getIP { #currently this script is only tested on GCE. The following line may need to be updated if k8s is not running on a cloud platform - NODES_IP=$($kubectl get nodes -t='{{range .items}}{{range .status.addresses}}{{if eq .type "ExternalIP"}}{{.address}}{{print "\n"}}{{end}}{{end}}{{end}}') + NODES_IP=$($kubectl get nodes -t='{{range .items}}{{range .status.addresses}}{{if or (eq .type "ExternalIP") (eq .type "LegacyHostIP")}}{{.address}}{{print "\n"}}{{end}}{{end}}{{end}}') TEST_IP=$($kubectl get nodes -t='{{range (index .items 0).status.addresses}}{{if eq .type "ExternalIP"}}{{.address}}{{end}}{{end}}') + if [ -z "$TEST_IP" ]; then + TEST_IP=$($kubectl get nodes -t='{{range (index .items 0).status.addresses}}{{if eq .type "LegacyHostIP"}}{{.address}}{{end}}{{end}}') + fi if [ -z "$NODES_IP" ]; then echo "Error: Can't get node's IP!!!" exit 1