Skip to content

Commit

Permalink
Fix the e2e scripts after PR 1284 which added a new file.
Browse files Browse the repository at this point in the history
  • Loading branch information
filbranden authored and brendandburns committed Sep 11, 2014
2 parents 57b721d + bd196ea commit fabf7c7
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started-guides/gce.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[http://cloud.google.com/console](http://cloud.google.com/console) for more details.
2. Make sure you can start up a GCE VM. At least make sure you can do the [Create an instance](https://developers.google.com/compute/docs/quickstart#addvm) part of the GCE Quickstart.
3. Make sure you can ssh into the VM without interactive prompts. You'll need to set up a ssh key and expose port 22 in the firewall if you choose to use a network other than the default network (`gcutil addfirewall --description "SSH allowed from anywhere" --allowed=tcp:22 default-ssh`)
4. You need to have the Google Storage API, and the Google Storage JSON API enabled.
4. You need to have the Google Cloud Storage API, and the Google Cloud Storage JSON API enabled.
5. You must have Go (version 1.2 or later) installed: [www.golang.org](http://www.golang.org).
6. You must have the [`gcloud` components](https://developers.google.com/cloud/sdk/) installed.
7. Ensure that your `gcloud` components are up-to-date by running `gcloud components update`.
Expand Down
13 changes: 13 additions & 0 deletions examples/guestbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ The example combines a web frontend, a redis master for storage and a replicated

This example assumes that you have forked the repository and [turned up a Kubernetes cluster](https://github.com/GoogleCloudPlatform/kubernetes#contents):

```shell
$ cd kubernetes
$ hack/dev-build-and-up.sh
```

### Step One: Turn up the redis master.

Use the file `examples/guestbook/redis-master.json` which describes a single pod running a redis key-value server in a container.
Expand Down Expand Up @@ -307,3 +312,11 @@ For details about limiting traffic to specific sources, see the [gcutil document

[cloud-console]: https://console.developer.google.com
[gcutil-docs]: https://developers.google.com/compute/docs/gcutil/reference/firewall#addfirewall

### Step Six: Cleanup

To turn down a Kubernetes cluster:

```shell
$ cluster/kube-down.sh
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

# This script will build and push the images necessary for the demo.

if (( $# != 1 )); then
echo "Usage: $0 <docker hub user name>"
set -o errexit
set -o nounset
set -o pipefail

if [[ "${DOCKER_HUB_USER+set}" != "set" ]] ; then
echo "Please set DOCKER_HUB_USER to your Docker hub account"
exit 1
fi

DOCKER_USER=$1

set -x

docker build -t update-demo-base base
docker build -t $DOCKER_USER/update-demo:kitten kitten
docker build -t $DOCKER_USER/update-demo:nautilus nautilus
docker build -t update-demo-base images/base
docker build -t "${DOCKER_HUB_USER}/update-demo:kitten" images/kitten
docker build -t "${DOCKER_HUB_USER}/update-demo:nautilus" images/nautilus

docker push $DOCKER_USER/update-demo
docker push "${DOCKER_HUB_USER}/update-demo"
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

echo "Running local proxy to Kubernetes API Server. Run this in a "
echo "separate terminal or run it in the background."
echo
echo " http://localhost:8001/static/"
echo

set -x

../../cluster/kubecfg.sh -proxy -www local/
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if [ -z "$DOCKER_HUB_USER" ] ; then
set -o errexit
set -o nounset
set -o pipefail

if [[ "${DOCKER_HUB_USER+set}" != "set" ]] ; then
echo "Please set DOCKER_HUB_USER to your Docker hub account"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

NEW_SIZE=${1:-4}

export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if [ -z "$DOCKER_HUB_USER" ] ; then
set -o errexit
set -o nounset
set -o pipefail

if [[ "${DOCKER_HUB_USER+set}" != "set" ]] ; then
echo "Please set DOCKER_HUB_USER to your Docker hub account"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}

Expand Down
42 changes: 26 additions & 16 deletions examples/update-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ This example demonstrates the usage of Kubernetes to perform a live update on a

### Step Zero: Prerequisites

This example assumes that you have forked the repository and [turned up a Kubernetes cluster](https://github.com/GoogleCloudPlatform/kubernetes-new#setup):
This example assumes that you have forked the repository and [turned up a Kubernetes cluster](https://github.com/GoogleCloudPlatform/kubernetes-new#contents):

$ cd kubernetes
$ hack/dev-build-and-up.sh
$ hack/build-go.sh
```shell
$ cd kubernetes
$ hack/dev-build-and-up.sh
```

This example also assumes that you have [Docker](http://docker.io) installed on your local machine.

Expand All @@ -35,47 +36,47 @@ You may need to open the firewall for port 8080 using the [console][cloud-consol
$ gcutil addfirewall --allowed=tcp:8080 --target_tags=kubernetes-minion kubernetes-minion-8080
```

### Step One: Build the image
### Step Zero: Build the image

```shell
$ cd kubernetes/examples/update-demo
$ ./build-images.sh
$ cd examples/update-demo
$ ./0-build-images.sh
```

### Step Two: Turn up the UX for the demo
### Step One: Turn up the UX for the demo

```shell
$ ./0-run-web-proxy.sh &
$ ./1-run-web-proxy.sh &
```

This can sometimes spew to the output so you could also run it in a different terminal.

Now visit the the [demo website](http://localhost:8001/static). You won't see anything much quite yet.

### Step Three: Run the controller
### Step Two: Run the controller
Now we will turn up two replicas of an image. They all serve on port 8080, mapped to internal port 80

```shell
$ ./1-create-replication-controller.sh
$ ./2-create-replication-controller.sh
```

After these pull the image (which may take a minute or so) you'll see a couple of squares in the UI detailing the pods that are running along with the image that they are serving up. A cute little nautilus.

### Step Four: Try resizing the controller
### Step Three: Try resizing the controller

Now we will increase the number of replicas from two to four:

```shell
$ ./2-scale.sh
$ ./3-scale.sh
```

If you go back to the [demo website](http://localhost:8001/static/index.html) you should eventually see four boxes, one for each pod.

### Step Five: Update the docker image
### Step Four: Update the docker image
We will now update the docker image to serve a different image by doing a rolling update to a new Docker image.

```shell
$ ./3-rolling-update
$ ./4-rolling-update
```
The rollingUpdate command in kubecfg will do 2 things:

Expand All @@ -87,13 +88,22 @@ Watch the UX, it will update one pod every 10 seconds until all of the pods have
### Step Five: Bring down the pods

```shell
$ ./4-down.sh
$ ./5-down.sh
```

This will first 'stop' the replication controller by turning the target number of replicas to 0. It'll then delete that controller.

[cloud-console]: https://console.developer.google.com

### Step Six: Cleanup

To turn down a Kubernetes cluster:

```shell
$ cd ../.. # Up to kubernetes.
$ cluster/kube-down.sh
```

### Image Copyright

Note that he images included here are public domain.
Expand Down
1 change: 1 addition & 0 deletions examples/update-demo/local/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<img src="http://{{server.ip}}:8080/{{server.image}}" height="100px" width="100px" />
<b>ID:</b> {{server.id}}<br>
<b>Host:</b> <a href="http://{{server.ip}}:8080/data.json">{{server.host}}</a><br>
<b>Status:</b> {{server.status}}<br>
<b>Image:</b> {{server.dockerImage}}<br>
<b>Labels:</b>
<ul>
Expand Down
9 changes: 5 additions & 4 deletions examples/update-demo/local/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var updateImage = function($http, server) {
console.log(data);
})
.error(function(data) {
server.image = ""
server.image = "";
console.log(data);
});
};
Expand All @@ -34,8 +34,9 @@ var updateServer = function($http, server) {
console.log(data);
server.ip = data.currentState.hostIP;
server.labels = data.labels;
server.host = data.currentState.host.split('.')[0]
server.dockerImage = data.currentState.info["update-demo-container"].Config.Image
server.host = data.currentState.host.split('.')[0];
server.status = data.currentState.status;
server.dockerImage = data.currentState.info["update-demo"].Config.Image;
updateImage($http, server);
})
.error(function(data) {
Expand Down Expand Up @@ -84,7 +85,7 @@ var update = function($scope, $http) {
newServers.push(server);
}
$scope.servers = newServers;
updateData($scope, $http)
updateData($scope, $http);
})
.error(function(data) {
console.log("ERROR: " + data);
Expand Down
10 changes: 5 additions & 5 deletions hack/e2e-suite/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,26 @@ function validate() {
export DOCKER_HUB_USER=jbeda

# Launch a container
${KUBE_REPO_ROOT}/examples/update-demo/1-create-replication-controller.sh
${KUBE_REPO_ROOT}/examples/update-demo/2-create-replication-controller.sh

function teardown() {
echo "Cleaning up test artifacts"
${KUBE_REPO_ROOT}/examples/update-demo/4-down.sh
${KUBE_REPO_ROOT}/examples/update-demo/5-down.sh
}

trap "teardown" EXIT

validate 2 nautilus

${KUBE_REPO_ROOT}/examples/update-demo/2-scale.sh 1
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 1
sleep 2
validate 1 nautilus

${KUBE_REPO_ROOT}/examples/update-demo/2-scale.sh 2
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 2
sleep 2
validate 2 nautilus

${KUBE_REPO_ROOT}/examples/update-demo/3-rolling-update.sh kitten 1s
${KUBE_REPO_ROOT}/examples/update-demo/4-rolling-update.sh kitten 1s
sleep 2
validate 2 kitten

Expand Down

0 comments on commit fabf7c7

Please sign in to comment.