Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the numbered shell scripts from the live update example and the update.sh e2e test. #4573

Merged
merged 1 commit into from
Feb 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 0 additions & 32 deletions examples/update-demo/1-run-web-proxy.sh

This file was deleted.

33 changes: 0 additions & 33 deletions examples/update-demo/2-create-replication-controller.sh

This file was deleted.

28 changes: 0 additions & 28 deletions examples/update-demo/3-scale.sh

This file was deleted.

35 changes: 0 additions & 35 deletions examples/update-demo/4-rolling-update.sh

This file was deleted.

32 changes: 0 additions & 32 deletions examples/update-demo/5-down.sh

This file was deleted.

57 changes: 22 additions & 35 deletions examples/update-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,22 @@ $ cd kubernetes
$ hack/dev-build-and-up.sh
```

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

It also assumes that `$DOCKER_HUB_USER` is set to your Docker user id. We use this to upload the docker images that are used in the demo.
```bash
$ export DOCKER_HUB_USER=my-docker-id
```

You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcloud` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:
If you are running your cluster on GCE (the default), you may need to open the firewall for port 8080 using the [console](https://console.developer.google.com) or the `gcloud` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:

```bash
$ gcloud compute firewall-rules create \
--allow tcp:8080 --target-tags=kubernetes-minion \
kubernetes-minion-8080
```

### Step Zero: Build the Docker images

This can take a few minutes to download/upload stuff.

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

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

You can use bash job control to run this in the background. This can sometimes spew to the output so you could also run it in a different terminal.

```
$ ./1-run-web-proxy.sh &
Running local proxy to Kubernetes API Server. Run this in a
separate terminal or run it in the background.

http://localhost:8001/static/

+ ../../cluster/kubectl.sh proxy --www=local/
I0115 16:50:15.959551 19790 proxy.go:34] Starting to serve on localhost:8001
$ ./cluster/kubectl.sh proxy --www=local/ &
+ ./cluster/kubectl.sh proxy --www=local/
I0218 15:18:31.623279 67480 proxy.go:36] Starting to serve on localhost:8001
```

Now visit the the [demo website](http://localhost:8001/static). You won't see anything much quite yet.
Expand All @@ -71,7 +50,7 @@ Now visit the the [demo website](http://localhost:8001/static). You won't see a
Now we will turn up two replicas of an image. They all serve on port 8080, mapped to internal port 80

```bash
$ ./2-create-replication-controller.sh
$ ./cluster/kubectl.sh create -f examples/update-demo/nautilus-rc.yaml
```

After pulling the image from the Docker Hub to your worker nodes (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.
Expand All @@ -81,7 +60,7 @@ After pulling the image from the Docker Hub to your worker nodes (which may take
Now we will increase the number of replicas from two to four:

```bash
$ ./3-scale.sh
$ ./cluster/kubectl.sh resize rc update-demo-nautilus --replicas=4
```

If you go back to the [demo website](http://localhost:8001/static/index.html) you should eventually see four boxes, one for each pod.
Expand All @@ -90,25 +69,23 @@ If you go back to the [demo website](http://localhost:8001/static/index.html) yo
We will now update the docker image to serve a different image by doing a rolling update to a new Docker image.

```bash
$ ./4-rolling-update.sh
$ ./cluster/kubectl.sh rollingupdate update-demo-nautilus --update-period=10s -f examples/update-demo/kitten-rc.yaml
```
The rollingUpdate command in kubectl will do 2 things:
The rollingupdate command in kubectl will do 2 things:

1. Create a new replication controller with a pod template that uses the new image (`$DOCKER_HUB_USER/update-demo:kitten`)
1. Create a new replication controller with a pod template that uses the new image (`kubernetes/update-demo:kitten`)
2. Resize the old and new replication controllers until the new controller replaces the old. This will kill the current pods one at a time, spinnning up new ones to replace them.

Watch the [demo website](http://localhost:8001/static/index.html), it will update one pod every 10 seconds until all of the pods have the new image.

### Step Five: Bring down the pods

```bash
$ ./5-down.sh
$ ./cluster/kubectl.sh stop rc update-demo-kitten
```

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:
Expand All @@ -123,11 +100,21 @@ After you are done running this demo make sure to kill it:

```bash
$ jobs
[1]+ Running ./1-run-web-proxy.sh &
[1]+ Running ./cluster/kubectl.sh proxy --www=local/ &
$ kill %1
[1]+ Terminated: 15 ./1-run-web-proxy.sh
[1]+ Terminated: 15 ./cluster/kubectl.sh proxy --www=local/
```

### Updating the Docker images

If you want to build your own docker images, you can set `$DOCKER_HUB_USER` to your Docker user id and run the included shell script. It can take a few minutes to download/upload stuff.

```bash
$ export DOCKER_HUB_USER=my-docker-id
$ ./examples/update-demo/build-images.sh
```

To use your custom docker image in the above examples, you will need to change the image name in `examples/update-demo/nautilus-rc.yaml` and `examples/update-demo/kitten-rc.yaml`.

### Image Copyright

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ 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_HUB_USER=${DOCKER_HUB_USER:-kubernetes}

set -x

Expand Down
2 changes: 1 addition & 1 deletion examples/update-demo/kitten-rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ desiredState:
manifest:
containers:
- name: update-demo
image: DOCKER_HUB_USER/update-demo:kitten
image: kubernetes/update-demo:kitten
ports:
- hostPort: 8080
containerPort: 80
Expand Down
2 changes: 1 addition & 1 deletion examples/update-demo/nautilus-rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ desiredState:
manifest:
containers:
- name: update-demo
image: DOCKER_HUB_USER/update-demo:nautilus
image: kubernetes/update-demo:nautilus
ports:
- hostPort: 8080
containerPort: 80
Expand Down
14 changes: 6 additions & 8 deletions hack/e2e-suite/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,27 @@ function validate() {
return 0
}

export DOCKER_HUB_USER=jlowdermilk

function teardown() {
echo "Cleaning up test artifacts"
${KUBE_ROOT}/examples/update-demo/5-down.sh
${KUBECTL} stop rc update-demo-kitten || true
${KUBECTL} stop rc update-demo-nautilus || true
}

trap "teardown" EXIT

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

${KUBECTL} create -f "${KUBE_ROOT}/examples/update-demo/nautilus-rc.yaml"
validate 2 nautilus

${KUBE_ROOT}/examples/update-demo/3-scale.sh 1
${KUBECTL} resize rc update-demo-nautilus --replicas=1
sleep 2
validate 1 nautilus

${KUBE_ROOT}/examples/update-demo/3-scale.sh 2
${KUBECTL} resize rc update-demo-nautilus --replicas=2
sleep 2
validate 2 nautilus

${KUBE_ROOT}/examples/update-demo/4-rolling-update.sh kitten 1s
${KUBECTL} rollingupdate update-demo-nautilus --update-period=1s -f "${KUBE_ROOT}/examples/update-demo/kitten-rc.yaml"
sleep 2
validate 2 kitten

Expand Down