Updated cloudconfig.sh output examples

Updated cloudconfig.sh output examples to match what the tool currently prints.
Added specific gcutil commands to get public IP addresses, and create the firewall rules.
This commit is contained in:
Brian Dorsey 2014-06-15 16:12:13 -07:00
parent f8712143bd
commit 8aacbfacd3
1 changed files with 47 additions and 443 deletions

View File

@ -51,45 +51,10 @@ cluster/cloudcfg.sh list /pods
You'll see a single redis master pod. It will also display the machine that the pod is running on. You'll see a single redis master pod. It will also display the machine that the pod is running on.
```javascript ```
Using master: kubernetes-master (external IP: 1.2.3.4) Name Image(s) Host Labels
{ ---------- ---------- ---------- ----------
"kind": "cluster#podList", redis-master-2 dockerfile/redis kubernetes-minion-3.c.briandpe-api.internal name=redis-master
"items": [
{
"id": "redis-master-2",
"labels": {
"name": "redis-master"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"name": "master",
"image": "dockerfile/redis",
"ports": [
{
"hostPort": 6379,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
}
]
}
``` ```
If you ssh to that machine, you can run `docker ps` to see the actual pod: If you ssh to that machine, you can run `docker ps` to see the actual pod:
@ -122,18 +87,11 @@ The pod that you created in Step One has the label `name=redis-master`, so the c
Once you have that service description, you can create the service with the `cloudcfg` cli: Once you have that service description, you can create the service with the `cloudcfg` cli:
```js ```shell
$ cluster/cloudcfg.sh -c examples/guestbook/redis-master-service.json create /services $ cluster/cloudcfg.sh -c examples/guestbook/redis-master-service.json create /services
Name Label Query Port
Using master: kubernetes-master (external IP: 1.2.3.4) ---------- ---------- ----------
{ redismaster name=redis-master 10000
"id": "redismaster",
"port": 10000,
"labels": {
"name": "redis-master"
}
}
``` ```
Once created, the service proxy on each minion is configured to set up a proxy on the specified port (in this case port 10000). Once created, the service proxy on each minion is configured to set up a proxy on the specified port (in this case port 10000).
@ -166,45 +124,11 @@ Create a file named `redis-slave-controller.json` that contains:
Then you can create the service by running: Then you can create the service by running:
```js ```shell
$ cluster/cloudcfg.sh -c examples/guestbook/redis-slave-controller.json create /replicationControllers $ cluster/cloudcfg.sh -c examples/guestbook/redis-slave-controller.json create /replicationControllers
Name Image(s) Label Query Replicas
Using master: kubernetes-master (external IP: 1.2.3.4) ---------- ---------- ---------- ----------
{ redisSlaveController brendanburns/redis-slave name=redisslave 2
"id": "redisSlaveController",
"desiredState": {
"replicas": 2,
"replicasInSet": {
"name": "redisslave"
},
"podTemplate": {
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/redis-slave",
"ports": [
{
"hostPort": 6380,
"containerPort": 6379
}
]
}
]
}
},
"labels": {
"name": "redisslave"
}
}
},
"labels": {
"name": "redisslave"
}
}
``` ```
The redis slave configures itself by looking for the Kubernetes service environment variables in the container environment. In particular, the redis slave is started with the following command: The redis slave configures itself by looking for the Kubernetes service environment variables in the container environment. In particular, the redis slave is started with the following command:
@ -215,111 +139,13 @@ redis-server --slaveof $SERVICE_HOST $REDISMASTER_SERVICE_PORT
Once that's up you can list the pods in the cluster, to verify that the master and slaves are running: Once that's up you can list the pods in the cluster, to verify that the master and slaves are running:
```js ```shell
$ cluster/cloudcfg.sh list /pods $ cluster/cloudcfg.sh list /pods
Name Image(s) Host Labels
Using master: kubernetes-master (external IP: 23.236.49.160) ---------- ---------- ---------- ----------
{ redis-master-2 dockerfile/redis kubernetes-minion-3.c.briandpe-api.internal name=redis-master
"kind": "cluster#podList", 4d65822107fcfd52 brendanburns/redis-slave kubernetes-minion-3.c.briandpe-api.internal name=redisslave,replicationController=redisSlaveController
"items": [ 78629a0f5f3f164f brendanburns/redis-slave kubernetes-minion-4.c.briandpe-api.internal name=redisslave,replicationController=redisSlaveController
{
"id": "redis-master-2",
"labels": {
"name": "redis-master"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"name": "master",
"image": "dockerfile/redis",
"ports": [
{
"hostPort": 6379,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
},
{
"id": "4d65822107fcfd52",
"labels": {
"name": "redisslave",
"replicationController": "redisSlaveController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/redis-slave",
"ports": [
{
"hostPort": 6380,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
},
{
"id": "78629a0f5f3f164f",
"labels": {
"name": "redisslave",
"replicationController": "redisSlaveController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/redis-slave",
"ports": [
{
"hostPort": 6380,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-2.c.{project-id}.internal"
}
}
]
}
``` ```
You will see a single redis master pod and two redis slave pods. You will see a single redis master pod and two redis slave pods.
@ -342,18 +168,11 @@ This time the label query for the service is `name=redis-slave`.
Now that you have created the service specification, create it in your cluster with the `cloudcfg` CLI: Now that you have created the service specification, create it in your cluster with the `cloudcfg` CLI:
```js ```shell
$ cluster/cloudcfg.sh -c examples/guestbook/redis-slave-service.json create /services $ cluster/cloudcfg.sh -c examples/guestbook/redis-slave-service.json create /services
Name Label Query Port
Using master: kubernetes-master (external IP: 1.2.3.4) ---------- ---------- ----------
{ redisslave name=redisslave 10001
"id": "redisslave",
"port": 10001,
"labels": {
"name": "redisslave"
}
}
``` ```
### Step Five: Create the frontend pod. ### Step Five: Create the frontend pod.
@ -385,251 +204,25 @@ Create a file named `frontend-controller.json`:
With this file, you can turn up your frontend with: With this file, you can turn up your frontend with:
```js ```shell
$ cluster/cloudcfg.sh -c examples/guestbook/frontend-controller.json create /replicationControllers $ cluster/cloudcfg.sh -c examples/guestbook/frontend-controller.json create /replicationControllers
Name Image(s) Label Query Replicas
Using master: kubernetes-master (external IP: 1.2.3.4) ---------- ---------- ---------- ----------
{ frontendController brendanburns/php-redis name=frontend 3
"id": "frontendController",
"desiredState": {
"replicas": 3,
"replicasInSet": {
"name": "frontend"
},
"podTemplate": {
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/php-redis",
"ports": [
{
"hostPort": 8080,
"containerPort": 80
}
]
}
]
}
},
"labels": {
"name": "frontend"
}
}
},
"labels": {
"name": "frontend"
}
}
``` ```
Once that's up you can list the pods in the cluster, to verify that the master, slaves and frontends are running: Once that's up you can list the pods in the cluster, to verify that the master, slaves and frontends are running:
```js ```shell
$ cluster/cloudcfg.sh list /pods $ cluster/cloudcfg.sh list /pods
Name Image(s) Host Labels
Using master: kubernetes-master (external IP: 1.2.3.4) ---------- ---------- ---------- ----------
{ redis-master-2 dockerfile/redis kubernetes-minion-3.c.briandpe-api.internal name=redis-master
"kind": "cluster#podList", 4d65822107fcfd52 brendanburns/redis-slave kubernetes-minion-3.c.briandpe-api.internal name=redisslave,replicationController=redisSlaveController
"items": [ 380704bb7b4d7c03 brendanburns/php-redis kubernetes-minion-3.c.briandpe-api.internal name=frontend,replicationController=frontendController
{ 55104dc76695721d brendanburns/php-redis kubernetes-minion-2.c.briandpe-api.internal name=frontend,replicationController=frontendController
"id": "redis-master-2", 365a858149c6e2d1 brendanburns/php-redis kubernetes-minion-1.c.briandpe-api.internal name=frontend,replicationController=frontendController
"labels": { 78629a0f5f3f164f brendanburns/redis-slave kubernetes-minion-4.c.briandpe-api.internal name=redisslave,replicationController=redisSlaveController
"name": "redis-master"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"name": "master",
"image": "dockerfile/redis",
"ports": [
{
"hostPort": 6379,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
},
{
"id": "4d65822107fcfd52",
"labels": {
"name": "redisslave",
"replicationController": "redisSlaveController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/redis-slave",
"ports": [
{
"hostPort": 6380,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
},
{
"id": "55104dc76695721d",
"labels": {
"name": "frontend",
"replicationController": "frontendController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/php-redis",
"ports": [
{
"hostPort": 8080,
"containerPort": 80
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-3.c.{project-id}.internal"
}
},
{
"id": "78629a0f5f3f164f",
"labels": {
"name": "redisslave",
"replicationController": "redisSlaveController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/redis-slave",
"ports": [
{
"hostPort": 6380,
"containerPort": 6379
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-2.c.{project-id}.internal"
}
},
{
"id": "380704bb7b4d7c03",
"labels": {
"name": "frontend",
"replicationController": "frontendController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/php-redis",
"ports": [
{
"hostPort": 8080,
"containerPort": 80
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-2.c.{project-id}.internal"
}
},
{
"id": "365a858149c6e2d1",
"labels": {
"name": "frontend",
"replicationController": "frontendController"
},
"desiredState": {
"manifest": {
"version": "",
"volumes": null,
"containers": [
{
"image": "brendanburns/php-redis",
"ports": [
{
"hostPort": 8080,
"containerPort": 80
}
]
}
]
}
},
"currentState": {
"manifest": {
"version": "",
"volumes": null,
"containers": null
},
"host": "kubernetes-minion-4.c.{project-id}.internal"
}
}
]
}
``` ```
You will see a single redis master pod, two redis slaves, and three frontend pods. You will see a single redis master pod, two redis slaves, and three frontend pods.
@ -676,6 +269,17 @@ if (isset($_GET['cmd']) === true) {
} ?> } ?>
``` ```
To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console], and visit `http://<host-ip>:8080`. You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcutil` tool. To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console] or the `gcutil` tool, and visit `http://<host-ip>:8080`.
```shell
$ gcutil listinstances
```
You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcutil` tool. The following command will allow traffic from any source to instances tagged `kubernetes-minion`:
```shell
$ gcutil addfirewall --allowed=tcp:8080 --target_tags=kubernetes-minion kubernetes-minion-8080
```
For details about limiting traffic to specific sources, see the [gcutil documentation][https://developers.google.com/compute/docs/gcutil/reference/firewall#addfirewall]
[cloud-console]: https://console.developer.google.com [cloud-console]: https://console.developer.google.com