2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
<!-- BEGIN STRIP_FOR_RELEASE -->
2015-07-16 17:02:26 +00:00
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< h2 > PLEASE NOTE: This document applies to the HEAD of the source tree< / h2 >
If you are using a released version of Kubernetes, you should
refer to the docs that go with that version.
< strong >
The latest 1.0.x release of this document can be found
[here ](http://releases.k8s.io/release-1.0/examples/rethinkdb/README.md ).
Documentation for other releases can be found at
[releases.k8s.io ](http://releases.k8s.io ).
< / strong >
--
2015-07-13 22:15:35 +00:00
2015-07-14 00:13:09 +00:00
<!-- END STRIP_FOR_RELEASE -->
<!-- END MUNGE: UNVERSIONED_WARNING -->
2015-02-04 04:35:13 +00:00
RethinkDB Cluster on Kubernetes
==============================
Setting up a [rethinkdb ](http://rethinkdb.com/ ) cluster on [kubernetes ](http://kubernetes.io )
**Features**
* Auto configuration cluster by querying info from k8s
* Simple
Quick start
-----------
**Step 1**
2015-08-03 23:14:09 +00:00
Rethinkdb will discover its peer using endpoints provided by kubernetes service,
2015-02-11 20:06:06 +00:00
so first create a service so the following pod can query its endpoint
2015-02-04 04:35:13 +00:00
2015-07-20 04:38:53 +00:00
```sh
2015-07-16 00:20:39 +00:00
$kubectl create -f examples/rethinkdb/driver-service.yaml
2015-02-04 04:35:13 +00:00
```
check out:
2015-07-20 04:38:53 +00:00
```sh
2015-07-07 13:27:49 +00:00
$kubectl get services
2015-08-08 04:08:43 +00:00
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
rethinkdb-driver 10.0.27.114 < none > 28015/TCP db=rethinkdb 10m
2015-07-07 13:27:49 +00:00
[...]
2015-02-04 04:35:13 +00:00
```
**Step 2**
2015-08-03 23:14:09 +00:00
start the first server in the cluster
2015-02-04 04:35:13 +00:00
2015-07-20 04:38:53 +00:00
```sh
2015-07-16 00:20:39 +00:00
$kubectl create -f examples/rethinkdb/rc.yaml
2015-02-04 04:35:13 +00:00
```
Actually, you can start servers as many as you want at one time, just modify the `replicas` in `rc.ymal`
check out again:
2015-07-20 04:38:53 +00:00
```sh
2015-07-07 13:27:49 +00:00
$kubectl get pods
NAME READY REASON RESTARTS AGE
[...]
rethinkdb-rc-r4tb0 1/1 Running 0 1m
2015-02-04 04:35:13 +00:00
```
**Done!**
---
Scale
-----
2015-08-03 23:14:09 +00:00
You can scale up your cluster using `kubectl scale` . The new pod will join to the existing cluster automatically, for example
2015-02-04 04:35:13 +00:00
2015-07-20 04:38:53 +00:00
```sh
2015-07-07 13:27:49 +00:00
$kubectl scale rc rethinkdb-rc --replicas=3
2015-05-21 21:10:25 +00:00
scaled
2015-07-07 13:27:49 +00:00
$kubectl get pods
NAME READY REASON RESTARTS AGE
[...]
rethinkdb-rc-f32c5 1/1 Running 0 1m
rethinkdb-rc-m4d50 1/1 Running 0 1m
rethinkdb-rc-r4tb0 1/1 Running 0 3m
2015-02-04 04:35:13 +00:00
```
Admin
-----
2015-06-05 15:35:17 +00:00
You need a separate pod (labeled as role:admin) to access Web Admin UI
2015-02-04 04:35:13 +00:00
2015-07-20 04:38:53 +00:00
```sh
2015-07-16 00:20:39 +00:00
kubectl create -f examples/rethinkdb/admin-pod.yaml
kubectl create -f examples/rethinkdb/admin-service.yaml
2015-02-04 04:35:13 +00:00
```
find the service
2015-08-08 04:08:43 +00:00
```console
2015-07-22 19:00:25 +00:00
$kubectl get services
2015-08-08 04:08:43 +00:00
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
2015-07-07 13:27:49 +00:00
[...]
2015-08-08 04:08:43 +00:00
rethinkdb-admin 10.0.131.19 104.197.19.120 8080/TCP db=rethinkdb,role=admin 10m
rethinkdb-driver 10.0.27.114 < none > 28015/TCP db=rethinkdb 20m
2015-05-07 22:44:58 +00:00
```
2015-08-03 23:14:09 +00:00
We request an external load balancer in the [admin-service.yaml ](admin-service.yaml ) file:
2015-05-07 22:44:58 +00:00
```
2015-06-10 21:54:42 +00:00
type: LoadBalancer
2015-02-04 04:35:13 +00:00
```
2015-08-03 23:14:09 +00:00
The external load balancer allows us to access the service from outside the firewall via an external IP, 104.197.19.120 in this case.
2015-05-07 22:44:58 +00:00
2015-06-26 19:13:43 +00:00
Note that you may need to create a firewall rule to allow the traffic, assuming you are using Google Compute Engine:
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```console
2015-05-07 22:44:58 +00:00
$ gcloud compute firewall-rules create rethinkdb --allow=tcp:8080
```
Now you can open a web browser and access to *http://104.197.19.120:8080* to manage your cluster.
2015-02-04 04:35:13 +00:00
**Why not just using pods in replicas?**
This is because kube-proxy will act as a load balancer and send your traffic to different server,
since the ui is not stateless when playing with Web Admin UI will cause `Connection not open on server` error.
- - -
**BTW**
* `gen_pod.sh` is using to generate pod templates for my local cluster,
2015-07-14 16:37:37 +00:00
the generated pods which is using `nodeSelector` to force k8s to schedule containers to my designate nodes, for I need to access persistent data on my host dirs. Note that one needs to label the node before 'nodeSelector' can work, see this [tutorial ](../../docs/user-guide/node-selection/ )
2015-02-04 04:35:13 +00:00
2015-07-17 02:01:02 +00:00
* see [antmanler/rethinkdb-k8s ](https://github.com/antmanler/rethinkdb-k8s ) for detail
2015-05-14 22:12:45 +00:00
2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
2015-05-14 22:12:45 +00:00
[![Analytics ](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/rethinkdb/README.md?pixel )]()
2015-07-14 00:13:09 +00:00
<!-- END MUNGE: GENERATED_ANALYTICS -->