From f9e9a7c6861e9aa119ee0b343f23f187d7b64518 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 18 Jun 2014 17:03:38 -0700 Subject: [PATCH] Update guestbook example --- examples/guestbook/guestbook.md | 15 ++++++++++----- examples/guestbook/redis-master-service.json | 2 +- examples/guestbook/redis-slave-service.json | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/guestbook/guestbook.md b/examples/guestbook/guestbook.md index 8ab6e84640c..77b8c01c852 100644 --- a/examples/guestbook/guestbook.md +++ b/examples/guestbook/guestbook.md @@ -73,18 +73,20 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ### Step Two: Turn up the master service. A Kubernetes 'service' is a named load balancer that proxies traffic to one or more containers. The services in a Kubernetes cluster are discoverable inside other containers via environment variables. Services find the containers to load balance based on pod labels. -The pod that you created in Step One has the label `name=redis-master`, so the corresponding service is defined by that label. Create a file named `redis-master-service.json` that contains: +The pod that you created in Step One has the label `name=redis-master`. The selector field of the service determines which pods will receive the traffic sent to the service. Create a file named `redis-master-service.json` that contains: ```js { "id": "redismaster", "port": 10000, - "labels": { + "selector": { "name": "redis-master" } } ``` +This will cause all pods to see the redis master apparently running on localhost:10000. + Once you have that service description, you can create the service with the `cloudcfg` cli: ```shell @@ -126,7 +128,7 @@ Then you can create the service by running: ```shell $ cluster/cloudcfg.sh -c examples/guestbook/redis-slave-controller.json create /replicationControllers -Name Image(s) Label Query Replicas +Name Image(s) Selector Replicas ---------- ---------- ---------- ---------- redisSlaveController brendanburns/redis-slave name=redisslave 2 ``` @@ -160,11 +162,14 @@ Just like the master, we want to have a service to proxy connections to the read "port": 10001, "labels": { "name": "redis-slave" + }, + "selector": { + "name": "redis-slave" } } ``` -This time the label query for the service is `name=redis-slave`. +This time the selector for the service is `name=redis-slave`, because that identifies the pods running redis slaves. It may also be helpful to set labels on your service itself--as we've done here--to make it easy to locate them with the `cloudcfg -l "label=value" list sevices` command. Now that you have created the service specification, create it in your cluster with the `cloudcfg` CLI: @@ -206,7 +211,7 @@ With this file, you can turn up your frontend with: ```shell $ cluster/cloudcfg.sh -c examples/guestbook/frontend-controller.json create /replicationControllers -Name Image(s) Label Query Replicas +Name Image(s) Selector Replicas ---------- ---------- ---------- ---------- frontendController brendanburns/php-redis name=frontend 3 ``` diff --git a/examples/guestbook/redis-master-service.json b/examples/guestbook/redis-master-service.json index 654c7e93071..5d79ea37fdd 100644 --- a/examples/guestbook/redis-master-service.json +++ b/examples/guestbook/redis-master-service.json @@ -1,7 +1,7 @@ { "id": "redismaster", "port": 10000, - "labels": { + "selector": { "name": "redis-master" } } diff --git a/examples/guestbook/redis-slave-service.json b/examples/guestbook/redis-slave-service.json index d9e30f8363e..ee87e91252f 100644 --- a/examples/guestbook/redis-slave-service.json +++ b/examples/guestbook/redis-slave-service.json @@ -4,4 +4,7 @@ "labels": { "name": "redisslave" } + "selector": { + "name": "redisslave" + } }