Merge pull request #1922 from brendandburns/guestbook

Update the services now that Services v2 has IP per service.
This commit is contained in:
Tim Hockin 2014-11-14 21:13:19 -08:00
commit d19826ccb9
7 changed files with 24 additions and 16 deletions

View File

@ -31,7 +31,6 @@ Use the file `examples/guestbook/redis-master.json` which describes a single pod
"image": "dockerfile/redis", "image": "dockerfile/redis",
"ports": [{ "ports": [{
"containerPort": 6379, "containerPort": 6379,
"hostPort": 6379
}] }]
}] }]
} }
@ -85,7 +84,7 @@ The pod that you created in Step One has the label `name=redis-master`. The sele
"id": "redismaster", "id": "redismaster",
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"port": 10000, "port": 6379,
"containerPort": 6379, "containerPort": 6379,
"selector": { "selector": {
"name": "redis-master" "name": "redis-master"
@ -99,12 +98,12 @@ to create the service with the `kubecfg` cli:
$ cluster/kubecfg.sh -c examples/guestbook/redis-master-service.json create services $ cluster/kubecfg.sh -c examples/guestbook/redis-master-service.json create services
ID Labels Selector Port ID Labels Selector Port
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
redismaster name=redis-master 10000 redismaster name=redis-master 6379
``` ```
This will cause all pods to see the redis master apparently running on localhost:10000. This will cause all pods to see the redis master apparently running on <ip>:6379.
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 6379).
### Step Three: Turn up the replicated slave pods. ### Step Three: Turn up the replicated slave pods.
Although the redis master is a single pod, the redis read slaves are a 'replicated' pod. In Kubernetes, a replication controller is responsible for managing multiple instances of a replicated pod. Although the redis master is a single pod, the redis read slaves are a 'replicated' pod. In Kubernetes, a replication controller is responsible for managing multiple instances of a replicated pod.
@ -127,7 +126,7 @@ Use the file `examples/guestbook/redis-slave-controller.json`
"containers": [{ "containers": [{
"name": "slave", "name": "slave",
"image": "brendanburns/redis-slave", "image": "brendanburns/redis-slave",
"ports": [{"containerPort": 6379, "hostPort": 6380}] "ports": [{"containerPort": 6379}]
}] }]
} }
}, },
@ -174,7 +173,7 @@ Just like the master, we want to have a service to proxy connections to the read
"id": "redisslave", "id": "redisslave",
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"port": 10001, "port": 6379,
"containerPort": 6379, "containerPort": 6379,
"labels": { "labels": {
"name": "redisslave" "name": "redisslave"
@ -193,7 +192,7 @@ Now that you have created the service specification, create it in your cluster w
$ cluster/kubecfg.sh -c examples/guestbook/redis-slave-service.json create services $ cluster/kubecfg.sh -c examples/guestbook/redis-slave-service.json create services
ID Labels Selector Port ID Labels Selector Port
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
redisslave name=redisslave name=redisslave 10001 redisslave name=redisslave name=redisslave 6379
``` ```
### Step Five: Create the frontend pod. ### Step Five: Create the frontend pod.

View File

@ -19,7 +19,10 @@
}] }]
} }
}, },
"labels": {"name": "frontend"} "labels": {
"name": "frontend",
"uses": "redisslave,redis-master"
}
}}, }},
"labels": {"name": "frontend"} "labels": {"name": "frontend"}
} }

View File

@ -2,9 +2,12 @@
"id": "frontend", "id": "frontend",
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"port": 9998, "port": 80,
"containerPort": 80, "containerPort": 80,
"selector": { "selector": {
"name": "frontend" "name": "frontend"
},
"labels": {
"name": "frontend"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"id": "redismaster", "id": "redis-master",
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"port": 10000, "port": 6379,
"containerPort": 6379, "containerPort": 6379,
"selector": { "selector": {
"name": "redis-master" "name": "redis-master"

View File

@ -1,11 +1,11 @@
{ {
"id": "redis-master-2", "id": "redis-master",
"kind": "Pod", "kind": "Pod",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"desiredState": { "desiredState": {
"manifest": { "manifest": {
"version": "v1beta1", "version": "v1beta1",
"id": "redis-master-2", "id": "redis-master",
"containers": [{ "containers": [{
"name": "master", "name": "master",
"image": "dockerfile/redis", "image": "dockerfile/redis",

View File

@ -18,7 +18,10 @@
}] }]
} }
}, },
"labels": {"name": "redisslave"} "labels": {
"name": "redisslave",
"uses": "redis-master",
}
}}, }},
"labels": {"name": "redisslave"} "labels": {"name": "redisslave"}
} }

View File

@ -2,7 +2,7 @@
"id": "redisslave", "id": "redisslave",
"kind": "Service", "kind": "Service",
"apiVersion": "v1beta1", "apiVersion": "v1beta1",
"port": 10001, "port": 6379,
"containerPort": 6379, "containerPort": 6379,
"labels": { "labels": {
"name": "redisslave" "name": "redisslave"