Updated k8spetstore to use non-default namespace.

This commit is contained in:
Klaus Ma 2016-08-17 23:09:12 +08:00
parent 8675adf138
commit aeb908865d
4 changed files with 85 additions and 4 deletions

View File

@ -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).

View File

@ -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.

View File

@ -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.

View File

@ -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.