Migrate the update-demo to use v1beta3.

This commit is contained in:
Robert Bailey 2015-04-17 23:32:02 -07:00
parent 52d99f0448
commit f5885f10bd
7 changed files with 19 additions and 58 deletions

View File

@ -42,7 +42,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 internal port 80.
```bash
$ ./cluster/kubectl.sh create -f examples/update-demo/v1beta1/nautilus-rc.yaml
$ ./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.
@ -61,7 +61,7 @@ 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
$ ./cluster/kubectl.sh rolling-update update-demo-nautilus --update-period=10s -f examples/update-demo/v1beta1/kitten-rc.yaml
$ ./cluster/kubectl.sh rolling-update update-demo-nautilus --update-period=10s -f examples/update-demo/kitten-rc.yaml
```
The rolling-update command in kubectl will do 2 things:
@ -106,7 +106,7 @@ $ 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/v1beta1/nautilus-rc.yaml` and `examples/update-demo/v1beta1/kitten-rc.yaml`.
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

View File

@ -22,9 +22,9 @@ limitations under the License.
</head>
<body ng-controller="ButtonsCtrl">
<div ng-repeat="server in servers" class="pod">
<img src="http://localhost:8001/api/v1beta1/proxy/pods/{{server.podId}}/{{server.image}}" height="100px" width="100px" />
<b>ID:</b> {{server.podId}}<br>
<b>Host:</b> <a href="http://localhost:8001/api/v1beta1/proxy/pods/{{server.podId}}/data.json">{{server.host}}</a><br>
<img src="http://localhost:8001/api/v1beta3/proxy/namespaces/default/pods/{{server.podName}}/{{server.image}}" height="100px" width="100px" />
<b>ID:</b> {{server.podName}}<br>
<b>Host:</b> <a href="http://localhost:8001/api/v1beta3/proxy/namespaces/default/pods/{{server.podName}}/data.json">{{server.host}}</a><br>
<b>Status:</b> {{server.status}}<br>
<b>Image:</b> {{server.dockerImage}}<br>
<b>Labels:</b>

View File

@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
var base = "http://localhost:8001/api/v1beta1/";
var base = "http://localhost:8001/api/v1beta3/";
var updateImage = function($http, server) {
$http.get(base + "proxy/pods/" + server.podId + "/data.json")
$http.get(base + "proxy/namespaces/default/pods/" + server.podName + "/data.json")
.success(function(data) {
console.log(data);
server.image = data.image;
@ -29,13 +29,13 @@ var updateImage = function($http, server) {
};
var updateServer = function($http, server) {
$http.get(base + "pods/" + server.podId)
$http.get(base + "namespaces/default/pods/" + server.podName)
.success(function(data) {
console.log(data);
server.labels = data.labels;
server.host = data.currentState.host.split('.')[0];
server.status = data.currentState.status;
server.dockerImage = data.currentState.info["update-demo"].image;
server.labels = data.metadata.labels;
server.host = data.spec.host.split('.')[0];
server.status = data.status.phase;
server.dockerImage = data.status.containerStatuses[0].image;
updateImage($http, server);
})
.error(function(data) {
@ -57,10 +57,10 @@ var ButtonsCtrl = function ($scope, $http, $interval) {
$interval(angular.bind({}, update, $scope, $http), 2000);
};
var getServer = function($scope, id) {
var getServer = function($scope, name) {
var servers = $scope.servers;
for (var i = 0; i < servers.length; ++i) {
if (servers[i].podId == id) {
if (servers[i].podName == name) {
return servers[i];
}
}
@ -68,7 +68,7 @@ var getServer = function($scope, id) {
};
var isUpdateDemoPod = function(pod) {
return pod.labels && pod.labels.name == "update-demo";
return pod.metadata && pod.metadata.labels && pod.metadata.labels.name == "update-demo";
};
var update = function($scope, $http) {
@ -76,7 +76,7 @@ var update = function($scope, $http) {
console.log("No HTTP!");
return;
}
$http.get(base + "pods")
$http.get(base + "namespaces/default/pods")
.success(function(data) {
console.log(data);
var newServers = [];
@ -85,9 +85,9 @@ var update = function($scope, $http) {
if (!isUpdateDemoPod(pod)) {
continue;
}
var server = getServer($scope, pod.id);
var server = getServer($scope, pod.metadata.name);
if (server == null) {
server = { "podId": pod.id };
server = { "podName": pod.metadata.name };
}
newServers.push(server);
}

View File

@ -1,19 +0,0 @@
kind: ReplicationController
id: update-demo-kitten
apiVersion: v1beta1
desiredState:
replicaSelector:
name: update-demo
version: kitten
podTemplate:
desiredState:
manifest:
containers:
- name: update-demo
image: gcr.io/google_containers/update-demo:kitten
ports:
- containerPort: 80
protocol: TCP
labels:
name: update-demo
version: kitten

View File

@ -1,20 +0,0 @@
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: gcr.io/google_containers/update-demo:nautilus
ports:
- containerPort: 80
protocol: TCP
labels:
name: update-demo
version: nautilus