Update update-demo example and e2e test to use kubectl
This commit is contained in:
parent
eff83897c1
commit
f0f2d2c147
|
@ -123,6 +123,10 @@ func TestExampleObjectSchemas(t *testing.T) {
|
|||
"service": &api.Service{},
|
||||
"replication-controller": &api.ReplicationController{},
|
||||
},
|
||||
"../examples/update-demo": {
|
||||
"kitten-rc": &api.ReplicationController{},
|
||||
"nautilus-rc": &api.ReplicationController{},
|
||||
},
|
||||
}
|
||||
|
||||
for path, expected := range cases {
|
||||
|
|
|
@ -24,6 +24,9 @@ echo
|
|||
echo " http://localhost:8001/static/"
|
||||
echo
|
||||
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_REPO_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
../../cluster/kubecfg.sh -proxy -www local/
|
||||
$KUBECTL proxy --www=local/
|
||||
|
|
|
@ -23,9 +23,11 @@ if [[ "${DOCKER_HUB_USER+set}" != "set" ]] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
||||
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_REPO_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECFG -p 8080:80 run $DOCKER_HUB_USER/update-demo:nautilus 2 update-demo
|
||||
SCHEMA=${KUBE_REPO_ROOT}/examples/update-demo/nautilus-rc.yaml
|
||||
|
||||
cat ${SCHEMA} | sed "s/DOCKER_HUB_USER/${DOCKER_HUB_USER}/" | ${KUBECTL} create -f -
|
||||
|
|
|
@ -21,8 +21,8 @@ set -o pipefail
|
|||
NEW_SIZE=${1:-4}
|
||||
|
||||
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
||||
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
|
||||
export KUBECTL=${KUBECTL-$KUBE_REPO_ROOT/cluster/kubectl.sh}
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECFG resize update-demo $NEW_SIZE
|
||||
$KUBECTL resize rc update-demo-nautilus --replicas=$NEW_SIZE
|
||||
|
|
|
@ -23,11 +23,13 @@ if [[ "${DOCKER_HUB_USER+set}" != "set" ]] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
NEW_IMAGE=${1:-kitten}
|
||||
TIMING=${2:-10s}
|
||||
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
|
||||
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECFG -image $DOCKER_HUB_USER/update-demo:$NEW_IMAGE -u $TIMING rollingupdate update-demo
|
||||
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
|
||||
|
|
|
@ -18,10 +18,11 @@ 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}
|
||||
export KUBE_ROOT=$(dirname $0)/../..
|
||||
export KUBECTL=${KUBE_ROOT}/cluster/kubectl.sh
|
||||
|
||||
set -x
|
||||
|
||||
$KUBECFG stop update-demo
|
||||
$KUBECFG rm update-demo
|
||||
rc="update-demo-kitten"
|
||||
|
||||
$KUBECTL stop rc ${rc}
|
||||
|
|
|
@ -61,8 +61,8 @@ separate terminal or run it in the background.
|
|||
|
||||
http://localhost:8001/static/
|
||||
|
||||
+ ../../cluster/kubecfg.sh -proxy -www local/
|
||||
I0922 11:43:54.886018 15659 kubecfg.go:209] Starting to serve on localhost:8001
|
||||
+ ../../cluster/kubectl.sh proxy --www=local/
|
||||
I0115 16:50:15.959551 19790 proxy.go:34] Starting to serve on localhost:8001
|
||||
```
|
||||
|
||||
Now visit the the [demo website](http://localhost:8001/static). You won't see anything much quite yet.
|
||||
|
@ -92,12 +92,12 @@ We will now update the docker image to serve a different image by doing a rollin
|
|||
```bash
|
||||
$ ./4-rolling-update.sh
|
||||
```
|
||||
The rollingUpdate command in kubecfg will do 2 things:
|
||||
The rollingUpdate command in kubectl will do 2 things:
|
||||
|
||||
1. Update the template in the replication controller to the new image (`$DOCKER_HUB_USER/update-demo:kitten`)
|
||||
2. Kill each of the pods one by one. It'll let the replication controller create new pods to replace those that were killed.
|
||||
1. Create a new replication controller with a pod template that uses the new image (`$DOCKER_HUB_USER/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 UX, it will update one pod every 10 seconds until all of the pods have the new image.
|
||||
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
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
kind: ReplicationController
|
||||
id: update-demo-kitten
|
||||
apiVersion: v1beta1
|
||||
desiredState:
|
||||
replicaSelector:
|
||||
name: update-demo
|
||||
version: kitten
|
||||
podTemplate:
|
||||
desiredState:
|
||||
manifest:
|
||||
containers:
|
||||
- name: update-demo
|
||||
image: DOCKER_HUB_USER/update-demo:kitten
|
||||
ports:
|
||||
- hostPort: 8080
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
labels:
|
||||
name: update-demo
|
||||
version: kitten
|
|
@ -46,7 +46,7 @@ var updateServer = function($http, server) {
|
|||
};
|
||||
|
||||
var updateData = function($scope, $http) {
|
||||
var servers = $scope.servers
|
||||
var servers = $scope.servers;
|
||||
for (var i = 0; i < servers.length; ++i) {
|
||||
var server = servers[i];
|
||||
updateServer($http, server);
|
||||
|
@ -69,6 +69,10 @@ var getServer = function($scope, id) {
|
|||
return null;
|
||||
};
|
||||
|
||||
var isUpdateDemoPod = function(pod) {
|
||||
return pod.labels && pod.labels.name == "update-demo";
|
||||
};
|
||||
|
||||
var update = function($scope, $http) {
|
||||
if (!$http) {
|
||||
console.log("No HTTP!");
|
||||
|
@ -79,9 +83,13 @@ var update = function($scope, $http) {
|
|||
console.log(data);
|
||||
var newServers = [];
|
||||
for (var i = 0; i < data.items.length; ++i) {
|
||||
var server = getServer($scope, data.items[i].id);
|
||||
var pod = data.items[i];
|
||||
if (!isUpdateDemoPod(pod)) {
|
||||
continue;
|
||||
}
|
||||
var server = getServer($scope, pod.id);
|
||||
if (server == null) {
|
||||
server = { "id": data.items[i].id };
|
||||
server = { "id": pod.id };
|
||||
}
|
||||
newServers.push(server);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
kind: ReplicationController
|
||||
id: update-demo-nautilus
|
||||
apiVersion: v1beta1
|
||||
desiredState:
|
||||
replicas: 2
|
||||
replicaSelector:
|
||||
name: update-demo
|
||||
version: nautilus
|
||||
podTemplate:
|
||||
desiredState:
|
||||
manifest:
|
||||
containers:
|
||||
- name: update-demo
|
||||
image: DOCKER_HUB_USER/update-demo:nautilus
|
||||
ports:
|
||||
- hostPort: 8080
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
labels:
|
||||
name: update-demo
|
||||
version: nautilus
|
Loading…
Reference in New Issue