Skip to content

Commit

Permalink
Merge pull request kubernetes#5079 from dchen1107/doc
Browse files Browse the repository at this point in the history
Convert resource-quota and rethinkdb to v1beta3
  • Loading branch information
bgrant0607 committed Mar 10, 2015
2 parents a4d79bf + 67be6bf commit 8273fff
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/resourcequota/v1beta3/resource-quota.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"apiVersion": "v1beta3",
"kind": "ResourceQuota",
"metadata": {
"name": "quota",
},
"spec": {
"hard": {
"memory": "1Gi",
"cpu": "20",
"pods": "10",
"services": "5",
"replicationcontrollers":"20",
"resourcequotas":"1",
},
}
}
106 changes: 106 additions & 0 deletions examples/rethinkdb/v1beta3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
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**

antmanler/rethinkdb will discover peer using endpoints provided by kubernetes_ro service,
so first create a service so the following pod can query its endpoint

```shell
kubectl create -f driver-service.yaml
```

check out:

```shell
$kubectl get se
NAME LABELS SELECTOR IP PORT
rethinkdb-driver db=influxdb db=rethinkdb 10.241.105.47 28015
```

**Step 2**

start fist server in cluster

```shell
kubectl create -f rc.yaml
```

Actually, you can start servers as many as you want at one time, just modify the `replicas` in `rc.ymal`

check out again:

```shell
$kubectl get po
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS
99f6d361-abd6-11e4-a1ea-001c426dbc28 10.240.2.68 rethinkdb rethinkdb:1.16.0 10.245.2.2/ db=rethinkdb,role=replicas Running
```

**Done!**


---

Scale
-----

You can scale up you cluster using `kubectl resize`, and new pod will join to exsits cluster automatically, for example


```shell
$kubectl resize rc rethinkdb-rc-1.16.0 --replicas=3
resized
$kubectl get po
POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS
99f6d361-abd6-11e4-a1ea-001c426dbc28 10.240.2.68 rethinkdb rethinkdb:1.16.0 10.245.2.2/ db=rethinkdb,role=replicas Running
d10182b5-abd6-11e4-a1ea-001c426dbc28 10.240.26.14 rethinkdb rethinkdb:1.16.0 10.245.2.4/ db=rethinkdb,role=replicas Running
d101c1a4-abd6-11e4-a1ea-001c426dbc28 10.240.11.14 rethinkdb rethinkdb:1.16.0 10.245.2.3/ db=rethinkdb,role=replicas Running
```

Admin
-----

You need a separate pod (which labled as role:admin) to access Web Admin UI

```shell
kubectl create -f admin-pod.yaml
kubectl create -f admin-service.yaml
```

find the service

```shell
$kubectl get se
NAME LABELS SELECTOR IP PORT
rethinkdb-admin db=influxdb db=rethinkdb,role=admin 10.241.220.209 8080
rethinkdb-driver db=influxdb db=rethinkdb 10.241.105.47 28015
```

open a web browser and access to *http://10.241.220.209:8080* to manage you cluster

**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**

* All services and pods are placed under namespace `rethinkdb`.

* `gen_pod.sh` is using to generate pod templates for my local cluster,
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.

* see [antmanler/rethinkdb-k8s](https://github.com/antmanler/rethinkdb-k8s) for detail
25 changes: 25 additions & 0 deletions examples/rethinkdb/v1beta3/admin-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1beta3
kind: Pod
metadata:
labels:
db: rethinkdb
role: admin
name: rethinkdb-admin-1.16.0
namespace: rethinkdb
spec:
containers:
- image: antmanler/rethinkdb:1.16.0
name: rethinkdb
ports:
- containerPort: 8080
name: admin-port
- containerPort: 28015
name: driver-port
- containerPort: 29015
name: cluster-port
volumeMounts:
- mountPath: /data/rethinkdb_data
name: rethinkdb-storage
volumes:
- name: rethinkdb-storage
emptyDir: {}
13 changes: 13 additions & 0 deletions examples/rethinkdb/v1beta3/admin-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1beta3
kind: Service
metadata:
labels:
db: influxdb
name: rethinkdb-admin
namespace: rethinkdb
spec:
containerPort: 8080
port: 8080
selector:
db: rethinkdb
role: admin
12 changes: 12 additions & 0 deletions examples/rethinkdb/v1beta3/driver-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1beta3
kind: Service
metadata:
labels:
db: influxdb
name: rethinkdb-driver
namespace: rethinkdb
spec:
containerPort: 28015
port: 28015
selector:
db: rethinkdb
34 changes: 34 additions & 0 deletions examples/rethinkdb/v1beta3/rc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v1beta3
kind: ReplicationController
metadata:
labels:
db: rethinkdb
name: rethinkdb-rc-1.16.0
namespace: rethinkdb
spec:
replicas: 1
selector:
db: rethinkdb
role: replicas
template:
metadata:
labels:
db: rethinkdb
role: replicas
spec:
containers:
- image: antmanler/rethinkdb:1.16.0
name: rethinkdb
ports:
- containerPort: 8080
name: admin-port
- containerPort: 28015
name: driver-port
- containerPort: 29015
name: cluster-port
volumeMounts:
- mountPath: /data/rethinkdb_data
name: rethinkdb-storage
volumes:
- name: rethinkdb-storage
emptyDir: {}

0 comments on commit 8273fff

Please sign in to comment.