mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
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
57b721dd05
commit
bd196ea49c
@ -6,7 +6,7 @@
|
|||||||
[http://cloud.google.com/console](http://cloud.google.com/console) for more details.
|
[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.
|
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`)
|
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).
|
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.
|
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`.
|
7. Ensure that your `gcloud` components are up-to-date by running `gcloud components update`.
|
||||||
|
@ -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):
|
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.
|
### 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.
|
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
|
[cloud-console]: https://console.developer.google.com
|
||||||
[gcutil-docs]: https://developers.google.com/compute/docs/gcutil/reference/firewall#addfirewall
|
[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.
|
# This script will build and push the images necessary for the demo.
|
||||||
|
|
||||||
if (( $# != 1 )); then
|
set -o errexit
|
||||||
echo "Usage: $0 <docker hub user name>"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOCKER_USER=$1
|
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
docker build -t update-demo-base base
|
docker build -t update-demo-base images/base
|
||||||
docker build -t $DOCKER_USER/update-demo:kitten kitten
|
docker build -t "${DOCKER_HUB_USER}/update-demo:kitten" images/kitten
|
||||||
docker build -t $DOCKER_USER/update-demo:nautilus nautilus
|
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
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# 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 "Running local proxy to Kubernetes API Server. Run this in a "
|
||||||
echo "separate terminal or run it in the background."
|
echo "separate terminal or run it in the background."
|
||||||
echo
|
echo
|
||||||
echo " http://localhost:8001/static/"
|
echo " http://localhost:8001/static/"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
../../cluster/kubecfg.sh -proxy -www local/
|
../../cluster/kubecfg.sh -proxy -www local/
|
@ -14,7 +14,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# 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"
|
echo "Please set DOCKER_HUB_USER to your Docker hub account"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
@ -14,6 +14,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
NEW_SIZE=${1:-4}
|
NEW_SIZE=${1:-4}
|
||||||
|
|
||||||
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
@ -14,7 +14,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# 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"
|
echo "Please set DOCKER_HUB_USER to your Docker hub account"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
@ -14,6 +14,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
||||||
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
|
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
|
### 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
|
```shell
|
||||||
$ hack/dev-build-and-up.sh
|
$ cd kubernetes
|
||||||
$ hack/build-go.sh
|
$ hack/dev-build-and-up.sh
|
||||||
|
```
|
||||||
|
|
||||||
This example also assumes that you have [Docker](http://docker.io) installed on your local machine.
|
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
|
$ gcutil addfirewall --allowed=tcp:8080 --target_tags=kubernetes-minion kubernetes-minion-8080
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step One: Build the image
|
### Step Zero: Build the image
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ cd kubernetes/examples/update-demo
|
$ cd examples/update-demo
|
||||||
$ ./build-images.sh
|
$ ./0-build-images.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step Two: Turn up the UX for the demo
|
### Step One: Turn up the UX for the demo
|
||||||
|
|
||||||
```shell
|
```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.
|
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.
|
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
|
Now we will turn up two replicas of an image. They all serve on port 8080, mapped to internal port 80
|
||||||
|
|
||||||
```shell
|
```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.
|
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:
|
Now we will increase the number of replicas from two to four:
|
||||||
|
|
||||||
```shell
|
```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.
|
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.
|
We will now update the docker image to serve a different image by doing a rolling update to a new Docker image.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ ./3-rolling-update
|
$ ./4-rolling-update
|
||||||
```
|
```
|
||||||
The rollingUpdate command in kubecfg will do 2 things:
|
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
|
### Step Five: Bring down the pods
|
||||||
|
|
||||||
```shell
|
```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.
|
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
|
[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
|
### Image Copyright
|
||||||
|
|
||||||
Note that he images included here are public domain.
|
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" />
|
<img src="http://{{server.ip}}:8080/{{server.image}}" height="100px" width="100px" />
|
||||||
<b>ID:</b> {{server.id}}<br>
|
<b>ID:</b> {{server.id}}<br>
|
||||||
<b>Host:</b> <a href="http://{{server.ip}}:8080/data.json">{{server.host}}</a><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>Image:</b> {{server.dockerImage}}<br>
|
||||||
<b>Labels:</b>
|
<b>Labels:</b>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -23,7 +23,7 @@ var updateImage = function($http, server) {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function(data) {
|
||||||
server.image = ""
|
server.image = "";
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -34,8 +34,9 @@ var updateServer = function($http, server) {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
server.ip = data.currentState.hostIP;
|
server.ip = data.currentState.hostIP;
|
||||||
server.labels = data.labels;
|
server.labels = data.labels;
|
||||||
server.host = data.currentState.host.split('.')[0]
|
server.host = data.currentState.host.split('.')[0];
|
||||||
server.dockerImage = data.currentState.info["update-demo-container"].Config.Image
|
server.status = data.currentState.status;
|
||||||
|
server.dockerImage = data.currentState.info["update-demo"].Config.Image;
|
||||||
updateImage($http, server);
|
updateImage($http, server);
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function(data) {
|
||||||
@ -84,7 +85,7 @@ var update = function($scope, $http) {
|
|||||||
newServers.push(server);
|
newServers.push(server);
|
||||||
}
|
}
|
||||||
$scope.servers = newServers;
|
$scope.servers = newServers;
|
||||||
updateData($scope, $http)
|
updateData($scope, $http);
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.error(function(data) {
|
||||||
console.log("ERROR: " + data);
|
console.log("ERROR: " + data);
|
||||||
|
Loading…
Reference in New Issue
Block a user