diff --git a/examples/k8petstore/README.md b/examples/k8petstore/README.md index 2a5337ebb27..54605f600be 100644 --- a/examples/k8petstore/README.md +++ b/examples/k8petstore/README.md @@ -132,7 +132,7 @@ Now that you are done hacking around on the app, you can run it in Kubernetes. Now, how to run the entire application in Kubernetes? -To simplify running this application, we have a single file, k8petstore.sh, which writes out json files on to disk. This allows us to have dynamic parameters, without needing to worry about managing multiple json files. +To simplify running this application, we have a single file, [k8petstore.sh](k8petstore.sh), which writes out json files on to disk. This allows us to have dynamic parameters, e.g. the namespace is configured by `NS` whose default value is `k8petstore`, without needing to worry about managing multiple json files. You might want to change it to point to your customized Go image, if you chose to modify things, like the number of data generators (more generators will create more load on the redis master). diff --git a/examples/k8petstore/k8petstore-loadbalancer.sh b/examples/k8petstore/k8petstore-loadbalancer.sh index 5e8e4d09c95..8eb07e79596 100755 --- a/examples/k8petstore/k8petstore-loadbalancer.sh +++ b/examples/k8petstore/k8petstore-loadbalancer.sh @@ -28,7 +28,7 @@ FE="1" # amount of Web server LG="1" # amount of load generators SLAVE="1" # amount of redis slaves TEST="1" # 0 = Don't run tests, 1 = Do run tests. -NS="default" # namespace +NS="k8petstore" # namespace kubectl="${1:-$kubectl}" VERSION="${2:-$VERSION}" @@ -40,6 +40,30 @@ TEST="${7:-$TEST}" # 0 = Don't run tests, 1 = Do run tests. NS="${8:-$NS}" # namespace echo "Running w/ args: kubectl $kubectl version $VERSION sec $_SECONDS fe $FE lg $LG slave $SLAVE test $TEST NAMESPACE $NS" + +function create_ns { + +case "$NS" in +"default" ) + ;; +"kube-system" ) + ;; +* ) +cat << EOF > ns.json +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "name": "$NS" + } +} +EOF + +$kubectl create -f ns.json + +esac +} + function create { cat << EOF > fe-rc.json @@ -216,6 +240,9 @@ cat << EOF > slave-rc.json } } EOF + +create_ns + $kubectl create -f rm.json --namespace=$NS $kubectl create -f rm-s.json --namespace=$NS sleep 3 # precaution to prevent fe from spinning up too soon. diff --git a/examples/k8petstore/k8petstore-nodeport.sh b/examples/k8petstore/k8petstore-nodeport.sh index 2a4dd809696..73a0ba340ed 100755 --- a/examples/k8petstore/k8petstore-nodeport.sh +++ b/examples/k8petstore/k8petstore-nodeport.sh @@ -29,7 +29,7 @@ FE="1" # amount of Web server LG="1" # amount of load generators SLAVE="1" # amount of redis slaves TEST="1" # 0 = Don't run tests, 1 = Do run tests. -NS="default" # namespace +NS="k8petstore" # namespace NODE_PORT=30291 #nodePort, see fe-s.json kubectl="${1:-$kubectl}" @@ -42,6 +42,30 @@ TEST="${7:-$TEST}" # 0 = Don't run tests, 1 = Do run tests. NS="${8:-$NS}" # namespace NODE_PORT="${9:-$NODE_PORT}" #nodePort, see fe-s.json echo "Running w/ args: kubectl $kubectl version $VERSION sec $_SECONDS fe $FE lg $LG slave $SLAVE test = $TEST, NAMESPACE = $NS, NODE_PORT = $NODE_PORT" + +function create_ns { + +case "$NS" in +"default" ) + ;; +"kube-system" ) + ;; +* ) +cat << EOF > ns.json +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "name": "$NS" + } +} +EOF + +$kubectl create -f ns.json + +esac +} + function create { cat << EOF > fe-rc.json @@ -219,6 +243,9 @@ cat << EOF > slave-rc.json } } EOF + +create_ns + $kubectl create -f rm.json --namespace=$NS $kubectl create -f rm-s.json --namespace=$NS sleep 3 # precaution to prevent fe from spinning up too soon. diff --git a/examples/k8petstore/k8petstore.sh b/examples/k8petstore/k8petstore.sh index 633cd2a2472..c5215775e58 100755 --- a/examples/k8petstore/k8petstore.sh +++ b/examples/k8petstore/k8petstore.sh @@ -29,7 +29,7 @@ FE="1" # amount of Web server LG="1" # amount of load generators SLAVE="1" # amount of redis slaves TEST="1" # 0 = Don't run tests, 1 = Do run tests. -NS="default" # namespace +NS="k8petstore" # namespace kubectl="${1:-$kubectl}" VERSION="${2:-$VERSION}" @@ -42,6 +42,30 @@ TEST="${8:-$TEST}" # 0 = Don't run tests, 1 = Do run tests. NS="${9:-$NS}" # namespace echo "Running w/ args: kubectl $kubectl version $VERSION ip $PUBLIC_IP sec $_SECONDS fe $FE lg $LG slave $SLAVE test $TEST NAMESPACE $NS" + +function create_ns { + +case "$NS" in +"default" ) + ;; +"kube-system" ) + ;; +* ) +cat << EOF > ns.json +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "name": "$NS" + } +} +EOF + +$kubectl create -f ns.json + +esac +} + function create { cat << EOF > fe-rc.json @@ -218,6 +242,9 @@ cat << EOF > slave-rc.json } } EOF + +create_ns + $kubectl create -f rm.json --namespace=$NS $kubectl create -f rm-s.json --namespace=$NS sleep 3 # precaution to prevent fe from spinning up too soon.