Commit 5b8767fa authored by Robert Bailey's avatar Robert Bailey

Migrate the update-demo to use v1beta3.

parent eb1ea269
...@@ -42,7 +42,7 @@ Now visit the the [demo website](http://localhost:8001/static). You won't see a ...@@ -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. Now we will turn up two replicas of an image. They all serve on internal port 80.
```bash ```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. 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 ...@@ -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. We will now update the docker image to serve a different image by doing a rolling update to a new Docker image.
```bash ```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: The rolling-update command in kubectl will do 2 things:
...@@ -106,7 +106,7 @@ $ export DOCKER_HUB_USER=my-docker-id ...@@ -106,7 +106,7 @@ $ export DOCKER_HUB_USER=my-docker-id
$ ./examples/update-demo/build-images.sh $ ./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 ### Image Copyright
......
...@@ -22,9 +22,9 @@ limitations under the License. ...@@ -22,9 +22,9 @@ limitations under the License.
</head> </head>
<body ng-controller="ButtonsCtrl"> <body ng-controller="ButtonsCtrl">
<div ng-repeat="server in servers" class="pod"> <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" /> <img src="http://localhost:8001/api/v1beta3/proxy/namespaces/default/pods/{{server.podName}}/{{server.image}}" height="100px" width="100px" />
<b>ID:</b> {{server.podId}}<br> <b>ID:</b> {{server.podName}}<br>
<b>Host:</b> <a href="http://localhost:8001/api/v1beta1/proxy/pods/{{server.podId}}/data.json">{{server.host}}</a><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>Status:</b> {{server.status}}<br>
<b>Image:</b> {{server.dockerImage}}<br> <b>Image:</b> {{server.dockerImage}}<br>
<b>Labels:</b> <b>Labels:</b>
......
...@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and ...@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var base = "http://localhost:8001/api/v1beta1/"; var base = "http://localhost:8001/api/v1beta3/";
var updateImage = function($http, server) { 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) { .success(function(data) {
console.log(data); console.log(data);
server.image = data.image; server.image = data.image;
...@@ -29,13 +29,13 @@ var updateImage = function($http, server) { ...@@ -29,13 +29,13 @@ var updateImage = function($http, server) {
}; };
var updateServer = 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) { .success(function(data) {
console.log(data); console.log(data);
server.labels = data.labels; server.labels = data.metadata.labels;
server.host = data.currentState.host.split('.')[0]; server.host = data.spec.host.split('.')[0];
server.status = data.currentState.status; server.status = data.status.phase;
server.dockerImage = data.currentState.info["update-demo"].image; server.dockerImage = data.status.containerStatuses[0].image;
updateImage($http, server); updateImage($http, server);
}) })
.error(function(data) { .error(function(data) {
...@@ -57,10 +57,10 @@ var ButtonsCtrl = function ($scope, $http, $interval) { ...@@ -57,10 +57,10 @@ var ButtonsCtrl = function ($scope, $http, $interval) {
$interval(angular.bind({}, update, $scope, $http), 2000); $interval(angular.bind({}, update, $scope, $http), 2000);
}; };
var getServer = function($scope, id) { var getServer = function($scope, name) {
var servers = $scope.servers; var servers = $scope.servers;
for (var i = 0; i < servers.length; ++i) { for (var i = 0; i < servers.length; ++i) {
if (servers[i].podId == id) { if (servers[i].podName == name) {
return servers[i]; return servers[i];
} }
} }
...@@ -68,7 +68,7 @@ var getServer = function($scope, id) { ...@@ -68,7 +68,7 @@ var getServer = function($scope, id) {
}; };
var isUpdateDemoPod = function(pod) { 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) { var update = function($scope, $http) {
...@@ -76,7 +76,7 @@ var update = function($scope, $http) { ...@@ -76,7 +76,7 @@ var update = function($scope, $http) {
console.log("No HTTP!"); console.log("No HTTP!");
return; return;
} }
$http.get(base + "pods") $http.get(base + "namespaces/default/pods")
.success(function(data) { .success(function(data) {
console.log(data); console.log(data);
var newServers = []; var newServers = [];
...@@ -85,9 +85,9 @@ var update = function($scope, $http) { ...@@ -85,9 +85,9 @@ var update = function($scope, $http) {
if (!isUpdateDemoPod(pod)) { if (!isUpdateDemoPod(pod)) {
continue; continue;
} }
var server = getServer($scope, pod.id); var server = getServer($scope, pod.metadata.name);
if (server == null) { if (server == null) {
server = { "podId": pod.id }; server = { "podName": pod.metadata.name };
} }
newServers.push(server); newServers.push(server);
} }
......
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment