Remove host ports from the update demo and update tests

This commit is contained in:
Robert Bailey
2015-02-24 14:51:33 -08:00
parent fdf371dc96
commit dd87c247a5
9 changed files with 74 additions and 56 deletions

View File

@@ -26,28 +26,20 @@ $ cd kubernetes
$ hack/dev-build-and-up.sh
```
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 \
--allow tcp:8080 --target-tags=kubernetes-minion \
kubernetes-minion-8080
```
### 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.
You can use bash job control to run this in the background (note that you must use the default port -- 8001 -- for the following demonstration to work properly). This can sometimes spew to the output so you could also run it in a different terminal.
```
$ ./cluster/kubectl.sh proxy --www=local/ &
+ ./cluster/kubectl.sh proxy --www=local/
$ ./cluster/kubectl.sh proxy --www=examples/update-demo/local/ &
+ ./cluster/kubectl.sh proxy --www=examples/update-demo/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.
### 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 internal port 80.
```bash
$ ./cluster/kubectl.sh create -f examples/update-demo/nautilus-rc.yaml

View File

@@ -12,8 +12,7 @@ desiredState:
- name: update-demo
image: kubernetes/update-demo:kitten
ports:
- hostPort: 8080
containerPort: 80
- containerPort: 80
protocol: TCP
labels:
name: update-demo

File diff suppressed because one or more lines are too long

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://{{server.ip}}:8080/{{server.image}}" height="100px" width="100px" />
<b>ID:</b> {{server.id}}<br>
<b>Host:</b> <a href="http://{{server.ip}}:8080/data.json">{{server.host}}</a><br>
<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>
<b>Status:</b> {{server.status}}<br>
<b>Image:</b> {{server.dockerImage}}<br>
<b>Labels:</b>

View File

@@ -17,27 +17,25 @@ limitations under the License.
var base = "http://localhost:8001/api/v1beta1/";
var updateImage = function($http, server) {
$http.get("http://" + server.ip + ":8080/data.json")
$http.get(base + "proxy/pods/" + server.podId + "/data.json")
.success(function(data) {
server.image = data.image;
console.log(data);
server.image = data.image;
})
.error(function(data) {
server.image = "";
console.log(data);
server.image = "";
});
};
var updateServer = function($http, server) {
$http.get(base + "pods/" + server.id)
$http.get(base + "pods/" + server.podId)
.success(function(data) {
console.log(data);
server.ip = data.currentState.hostIP;
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.dockerImage = data.currentState.info["update-demo"].image;
updateImage($http, server);
})
.error(function(data) {
@@ -62,7 +60,7 @@ var ButtonsCtrl = function ($scope, $http, $interval) {
var getServer = function($scope, id) {
var servers = $scope.servers;
for (var i = 0; i < servers.length; ++i) {
if (servers[i].id == id) {
if (servers[i].podId == id) {
return servers[i];
}
}
@@ -89,7 +87,7 @@ var update = function($scope, $http) {
}
var server = getServer($scope, pod.id);
if (server == null) {
server = { "id": pod.id };
server = { "podId": pod.id };
}
newServers.push(server);
}

View File

@@ -13,8 +13,7 @@ desiredState:
- name: update-demo
image: kubernetes/update-demo:nautilus
ports:
- hostPort: 8080
containerPort: 80
- containerPort: 80
protocol: TCP
labels:
name: update-demo