Fix some readme and script bugs in examples (take 2).
v2: Resolve issues from comments, fix bugs in update-demo example, rename files for clarity, add turn-down steps. v3: Add more set commands, clean up rest of env var checks.
This commit is contained in:
parent
295e70a949
commit
3b9e9387cf
|
@ -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.
|
||||
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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"
|
|
@ -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/
|
|
@ -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
|
|
@ -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)/../..}
|
|
@ -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
|
|
@ -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}
|
||||
|
|
@ -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.
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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.
|
||||
|
|
|
@ -25,6 +25,7 @@ limitations under the License.
|
|||
<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>
|
||||
|
|
|
@ -23,7 +23,7 @@ var updateImage = function($http, server) {
|
|||
console.log(data);
|
||||
})
|
||||
.error(function(data) {
|
||||
server.image = ""
|
||||
server.image = "";
|
||||
console.log(data);
|
||||
});
|
||||
};
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue