diff --git a/build/BUILD b/build/BUILD index ff7d2ea9a9..e775dd2a73 100644 --- a/build/BUILD +++ b/build/BUILD @@ -139,7 +139,6 @@ filegroup( "//cmd/kubemark", # TODO: server platforms only "//cmd/linkcheck", "//cmd/mungedocs", - "//examples/k8petstore/web-server/src", "//federation/cmd/genfeddocs", "//test/e2e:e2e.test", "//test/e2e_node:e2e_node.test", # TODO: server platforms only diff --git a/examples/BUILD b/examples/BUILD index 99bd87d7dd..2ce21e4087 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -72,7 +72,6 @@ filegroup( "//examples/explorer:all-srcs", "//examples/guestbook-go:all-srcs", "//examples/https-nginx:all-srcs", - "//examples/k8petstore/web-server/src:all-srcs", "//examples/sharing-clusters:all-srcs", ], tags = ["automanaged"], diff --git a/examples/k8petstore/README.md b/examples/k8petstore/README.md deleted file mode 100644 index 74d839ab55..0000000000 --- a/examples/k8petstore/README.md +++ /dev/null @@ -1,137 +0,0 @@ -## Welcome to k8PetStore - -This is a follow up to the [Guestbook Example](../guestbook/README.md)'s [Go implementation](../guestbook-go/). - -- It leverages the same components (redis, Go REST API) as the guestbook application -- It comes with visualizations for graphing whats happening in Redis transactions, along with commandline printouts of transaction throughput -- It is hackable : you can build all images from the files is in this repository (With the exception of the data generator, which is apache bigtop). -- It generates massive load using a semantically rich, realistic transaction simulator for petstores - -This application will run a web server which returns REDIS records for a petstore application. -It is meant to simulate and test high load on Kubernetes or any other docker based system. - -If you are new to Kubernetes, and you haven't run guestbook yet, - -you might want to stop here and go back and run guestbook app first. - -The guestbook tutorial will teach you a lot about the basics of Kubernetes, and we've tried not to be redundant here. - -## Architecture of this SOA - -A diagram of the overall architecture of this application can be seen in [k8petstore.dot](k8petstore.dot) (you can paste the contents in any graphviz viewer, including online ones such as http://sandbox.kidstrythisathome.com/erdos/. - -## Docker image dependencies - -Reading this section is optional, only if you want to rebuild everything from scratch. - -This project depends on three docker images which you can build for yourself and save -in your dockerhub "dockerhub-name". - -Since these images are already published under other parties like redis, jayunit100, and so on, -so you don't need to build the images to run the app. - -If you do want to build the images, you will need to build and push the images in this repository. - -For a list of those images, see the `build-and-push` shell script - it builds and pushes all the images for you, just - -modify the dockerhub user name in it accordingly. - -## Hacking, extending, and locally testing on the k8petstore - -The web app is written in Go, and borrowed from the original Guestbook example by brendan burns. - -K8petstore is built to be expanded, and aims to attract developers interested in building and maintaining a polyglot, non-trivial kubernetes app as a community. - -It can be a simple way to get started with kubernetes or golang application development. - -Thus we've tried to make it easy to hack on, even without kubernetes. Just run the containers and glue them together using docker IP addresses ! - -We have extended it to do some error reporting, persisting of JSON petstore transactions (not much different then guestbook entries), - -and supporting of additional REST calls, like LLEN, which returns the total # of transactions in the database. - -If that is all working, you can finally run `k8petstore.sh` in any Kubernetes cluster, and run the app at scale. - -### MAC USERS - -To develop against k8petstore, simply run the docker-machine-dev.sh script, which is built for mac users. - -### LINUX USERS - -For now, modify the docker-machine-dev.sh script as necessary to use the provider of your choice. Most linux/docker users are savvy enough to do this easily. - -If you need help, just ask on the mailing list. - -## Set up the data generator (optional) - -The web front end provides users an interface for watching pet store transactions in real time as they occur. - -To generate those transactions, you can use the bigpetstore data generator. Alternatively, you could just write a - -shell script which calls "curl localhost:3000/k8petstore/rpush/blahblahblah" over and over again :). But that's not nearly - -as fun, and its not a good test of a real world scenario where payloads scale and have lots of information content. - -Similarly, you can locally run and test the data generator code, which is Java based, you can pull it down directly from - -apache bigtop. - -Directions for that are here : https://github.com/apache/bigtop/tree/master/bigtop-bigpetstore/bigpetstore-transaction-queue - -You will likely want to checkout the branch 2b2392bf135e9f1256bd0b930f05ae5aef8bbdcb, which is the exact commit which the current k8petstore was tested on. - -## Now what? - -Once you have done the above 3 steps, you have a working, from source, locally runnable version of the k8petstore app, now, we can try to run it in Kubernetes. - -## Hacking, testing, benchmarking - -Once the app is running, you can access the app in your browser, you should see a chart - -and the k8petstore title page, as well as an indicator of transaction throughput, and so on. - -You can modify the HTML pages, add new REST paths to the Go app, and so on. - -## Running in Kubernetes - -Now that you are done hacking around on the app, you can run it in Kubernetes. To do this, you will want to rebuild the docker images (most likely, for the Go web-server app), but less likely for the other images which you are less likely to need to change. Then you will push those images to dockerhub. - -Now, how to run the entire application in Kubernetes? - -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). - -So, to run this app in Kubernetes, simply run [The all in one k8petstore.sh shell script](k8petstore.sh). - -## Should we use PublicIP, NodePort, Cloud loadbalancers ? - -The original k8petstore used PUBLIC_IP fields to bind the web app to an IP. - -However... because the public IP was deprecated in Kubernetes v1, we provide other 2 scripts k8petstore-loadbalancer.sh and k8petstore-nodeport.sh. As the names suggest, they rely on LoadBalancer and NodePort respectively. More details can be found [here](../../docs/user-guide/services.md#external-services). - -We will continue to try to update k8petstore to use the idiomatic networking tools that kubernetes supports, if we fall behind, please create an issue ! - -## Future - -Future development ideas include, adding a persistent k/v store like cassandra/hbase/..., using kafka/activeMQ for the data sink (with redis as a consumer). - -Additionally, adding analytics and meaningful streaming queries to the richly patterned data would also be interesting. - -We are open to other ways of expanding the coverage and realism of the k8petstore application. - -Reach out with ideas, pull requests, and so on! - -The end goal is to support polyglot, real world, data-intensive application on kubernetes which can be used both to learn how to maintain kubernetes applications - -as well as for scale and functionality testing. - -## Questions - -For questions on running this app, you can ask on [Slack](http://slack.kubernetes.io). - -For questions about bigpetstore, and how the data is generated, ask on the apache bigtop mailing list. - - -[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/k8petstore/README.md?pixel)]() - diff --git a/examples/k8petstore/bps-data-generator/README.md b/examples/k8petstore/bps-data-generator/README.md deleted file mode 100644 index 488129044f..0000000000 --- a/examples/k8petstore/bps-data-generator/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# How to generate the bps-data-generator container # - -This container is maintained as part of the apache bigtop project. - -To create it, simply - -`git clone https://github.com/apache/bigtop` - -and checkout the last exact version (will be updated periodically). - -`git checkout -b aNewBranch 2b2392bf135e9f1256bd0b930f05ae5aef8bbdcb` - -then, cd to bigtop-bigpetstore/bigpetstore-transaction-queue, and run the docker file, i.e. - -`Docker build -t -i jayunit100/bps-transaction-queue`. - - - -[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/k8petstore/bps-data-generator/README.md?pixel)]() - diff --git a/examples/k8petstore/build-push-containers.sh b/examples/k8petstore/build-push-containers.sh deleted file mode 100755 index 4cf385b7f5..0000000000 --- a/examples/k8petstore/build-push-containers.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#K8PetStore version is tied to the redis version. We will add more info to version tag later. -#Change the 'jayunit100' string below to you're own dockerhub name and run this script. -#It will build all the containers for this application and publish them to your dockerhub account -version="r.2.8.19" -docker build -t jayunit100/k8-petstore-redis:$version ./redis/ -docker build -t jayunit100/k8-petstore-redis-master:$version ./redis-master -docker build -t jayunit100/k8-petstore-redis-slave:$version ./redis-slave -docker build -t jayunit100/k8-petstore-web-server:$version ./web-server - -docker push jayunit100/k8-petstore-redis:$version -docker push jayunit100/k8-petstore-redis-master:$version -docker push jayunit100/k8-petstore-redis-slave:$version -docker push jayunit100/k8-petstore-web-server:$version - -### Now, start the application. - diff --git a/examples/k8petstore/docker-machine-dev.sh b/examples/k8petstore/docker-machine-dev.sh deleted file mode 100755 index 0ad18b8c5e..0000000000 --- a/examples/k8petstore/docker-machine-dev.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/bin/bash - -source ../../hack/lib/util.sh # need kube::util::host_platform() - -HOST_OS=$(kube::util::host_platform) -HOST_OS=${HOST_OS%/*} # just host_os name - -function setup_vm() { - ### Provider = vbox. You can use another one if you want... But untested. - PROVIDER=virtualbox - - ### Create a VM specific to this app... - if docker-machine ls | grep -q k8petstore ; then - echo "VM already exists, moving on..." - else - docker-machine create --driver $PROVIDER k8petstore - fi -} - -function setup_docker() { - - ## Set the docker server, and then clean all containers... - eval "$(docker-machine env k8petstore)" - docker rm -f `docker ps -a -q` - -} - -function build_containers() { - - version="`date +"%m-%d-%Y-%s"`" - pushd redis - docker build -t jayunit100/k8-petstore-redis:$version ./ - popd - - pushd redis-master - docker build -t jayunit100/k8-petstore-redis-master:$version ./ - popd - - pushd redis-slave - docker build -t jayunit100/k8-petstore-redis-slave:$version ./ - popd - - pushd web-server - docker build -t jayunit100/k8-petstore-web-server:$version ./ - popd -} - -function runk8petstore() { - - ### Finally, run the application. - ### This app is guaranteed to be a clean run using all the source. - ### You can use it to iteratively test/deploy k8petstore and make new changes. - - ### TODO, add slaves. - - echo "Running k8petstore now..." - docker run --name redis -d -p 6379:6379 jayunit100/k8-petstore-redis-master:$version - docker run --link redis:redis -d -e REDISMASTER_SERVICE_HOST=redis -e REDISMASTER_SERVICE_PORT=6379 -p 3000:3000 jayunit100/k8-petstore-web-server:$version - -} - - -if [[ "$HOST_OS" != linux ]] ; then - setup_vm - setup_docker -fi - -build_containers - -runk8petstore diff --git a/examples/k8petstore/k8petstore-loadbalancer.sh b/examples/k8petstore/k8petstore-loadbalancer.sh deleted file mode 100755 index 8eb07e7959..0000000000 --- a/examples/k8petstore/k8petstore-loadbalancer.sh +++ /dev/null @@ -1,332 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "WRITING KUBE FILES , will overwrite the jsons, then testing pods. is kube clean ready to go?" - - -#Args below can be overriden when calling from cmd line. -#Just send all the args in order. -#for dev/test you can use: -#kubectl=$GOPATH/src/github.com/kubernetes/kubernetes/cluster/kubectl.sh" -kubectl="kubectl" -VERSION="r.2.8.19" -_SECONDS=1000 # number of seconds to measure throughput. -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="k8petstore" # namespace - -kubectl="${1:-$kubectl}" -VERSION="${2:-$VERSION}" -_SECONDS="${3:-$_SECONDS}" # number of seconds to measure throughput. -FE="${4:-$FE}" # amount of Web server -LG="${5:-$LG}" # amount of load generators -SLAVE="${6:-$SLAVE}" # amount of redis slaves -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 -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "fectrl", - "labels": {"name": "frontend"} - }, - "spec": { - "replicas": $FE, - "selector": {"name": "frontend"}, - "template": { - "metadata": { - "labels": { - "name": "frontend", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "frontend-go-restapi", - "image": "jayunit100/k8-petstore-web-server:$VERSION" - }] - } - } - } -} -EOF - -cat << EOF > bps-load-gen-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "bpsloadgenrc", - "labels": {"name": "bpsLoadGenController"} - }, - "spec": { - "replicas": $LG, - "selector": {"name": "bps"}, - "template": { - "metadata": { - "labels": { - "name": "bps", - "uses": "frontend" - } - }, - "spec": { - "containers": [{ - "name": "bps", - "image": "jayunit100/bigpetstore-load-generator", - "command": ["sh","-c","/opt/PetStoreLoadGenerator-1.0/bin/PetStoreLoadGenerator http://\$FRONTEND_SERVICE_HOST:3000/rpush/k8petstore/ 4 4 1000 123"] - }] - } - } - } -} -EOF - -cat << EOF > fe-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "frontend", - "labels": { - "name": "frontend" - } - }, - "spec": { - "ports": [{ - "port": 3000 - }], - "selector": { - "name": "frontend" - }, - "type": "LoadBalancer" - } -} -EOF - -cat << EOF > rm.json -{ - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "master", - "image": "jayunit100/k8-petstore-redis-master:$VERSION", - "ports": [{ - "containerPort": 6379 - }] - }] - } -} -EOF - -cat << EOF > rm-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redis-master" - } - } -} -EOF - -cat << EOF > rs-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redisslave", - "labels": { - "name": "redisslave" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redisslave" - } - } -} -EOF - -cat << EOF > slave-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "redissc", - "labels": {"name": "redisslave"} - }, - "spec": { - "replicas": $SLAVE, - "selector": {"name": "redisslave"}, - "template": { - "metadata": { - "labels": { - "name": "redisslave", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "slave", - "image": "jayunit100/k8-petstore-redis-slave:$VERSION", - "ports": [{"containerPort": 6379}] - }] - } - } - } -} -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. -$kubectl create -f slave-rc.json --namespace=$NS -$kubectl create -f rs-s.json --namespace=$NS -sleep 3 # see above comment. -$kubectl create -f fe-rc.json --namespace=$NS -$kubectl create -f fe-s.json --namespace=$NS -$kubectl create -f bps-load-gen-rc.json --namespace=$NS -} - -#This script assumes the cloud provider is able to create a load balancer. If this not the case, you may want to check out other ways to make the frontend service accessible from outside (https://github.com/kubernetes/kubernetes/blob/master/docs/services.md#external-services) -function getIP { - echo "Waiting up to 1 min for a public IP to be assigned by the cloud provider..." - for i in {1..20}; - do - PUBLIC_IP=$($kubectl get services/frontend --namespace=$NS -o template --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") - if [ -n "$PUBLIC_IP" ]; then - printf '\n\n\n%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = - echo "public IP=$PUBLIC_IP" - printf '%*s\n\n\n\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = - return - fi - sleep 3 - done - echo "Failed to detect the public IP after 1 min, exit!" - exit 1 -} - -function pollfor { - pass_http=0 - - ### Test HTTP Server comes up. - for i in {1..150}; - do - ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) - echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... " - curl --max-time 1 "$PUBLIC_IP:3000" > result - cat result - cat result | grep -q "k8-bps" - if [ $? -eq 0 ]; then - echo "TEST PASSED after $i tries !" - i=1000 - break - else - echo "the above RESULT didn't contain target string for trial $i" - fi - sleep 3 - done - - if [ $i -eq 1000 ]; then - pass_http=1 - fi - -} - -function tests { - pass_load=0 - - ### Print statistics of db size, every second, until $SECONDS are up. - for i in `seq 1 $_SECONDS`; - do - echo "curl : $PUBLIC_IP:3000 , $i of $_SECONDS" - curr_cnt="`curl --max-time 1 "$PUBLIC_IP:3000/llen"`" - ### Write CSV File of # of trials / total transcations. - echo "$i $curr_cnt" >> result - echo "total transactions so far : $curr_cnt" - sleep 1 - done -} - -create - -getIP - -pollfor - -if [[ $pass_http -eq 1 ]]; then - echo "Passed..." -else - exit 1 -fi - -if [[ $TEST -eq 1 ]]; then - echo "running polling tests now" - tests -fi diff --git a/examples/k8petstore/k8petstore-nodeport.sh b/examples/k8petstore/k8petstore-nodeport.sh deleted file mode 100755 index 73a0ba340e..0000000000 --- a/examples/k8petstore/k8petstore-nodeport.sh +++ /dev/null @@ -1,351 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "WRITING KUBE FILES , will overwrite the jsons, then testing pods. is kube clean ready to go?" - - -#Args below can be overriden when calling from cmd line. -#Just send all the args in order. -#for dev/test you can use: -#kubectl="$GOPATH/src/k8s.io/kubernetes/cluster/kubectl.sh" - -kubectl="kubectl" -VERSION="r.2.8.19" -_SECONDS=1000 # number of seconds to measure throughput. -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="k8petstore" # namespace -NODE_PORT=30291 #nodePort, see fe-s.json - -kubectl="${1:-$kubectl}" -VERSION="${2:-$VERSION}" -_SECONDS="${3:-$_SECONDS}" # number of seconds to measure throughput. -FE="${4:-$FE}" # amount of Web server -LG="${5:-$LG}" # amount of load generators -SLAVE="${6:-$SLAVE}" # amount of redis slaves -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 -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "fectrl", - "labels": {"name": "frontend"} - }, - "spec": { - "replicas": $FE, - "selector": {"name": "frontend"}, - "template": { - "metadata": { - "labels": { - "name": "frontend", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "frontend-go-restapi", - "image": "jayunit100/k8-petstore-web-server:$VERSION" - }] - } - } - } -} -EOF - -cat << EOF > bps-load-gen-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "bpsloadgenrc", - "labels": {"name": "bpsLoadGenController"} - }, - "spec": { - "replicas": $LG, - "selector": {"name": "bps"}, - "template": { - "metadata": { - "labels": { - "name": "bps", - "uses": "frontend" - } - }, - "spec": { - "containers": [{ - "name": "bps", - "image": "jayunit100/bigpetstore-load-generator", - "command": ["sh","-c","/opt/PetStoreLoadGenerator-1.0/bin/PetStoreLoadGenerator http://\$FRONTEND_SERVICE_HOST:3000/rpush/k8petstore/ 4 4 1000 123"] - }] - } - } - } -} -EOF - -cat << EOF > fe-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "frontend", - "labels": { - "name": "frontend" - } - }, - "spec": { - "ports": [{ - "port": 3000, - "nodePort": $NODE_PORT - }], - "selector": { - "name": "frontend" - }, - "type": "NodePort" - } -} -EOF - -cat << EOF > rm.json -{ - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "master", - "image": "jayunit100/k8-petstore-redis-master:$VERSION", - "ports": [{ - "containerPort": 6379 - }] - }] - } -} -EOF - -cat << EOF > rm-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redis-master" - } - } -} -EOF - -cat << EOF > rs-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redisslave", - "labels": { - "name": "redisslave" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redisslave" - } - } -} -EOF - -cat << EOF > slave-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "redissc", - "labels": {"name": "redisslave"} - }, - "spec": { - "replicas": $SLAVE, - "selector": {"name": "redisslave"}, - "template": { - "metadata": { - "labels": { - "name": "redisslave", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "slave", - "image": "jayunit100/k8-petstore-redis-slave:$VERSION", - "ports": [{"containerPort": 6379}] - }] - } - } - } -} -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. -$kubectl create -f slave-rc.json --namespace=$NS -$kubectl create -f rs-s.json --namespace=$NS -sleep 3 # see above comment. -$kubectl create -f fe-rc.json --namespace=$NS -$kubectl create -f fe-s.json --namespace=$NS -$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 -o go-template='{{range .items}}{{range .status.addresses}}{{if or (eq .type "ExternalIP") (eq .type "LegacyHostIP")}}{{.address}}{{print "\n"}}{{end}}{{end}}{{end}}') - TEST_IP=$($kubectl get nodes -o go-template='{{range (index .items 0).status.addresses}}{{if eq .type "ExternalIP"}}{{.address}}{{end}}{{end}}') - if [ -z "$TEST_IP" ]; then - TEST_IP=$($kubectl get nodes -o go-template='{{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 - else - printf '\n\n\n%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = - echo -e "List of nodes' IP addresses:\n$NODES_IP" - echo -e "Node IP $TEST_IP will be used in the tests in this script" - printf '%*s\n\n\n\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = - fi -} - -function getNodePort { -NODE_PORT=$($kubectl get services/frontend --namespace=$NS -o go-template='{{(index .spec.ports 0).nodePort}}') - -if [ -z "$NODE_PORT" ]; then - echo "Error: Can't get NodePort of services/frontend!!!" - exit 1 -else - printf '\n\n\n%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = - echo -e "NodePort of services/frontend:\n$NODE_PORT" - echo -e "WARNING: On cloud platforms like GCE, you may need to add a firewall rule to allow TCP traffic on port $NODE_PORT" - printf '%*s\n\n\n\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = -fi -} - -function pollfor { - pass_http=0 - - ### Test HTTP Server comes up. - for i in {1..150}; - do - ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) - echo "Trying curl frontend:3000 via $TEST_IP:$NODE_PORT, attempt ${i}. Expect a few failures while pulling images... " - curl --max-time 1 --connect-timeout 3 "$TEST_IP:$NODE_PORT" > result - cat result - cat result | grep -q "k8-bps" - if [ $? -eq 0 ]; then - echo "TEST PASSED after $i tries !" - i=1000 - break - else - echo "the above RESULT didn't contain target string for trial $i" - fi - sleep 3 - done - - if [ $i -eq 1000 ]; then - pass_http=1 - fi -} - -function tests { - pass_load=0 - - ### Print statistics of db size, every second, until $SECONDS are up. - for i in `seq 1 $_SECONDS`; - do - echo "curl : $TEST_IP:$NODE_PORT , $i of $_SECONDS" - curr_cnt="`curl --max-time 1 --connect-timeout 3 "$TEST_IP:$NODE_PORT/llen"`" - ### Write CSV File of # of trials / total transcations. - echo "$i $curr_cnt" >> result - echo "total transactions so far : $curr_cnt" - sleep 1 - done -} - -create - -getIP - -getNodePort - -pollfor - -if [[ $pass_http -eq 1 ]]; then - echo "Passed..." -else - exit 1 -fi - -if [[ $TEST -eq 1 ]]; then - echo "running polling tests now" - tests -fi diff --git a/examples/k8petstore/k8petstore.dot b/examples/k8petstore/k8petstore.dot deleted file mode 100644 index 539132fb3a..0000000000 --- a/examples/k8petstore/k8petstore.dot +++ /dev/null @@ -1,9 +0,0 @@ - digraph k8petstore { - - USERS -> publicIP_proxy -> web_server; - bps_data_generator -> web_server [arrowhead = crow, label = "http://$FRONTEND_SERVICE_HOST:3000/rpush/k8petstore/{name..address..,product=..."]; - external -> web_server [arrowhead = crow, label=" http://$FRONTEND_SERVICE_HOST/k8petstore/llen:3000"]; - web_server -> redis_master [label=" RESP : k8petstore, llen"]; - redis_master -> redis_slave [arrowhead = crow] [label="replication (one-way)"]; -} - diff --git a/examples/k8petstore/k8petstore.sh b/examples/k8petstore/k8petstore.sh deleted file mode 100755 index 77089b2b0a..0000000000 --- a/examples/k8petstore/k8petstore.sh +++ /dev/null @@ -1,324 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "WRITING KUBE FILES , will overwrite the jsons, then testing pods. is kube clean ready to go?" - - -#Args below can be overriden when calling from cmd line. -#Just send all the args in order. -#for dev/test you can use: -#kubectl=$GOPATH/src/github.com/kubernetes/kubernetes/cluster/kubectl.sh" -kubectl="kubectl" -VERSION="r.2.8.19" -PUBLIC_IP="10.1.4.89" # ip which we use to access the Web server. -_SECONDS=1000 # number of seconds to measure throughput. -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="k8petstore" # namespace - -kubectl="${1:-$kubectl}" -VERSION="${2:-$VERSION}" -PUBLIC_IP="${3:-$PUBLIC_IP}" # ip which we use to access the Web server. -_SECONDS="${4:-$_SECONDS}" # number of seconds to measure throughput. -FE="${5:-$FE}" # amount of Web server -LG="${6:-$LG}" # amount of load generators -SLAVE="${7:-$SLAVE}" # amount of redis slaves -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 -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "fectrl", - "labels": {"name": "frontend"} - }, - "spec": { - "replicas": $FE, - "selector": {"name": "frontend"}, - "template": { - "metadata": { - "labels": { - "name": "frontend", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "frontend-go-restapi", - "image": "jayunit100/k8-petstore-web-server:$VERSION" - }] - } - } - } -} -EOF - -cat << EOF > bps-load-gen-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "bpsloadgenrc", - "labels": {"name": "bpsLoadGenController"} - }, - "spec": { - "replicas": $LG, - "selector": {"name": "bps"}, - "template": { - "metadata": { - "labels": { - "name": "bps", - "uses": "frontend" - } - }, - "spec": { - "containers": [{ - "name": "bps", - "image": "jayunit100/bigpetstore-load-generator", - "command": ["sh","-c","/opt/PetStoreLoadGenerator-1.0/bin/PetStoreLoadGenerator http://\$FRONTEND_SERVICE_HOST:3000/rpush/k8petstore/ 4 4 1000 123"] - }] - } - } - } -} -EOF - -cat << EOF > fe-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "frontend", - "labels": { - "name": "frontend" - } - }, - "spec": { - "ports": [{ - "port": 3000 - }], - "externalIPs":["$PUBLIC_IP","10.1.4.89"], - "selector": { - "name": "frontend" - } - } -} -EOF - -cat << EOF > rm.json -{ - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "master", - "image": "jayunit100/k8-petstore-redis-master:$VERSION", - "ports": [{ - "containerPort": 6379 - }] - }] - } -} -EOF - -cat << EOF > rm-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redismaster", - "labels": { - "name": "redis-master" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redis-master" - } - } -} -EOF - -cat << EOF > rs-s.json -{ - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "redisslave", - "labels": { - "name": "redisslave" - } - }, - "spec": { - "ports": [{ - "port": 6379 - }], - "selector": { - "name": "redisslave" - } - } -} -EOF - -cat << EOF > slave-rc.json -{ - "kind": "ReplicationController", - "apiVersion": "v1", - "metadata": { - "name": "redissc", - "labels": {"name": "redisslave"} - }, - "spec": { - "replicas": $SLAVE, - "selector": {"name": "redisslave"}, - "template": { - "metadata": { - "labels": { - "name": "redisslave", - "uses": "redis-master" - } - }, - "spec": { - "containers": [{ - "name": "slave", - "image": "jayunit100/k8-petstore-redis-slave:$VERSION", - "ports": [{"containerPort": 6379}] - }] - } - } - } -} -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. -$kubectl create -f slave-rc.json --namespace=$NS -$kubectl create -f rs-s.json --namespace=$NS -sleep 3 # see above comment. -$kubectl create -f fe-rc.json --namespace=$NS -$kubectl create -f fe-s.json --namespace=$NS -$kubectl create -f bps-load-gen-rc.json --namespace=$NS -} - -function pollfor { - pass_http=0 - - ### Test HTTP Server comes up. - for i in {1..150}; - do - ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) - echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... " - curl --max-time 1 "$PUBLIC_IP:3000" > result - cat result - cat result | grep -q "k8-bps" - if [ $? -eq 0 ]; then - echo "TEST PASSED after $i tries !" - i=1000 - break - else - echo "the above RESULT didn't contain target string for trial $i" - fi - sleep 3 - done - - if [ $i -eq 1000 ]; then - pass_http=1 - fi - -} - -function tests { - pass_load=0 - - ### Print statistics of db size, every second, until $SECONDS are up. - for i in `seq 1 $_SECONDS`; - do - echo "curl : $PUBLIC_IP:3000 , $i of $_SECONDS" - curr_cnt="`curl --max-time 1 "$PUBLIC_IP:3000/llen"`" - ### Write CSV File of # of trials / total transcations. - echo "$i $curr_cnt" >> result - echo "total transactions so far : $curr_cnt" - sleep 1 - done -} - -function warning { - echo "" - echo "THIS SCRIPT IS FOR KUBERNETES < v1." - echo "For LATER VERSIONS, use k8petstore-nodeport.sh or k8petstore-loadbalacer.sh!!!!" - echo "In particular PublicIP is DEPRECATED in post-v1 releases!!!" - echo "" -} - -warning - -create - -pollfor - -if [[ $pass_http -eq 1 ]]; then - echo "Passed..." -else - exit 1 -fi - -if [[ $TEST -eq 1 ]]; then - echo "running polling tests now" - tests -fi diff --git a/examples/k8petstore/redis-master/Dockerfile b/examples/k8petstore/redis-master/Dockerfile deleted file mode 100644 index a3f7f9bc90..0000000000 --- a/examples/k8petstore/redis-master/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Redis Dockerfile -# -# https://github.com/dockerfile/redis -# - -# Pull base image. -# -# Just a stub. - -FROM redis - -ADD etc_redis_redis.conf /etc/redis/redis.conf - -CMD ["redis-server", "/etc/redis/redis.conf"] -# Expose ports. -EXPOSE 6379 diff --git a/examples/k8petstore/redis-master/etc_redis_redis.conf b/examples/k8petstore/redis-master/etc_redis_redis.conf deleted file mode 100644 index 38b8c701e7..0000000000 --- a/examples/k8petstore/redis-master/etc_redis_redis.conf +++ /dev/null @@ -1,46 +0,0 @@ -pidfile /var/run/redis.pid -port 6379 -tcp-backlog 511 -timeout 0 -tcp-keepalive 0 -loglevel verbose -syslog-enabled yes -databases 1 -save 1 1 -save 900 1 -save 300 10 -save 60 10000 -stop-writes-on-bgsave-error yes -rdbcompression no -rdbchecksum yes -dbfilename dump.rdb -dir /data -slave-serve-stale-data no -slave-read-only yes -repl-disable-tcp-nodelay no -slave-priority 100 -maxmemory -appendonly yes -appendfilename "appendonly.aof" -appendfsync everysec -no-appendfsync-on-rewrite no -auto-aof-rewrite-percentage 100 -auto-aof-rewrite-min-size 1 -aof-load-truncated yes -lua-time-limit 5000 -slowlog-log-slower-than 10000 -slowlog-max-len 128 -latency-monitor-threshold 0 -notify-keyspace-events "KEg$lshzxeA" -list-max-ziplist-entries 512 -list-max-ziplist-value 64 -set-max-intset-entries 512 -zset-max-ziplist-entries 128 -zset-max-ziplist-value 64 -hll-sparse-max-bytes 3000 -activerehashing yes -client-output-buffer-limit normal 0 0 0 -client-output-buffer-limit slave 256mb 64mb 60 -client-output-buffer-limit pubsub 32mb 8mb 60 -hz 10 -aof-rewrite-incremental-fsync yes diff --git a/examples/k8petstore/redis-slave/Dockerfile b/examples/k8petstore/redis-slave/Dockerfile deleted file mode 100644 index 481102d740..0000000000 --- a/examples/k8petstore/redis-slave/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Redis Dockerfile -# -# https://github.com/dockerfile/redis -# - -# Pull base image. -# -# Just a stub. - -FROM redis - -ADD run.sh /run.sh - -CMD /run.sh diff --git a/examples/k8petstore/redis-slave/etc_redis_redis.conf b/examples/k8petstore/redis-slave/etc_redis_redis.conf deleted file mode 100644 index 38b8c701e7..0000000000 --- a/examples/k8petstore/redis-slave/etc_redis_redis.conf +++ /dev/null @@ -1,46 +0,0 @@ -pidfile /var/run/redis.pid -port 6379 -tcp-backlog 511 -timeout 0 -tcp-keepalive 0 -loglevel verbose -syslog-enabled yes -databases 1 -save 1 1 -save 900 1 -save 300 10 -save 60 10000 -stop-writes-on-bgsave-error yes -rdbcompression no -rdbchecksum yes -dbfilename dump.rdb -dir /data -slave-serve-stale-data no -slave-read-only yes -repl-disable-tcp-nodelay no -slave-priority 100 -maxmemory -appendonly yes -appendfilename "appendonly.aof" -appendfsync everysec -no-appendfsync-on-rewrite no -auto-aof-rewrite-percentage 100 -auto-aof-rewrite-min-size 1 -aof-load-truncated yes -lua-time-limit 5000 -slowlog-log-slower-than 10000 -slowlog-max-len 128 -latency-monitor-threshold 0 -notify-keyspace-events "KEg$lshzxeA" -list-max-ziplist-entries 512 -list-max-ziplist-value 64 -set-max-intset-entries 512 -zset-max-ziplist-entries 128 -zset-max-ziplist-value 64 -hll-sparse-max-bytes 3000 -activerehashing yes -client-output-buffer-limit normal 0 0 0 -client-output-buffer-limit slave 256mb 64mb 60 -client-output-buffer-limit pubsub 32mb 8mb 60 -hz 10 -aof-rewrite-incremental-fsync yes diff --git a/examples/k8petstore/redis-slave/run.sh b/examples/k8petstore/redis-slave/run.sh deleted file mode 100755 index ec9647eafa..0000000000 --- a/examples/k8petstore/redis-slave/run.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "If you get errors below, kubernetes env injection could be failing..." -echo "env vars =" -env -echo "CHECKING ENVS BEFORE STARTUP........" -if [ ! "$REDISMASTER_SERVICE_HOST" ]; then - echo "Need to set REDIS_MASTER_SERVICE_HOST" && exit 1; -fi -if [ ! "$REDISMASTER_PORT" ]; then - echo "Need to set REDIS_MASTER_PORT" && exit 1; -fi - -echo "ENV Vars look good, starting !" - -redis-server --slaveof ${REDISMASTER_SERVICE_HOST:-$SERVICE_HOST} $REDISMASTER_SERVICE_PORT diff --git a/examples/k8petstore/redis/Dockerfile b/examples/k8petstore/redis/Dockerfile deleted file mode 100644 index f230afad20..0000000000 --- a/examples/k8petstore/redis/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Redis Dockerfile -# -# https://github.com/dockerfile/redis -# - -# Pull base image. -FROM redis - -# Define mountable directories. -VOLUME ["/data"] - -# Define working directory. -WORKDIR /data - -ADD etc_redis_redis.conf /etc/redis/redis.conf - -# Print redis configs and start. -# CMD "redis-server /etc/redis/redis.conf" - -# Expose ports. -EXPOSE 6379 diff --git a/examples/k8petstore/redis/etc_redis_redis.conf b/examples/k8petstore/redis/etc_redis_redis.conf deleted file mode 100644 index 38b8c701e7..0000000000 --- a/examples/k8petstore/redis/etc_redis_redis.conf +++ /dev/null @@ -1,46 +0,0 @@ -pidfile /var/run/redis.pid -port 6379 -tcp-backlog 511 -timeout 0 -tcp-keepalive 0 -loglevel verbose -syslog-enabled yes -databases 1 -save 1 1 -save 900 1 -save 300 10 -save 60 10000 -stop-writes-on-bgsave-error yes -rdbcompression no -rdbchecksum yes -dbfilename dump.rdb -dir /data -slave-serve-stale-data no -slave-read-only yes -repl-disable-tcp-nodelay no -slave-priority 100 -maxmemory -appendonly yes -appendfilename "appendonly.aof" -appendfsync everysec -no-appendfsync-on-rewrite no -auto-aof-rewrite-percentage 100 -auto-aof-rewrite-min-size 1 -aof-load-truncated yes -lua-time-limit 5000 -slowlog-log-slower-than 10000 -slowlog-max-len 128 -latency-monitor-threshold 0 -notify-keyspace-events "KEg$lshzxeA" -list-max-ziplist-entries 512 -list-max-ziplist-value 64 -set-max-intset-entries 512 -zset-max-ziplist-entries 128 -zset-max-ziplist-value 64 -hll-sparse-max-bytes 3000 -activerehashing yes -client-output-buffer-limit normal 0 0 0 -client-output-buffer-limit slave 256mb 64mb 60 -client-output-buffer-limit pubsub 32mb 8mb 60 -hz 10 -aof-rewrite-incremental-fsync yes diff --git a/examples/k8petstore/web-server/Dockerfile b/examples/k8petstore/web-server/Dockerfile deleted file mode 100644 index 92768bff3d..0000000000 --- a/examples/k8petstore/web-server/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM golang:latest - -# Add source to gopath. This is defacto required for go apps. -ADD ./src /gopath/src/k8petstore -RUN mkdir /gopath/bin/ -ADD ./static /tmp/static -ADD ./test.sh /opt/test.sh -RUN chmod 777 /opt/test.sh - -# So that we can easily run and install -WORKDIR /gopath/src - -# Install the code (the executables are in the main dir) This will get the deps also. -RUN export GOPATH=/gopath/ && go get k8petstore -RUN export GOPATH=/gopath/ && go install k8petstore - - -# Expected that you will override this in production kubernetes. -ENV STATIC_FILES /tmp/static -CMD /gopath/bin/k8petstore diff --git a/examples/k8petstore/web-server/dump.rdb b/examples/k8petstore/web-server/dump.rdb deleted file mode 100644 index d1028f1679..0000000000 Binary files a/examples/k8petstore/web-server/dump.rdb and /dev/null differ diff --git a/examples/k8petstore/web-server/src/BUILD b/examples/k8petstore/web-server/src/BUILD deleted file mode 100644 index fb3328d8ac..0000000000 --- a/examples/k8petstore/web-server/src/BUILD +++ /dev/null @@ -1,39 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_binary", - "go_library", -) - -go_binary( - name = "src", - library = ":go_default_library", - tags = ["automanaged"], -) - -go_library( - name = "go_default_library", - srcs = ["main.go"], - tags = ["automanaged"], - deps = [ - "//vendor/github.com/codegangsta/negroni:go_default_library", - "//vendor/github.com/gorilla/mux:go_default_library", - "//vendor/github.com/xyproto/simpleredis:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], -) diff --git a/examples/k8petstore/web-server/src/main.go b/examples/k8petstore/web-server/src/main.go deleted file mode 100644 index a0c2e0f6d8..0000000000 --- a/examples/k8petstore/web-server/src/main.go +++ /dev/null @@ -1,204 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "encoding/json" - "fmt" - "net/http" - "os" - "strings" - - "github.com/codegangsta/negroni" - "github.com/gorilla/mux" - "github.com/xyproto/simpleredis" -) - -//return the path to static assets (i.e. index.html) -func pathToStaticContents() string { - var static_content = os.Getenv("STATIC_FILES") - // Take a wild guess. This will work in dev environment. - if static_content == "" { - println("*********** WARNING: DIDNT FIND ENV VAR 'STATIC_FILES', guessing your running in dev.") - static_content = "../../static/" - } else { - println("=========== Read ENV 'STATIC_FILES', path to assets : " + static_content) - } - - //Die if no the static files are missing. - _, err := os.Stat(static_content) - if err != nil { - println("*********** os.Stat failed on " + static_content + " This means no static files are available. Dying...") - os.Exit(2) - } - return static_content -} - -func main() { - - var connection = os.Getenv("REDISMASTER_SERVICE_HOST") + ":" + os.Getenv("REDISMASTER_SERVICE_PORT") - - if connection == ":" { - print("WARNING ::: If in kube, this is a failure: Missing env variable REDISMASTER_SERVICE_HOST") - print("WARNING ::: Attempting to connect redis localhost.") - connection = "127.0.0.1:6379" - } else { - print("Found redis master host " + os.Getenv("REDISMASTER_SERVICE_PORT")) - connection = os.Getenv("REDISMASTER_SERVICE_HOST") + ":" + os.Getenv("REDISMASTER_SERVICE_PORT") - } - - println("Now connecting to : " + connection) - /** - * Create a connection pool. ?The pool pointer will otherwise - * not be of any use.?https://gist.github.com/jayunit100/1d00e6d343056401ef00 - */ - pool = simpleredis.NewConnectionPoolHost(connection) - - println("Connection pool established : " + connection) - - defer pool.Close() - - r := mux.NewRouter() - - println("Router created ") - - /** - * Define a REST path. - * - The parameters (key) can be accessed via mux.Vars. - * - The Methods (GET) will be bound to a handler function. - */ - r.Path("/info").Methods("GET").HandlerFunc(InfoHandler) - r.Path("/lrange/{key}").Methods("GET").HandlerFunc(ListRangeHandler) - r.Path("/rpush/{key}/{value}").Methods("GET").HandlerFunc(ListPushHandler) - r.Path("/llen").Methods("GET").HandlerFunc(LLENHandler) - - //for dev environment, the site is one level up... - - r.PathPrefix("/").Handler(http.FileServer(http.Dir(pathToStaticContents()))) - - r.Path("/env").Methods("GET").HandlerFunc(EnvHandler) - - list := simpleredis.NewList(pool, "k8petstore") - HandleError(nil, list.Add("jayunit100")) - HandleError(nil, list.Add("tstclaire")) - HandleError(nil, list.Add("rsquared")) - - // Verify that this is 3 on startup. - infoL := HandleError(pool.Get(0).Do("LLEN", "k8petstore")).(int64) - fmt.Printf("\n=========== Starting DB has %d elements \n", infoL) - if infoL < 3 { - print("Not enough entries in DB. something is wrong w/ redis querying") - print(infoL) - panic("Failed ... ") - } - - println("=========== Now launching negroni...this might take a second...") - n := negroni.Classic() - n.UseHandler(r) - n.Run(":3000") - println("Done ! Web app is now running.") - -} - -/** -* the Pool will be populated on startup, -* it will be an instance of a connection pool. -* Hence, we reference its address rather than copying. - */ -var pool *simpleredis.ConnectionPool - -/** -* REST -* input: key -* -* Writes all members to JSON. - */ -func ListRangeHandler(rw http.ResponseWriter, req *http.Request) { - println("ListRangeHandler") - - key := mux.Vars(req)["key"] - - list := simpleredis.NewList(pool, key) - - //members := HandleError(list.GetAll()).([]string) - members := HandleError(list.GetLastN(4)).([]string) - - print(members) - membersJSON := HandleError(json.MarshalIndent(members, "", " ")).([]byte) - - print("RETURN MEMBERS = " + string(membersJSON)) - rw.Write(membersJSON) -} - -func LLENHandler(rw http.ResponseWriter, req *http.Request) { - println("=========== LLEN HANDLER") - - infoL := HandleError(pool.Get(0).Do("LLEN", "k8petstore")).(int64) - fmt.Printf("=========== LLEN is %d ", infoL) - lengthJSON := HandleError(json.MarshalIndent(infoL, "", " ")).([]byte) - fmt.Printf("================ LLEN json is %d", infoL) - - print("RETURN LEN = " + string(lengthJSON)) - rw.Write(lengthJSON) - -} - -func ListPushHandler(rw http.ResponseWriter, req *http.Request) { - println("ListPushHandler") - - /** - * Expect a key and value as input. - * - */ - key := mux.Vars(req)["key"] - value := mux.Vars(req)["value"] - - println("New list " + key + " " + value) - list := simpleredis.NewList(pool, key) - HandleError(nil, list.Add(value)) - ListRangeHandler(rw, req) -} - -func InfoHandler(rw http.ResponseWriter, req *http.Request) { - println("InfoHandler") - - info := HandleError(pool.Get(0).Do("INFO")).([]byte) - rw.Write(info) -} - -func EnvHandler(rw http.ResponseWriter, req *http.Request) { - println("EnvHandler") - - environment := make(map[string]string) - for _, item := range os.Environ() { - splits := strings.Split(item, "=") - key := splits[0] - val := strings.Join(splits[1:], "=") - environment[key] = val - } - - envJSON := HandleError(json.MarshalIndent(environment, "", " ")).([]byte) - rw.Write(envJSON) -} - -func HandleError(result interface{}, err error) (r interface{}) { - if err != nil { - print("ERROR : " + err.Error()) - //panic(err) - } - return result -} diff --git a/examples/k8petstore/web-server/static/histogram.js b/examples/k8petstore/web-server/static/histogram.js deleted file mode 100644 index c9f20203e3..0000000000 --- a/examples/k8petstore/web-server/static/histogram.js +++ /dev/null @@ -1,39 +0,0 @@ -//var data = [4, 8, 15, 16, 23, 42]; - -function defaults(){ - - Chart.defaults.global.animation = false; - -} - -function f(data2) { - - defaults(); - - // Get context with jQuery - using jQuery's .get() method. - var ctx = $("#myChart").get(0).getContext("2d"); - ctx.width = $(window).width()*1.5; - ctx.width = $(window).height *.5; - - // This will get the first returned node in the jQuery collection. - var myNewChart = new Chart(ctx); - - var data = { - labels: Array.apply(null, Array(data2.length)).map(function (_, i) {return i;}), - datasets: [ - { - label: "My First dataset", - fillColor: "rgba(220,220,220,0.2)", - strokeColor: "rgba(220,220,220,1)", - pointColor: "rgba(220,220,220,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(220,220,220,1)", - data: data2 - } - ] - }; - - var myLineChart = new Chart(ctx).Line(data); -} - diff --git a/examples/k8petstore/web-server/static/index.html b/examples/k8petstore/web-server/static/index.html deleted file mode 100644 index b184ab0e78..0000000000 --- a/examples/k8petstore/web-server/static/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - ((( - PRODUCTION -))) Guestbook - - - - - - - - - - - - -
-
-

Waiting for database connection...This will get overwritten...

-
-
-
-
-

-

/env - /info

-
-
- -
- - - diff --git a/examples/k8petstore/web-server/static/script.js b/examples/k8petstore/web-server/static/script.js deleted file mode 100644 index 095d161fdf..0000000000 --- a/examples/k8petstore/web-server/static/script.js +++ /dev/null @@ -1,72 +0,0 @@ -$(document).ready(function() { - - var max_trials=1000 - - var headerTitleElement = $("#header h1"); - var entriesElement = $("#k8petstore-entries"); - var hostAddressElement = $("#k8petstore-host-address"); - var currentEntries = [] - - var updateEntryCount = function(data, trial) { - if(currentEntries.length > 1000) - currentEntries.splice(0,100); - //console.info("entry count " + data) ; - currentEntries[trial]=data ; - } - - var updateEntries = function(data) { - entriesElement.empty(); - //console.info("data - > " + Math.random()) - //uncommend for debugging... - //entriesElement.append("

CURRENT TIME : "+ $.now() +"

TOTAL entries : "+ JSON.stringify(currentEntries)+"

") - var c1 = currentEntries[currentEntries.length-1] - var c2 = currentEntries[currentEntries.length-2] - entriesElement.append("

CURRENT TIME : "+ $.now() +"

TOTAL entries : "+ c1 +"
transaction delta " + (c1-c2) +"

") - f(currentEntries); - $.each(data, function(key, val) { - //console.info(key + " -> " +val); - entriesElement.append("

" + key + " " + val.substr(0,50) + val.substr(100,150) + "

"); - }); - - } - - // colors = purple, blue, red, green, yellow - var colors = ["#549", "#18d", "#d31", "#2a4", "#db1"]; - var randomColor = colors[Math.floor(5 * Math.random())]; - ( - function setElementsColor(color) { - headerTitleElement.css("color", color); - }) - - (randomColor); - - hostAddressElement.append(document.URL); - - // Poll every second. - (function fetchGuestbook() { - - // Get JSON by running the query, and append - $.getJSON("lrange/k8petstore").done(updateEntries).always( - function() { - setTimeout(fetchGuestbook, 2000); - }); - })(); - - (function fetchLength(trial) { - $.getJSON("llen").done( - function a(llen1){ - updateEntryCount(llen1, trial) - }).always( - function() { - // This function is run every 2 seconds. - setTimeout( - function(){ - trial+=1 ; - fetchLength(trial); - f(); - }, 5000); - } - ) - })(0); -}); - diff --git a/examples/k8petstore/web-server/static/style.css b/examples/k8petstore/web-server/static/style.css deleted file mode 100644 index 3685293452..0000000000 --- a/examples/k8petstore/web-server/static/style.css +++ /dev/null @@ -1,69 +0,0 @@ -body, input { - color: #123; - font-family: "Gill Sans", sans-serif; -} - -div { - overflow: hidden; - padding: 1em 0; - position: relative; - text-align: center; -} - -h1, h2, p, input, a { - font-weight: 300; - margin: 0; -} - -h1 { - color: #BDB76B; - font-size: 3.5em; -} - -h2 { - color: #999; -} - -form { - margin: 0 auto; - max-width: 50em; - text-align: center; -} - -input { - border: 0; - border-radius: 1000px; - box-shadow: inset 0 0 0 2px #BDB76B; - display: inline; - font-size: 1.5em; - margin-bottom: 1em; - outline: none; - padding: .5em 5%; - width: 55%; -} - -form a { - background: #BDB76B; - border: 0; - border-radius: 1000px; - color: #FFF; - font-size: 1.25em; - font-weight: 400; - padding: .75em 2em; - text-decoration: none; - text-transform: uppercase; - white-space: normal; -} - -p { - font-size: 1.5em; - line-height: 1.5; -} -.chart div { - font: 10px sans-serif; - background-color: steelblue; - text-align: right; - padding: 3px; - margin: 1px; - color: white; -} diff --git a/examples/k8petstore/web-server/test.sh b/examples/k8petstore/web-server/test.sh deleted file mode 100644 index cf1427bd41..0000000000 --- a/examples/k8petstore/web-server/test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "start test of frontend" -curl localhost:3000/llen -curl localhost:3000/llen -curl localhost:3000/llen -curl localhost:3000/llen -curl localhost:3000/llen -curl localhost:3000/llen -x=`curl localhost:3000/llen` -echo "done testing frontend result = $x" diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 68d01b5ffe..f9597a194c 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -131,7 +131,6 @@ kube::golang::test_targets() { cmd/mungedocs cmd/genswaggertypedocs cmd/linkcheck - examples/k8petstore/web-server/src federation/cmd/genfeddocs vendor/github.com/onsi/ginkgo/ginkgo test/e2e/e2e.test