mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #4573 from roberthbailey/update-sh
Remove the numbered shell scripts from the live update example and the update.sh e2e test.
This commit is contained in:
commit
46cbc700eb
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
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
|
||||
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECTL proxy --www=local/
|
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
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
|
||||
|
||||
export KUBE_ROOT=${KUBE_ROOT-$(dirname $0)/../..}
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
SCHEMA=${KUBE_ROOT}/examples/update-demo/nautilus-rc.yaml
|
||||
|
||||
cat ${SCHEMA} | sed "s/DOCKER_HUB_USER/${DOCKER_HUB_USER}/" | ${KUBECTL} create -f -
|
@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
NEW_SIZE=${1:-4}
|
||||
|
||||
export KUBE_ROOT=${KUBE_ROOT-$(dirname $0)/../..}
|
||||
export KUBECTL=${KUBECTL-$KUBE_ROOT/cluster/kubectl.sh}
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECTL resize rc update-demo-nautilus --replicas=$NEW_SIZE
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
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
|
||||
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
NEW_IMAGE=${1:-kitten}
|
||||
TIMING=${2:-10s}
|
||||
SCHEMA=${KUBE_ROOT}/examples/update-demo/kitten-rc.yaml
|
||||
|
||||
cat ${SCHEMA} | sed "s/DOCKER_HUB_USER/${DOCKER_HUB_USER}/" | ${KUBECTL} rollingupdate update-demo-nautilus -f - --update-period=10s
|
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
rc="update-demo-kitten"
|
||||
echo "Stopping replicationController ${rc}"
|
||||
$KUBECTL stop rc ${rc} || true
|
||||
|
||||
rc="update-demo-nautilus"
|
||||
echo "Stopping replicationController ${rc}"
|
||||
$KUBECTL stop rc ${rc} || true
|
@ -26,14 +26,7 @@ $ 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 \
|
||||
@ -41,28 +34,14 @@ $ gcloud compute firewall-rules create \
|
||||
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.
|
||||
@ -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.
|
||||
@ -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.
|
||||
@ -90,11 +69,11 @@ 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.
|
||||
@ -102,13 +81,11 @@ Watch the [demo website](http://localhost:8001/static/index.html), it will updat
|
||||
### 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:
|
||||
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user