Update the services now that Services v2 has IP per service.

pull/6/head
Brendan Burns 2014-10-20 21:16:21 -07:00
parent 97cb1fa2df
commit 110b5a3345
8 changed files with 30 additions and 22 deletions

View File

@ -31,7 +31,6 @@ Use the file `examples/guestbook/redis-master.json` which describes a single pod
"image": "dockerfile/redis",
"ports": [{
"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",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 10000,
"port": 6379,
"containerPort": 6379,
"selector": {
"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
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.
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": [{
"name": "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",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 10001,
"port": 6379,
"containerPort": 6379,
"labels": {
"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
ID Labels Selector Port
---------- ---------- ---------- ----------
redisslave name=redisslave name=redisslave 10001
redisslave name=redisslave name=redisslave 6379
```
### 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"}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -99,15 +99,15 @@ kube::log::status "Testing kubectl(pods)"
"${kube_cmd[@]}" get pods "${kube_flags[@]}"
"${kube_cmd[@]}" create -f examples/guestbook/redis-master.json "${kube_flags[@]}"
"${kube_cmd[@]}" get pods "${kube_flags[@]}"
"${kube_cmd[@]}" get pod redis-master-2 "${kube_flags[@]}"
[[ "$("${kube_cmd[@]}" get pod redis-master-2 -o template --output-version=v1beta1 -t '{{ .id }}' "${kube_flags[@]}")" == "redis-master-2" ]]
output_pod=$("${kube_cmd[@]}" get pod redis-master-2 -o json --output-version=v1beta1 "${kube_flags[@]}")
"${kube_cmd[@]}" delete pod redis-master-2 "${kube_flags[@]}"
"${kube_cmd[@]}" get pod redis-master "${kube_flags[@]}"
[[ "$("${kube_cmd[@]}" get pod redis-master -o template --output-version=v1beta1 -t '{{ .id }}' "${kube_flags[@]}")" == "redis-master" ]]
output_pod=$("${kube_cmd[@]}" get pod redis-master -o json --output-version=v1beta1 "${kube_flags[@]}")
"${kube_cmd[@]}" delete pod redis-master "${kube_flags[@]}"
[[ $("${kube_cmd[@]}" get pods -o template -t '{{ len .items }}' "${kube_flags[@]}") -eq 0 ]]
echo $output_pod | "${kube_cmd[@]}" create -f - "${kube_flags[@]}"
[[ $("${kube_cmd[@]}" get pods -o template -t '{{ len .items }}' "${kube_flags[@]}") -eq 1 ]]
"${kube_cmd[@]}" get pods -o yaml "${kube_flags[@]}" | grep -q "id: redis-master-2"
"${kube_cmd[@]}" describe pod redis-master-2 "${kube_flags[@]}" | grep -q 'Name:.*redis-master-2'
"${kube_cmd[@]}" get pods -o yaml "${kube_flags[@]}" | grep -q "id: redis-master"
"${kube_cmd[@]}" describe pod redis-master "${kube_flags[@]}" | grep -q 'Name:.*redis-master'
"${kube_cmd[@]}" delete -f examples/guestbook/redis-master.json "${kube_flags[@]}"
kube::log::status "Testing kubectl(services)"