rethinkdb

by neil-pozetroninc

Helm chartv1.1.9App 2.4.1Apache-2.0

The open-source database for the realtime web

About this chart

RethinkDB Cluster Helm Chart

Prerequisites Details

  • Kubernetes 1.5+ with Beta APIs enabled.
  • PV support on the underlying infrastructure.

StatefulSet Details

  • https://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/

StatefulSet Caveats

  • https://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/#limitations

Acknowledgment of Previous Works

This is a simple fork of the deprecated official helm chart for RethinkDB which was originally contributed by https://github.com/meenie.

That work too heavily borrowed and extended code (peer discovery and probe) from the following project to build the Helm Chart and Docker image: https://github.com/rosskukulinski/kubernetes-rethinkdb-cluster

Chart Details

This chart implements a dynamically scalable RethinkDB Cluster using Kubernetes StatefulSets.

Installing the Chart

To install the chart with the release name my-release:

$ helm install --name my-release pozetron/rethinkdb

Configuration

The following table lists the configurable parameters of the rethinkdb chart and their default values.

ParameterDescriptionDefault
image.nameCustom RethinkDB image name for auto-joining and probepozetroninc/rethinkdb-cluster
image.tagCustom RethinkDB image tag0.1.0
image.pullPolicyCustom RethinkDB image pull policyIfNotPresent
cluster.replicasNumber of RethinkDB Cluster replicas3
cluster.resourcesResource configuration for each RethinkDB Cluster Pod{}
cluster.podAnnotationsAnnotations to be added to RethinkDB Cluster Pods{}
cluster.service.annotationsAnnotations to be added to RethinkDB Cluster Service{}
cluster.storageClass.enabledIf true, create a StorageClass for the cluster. Note: You must set a provisionerfalse
cluster.storageClass.provisionerProvisioner definition for StorageClassundefined
cluster.storageClass.parametersParameters for StorageClassundefined
cluster.persistentVolume.enabledIf true, persistent volume claims are createdtrue
cluster.persistentVolume.storageClassPersistent volume storage classdefault
cluster.persistentVolume.accessModePersistent volume access modes[ReadWriteOnce]
cluster.persistentVolume.sizePersistent volume size1Gi
cluster.persistentVolume.annotationsPersistent volume annotations{}
cluster.rethinkCacheSizeRethinkDB cache-size value in MB100
proxy.replicasNumber of RethinkDB Proxy replicas1
proxy.resourcesResource configuration for each RethinkDB Proxy Pod{}
proxy.podAnnotationsAnnotations to be added to RethinkDB Proxy Pods{}
proxy.service.typeRethinkDB Proxy Service TypeClusterIP
proxy.service.annotationsAnnotations to be added to RethinkDB Cluster Service{}
proxy.service.clusterIPInternal controller proxy service IP""
proxy.service.externalIPsController service external IP addresses[]
proxy.service.loadBalancerIPIP address to assign to load balancer (if supported)""
proxy.service.loadBalancerSourceRangesList of IP CIDRs allowed access to load balancer (if supported)[]
proxy.driverTLS.enabledShould RethinkDB Proxy TLS be enabled. Note: If enabled, you must set a key and certfalse
proxy.driverTLS.keyRSA Private Keyundefined
proxy.driverTLS.certCertificateundefined
ports.clusterRethinkDB Cluster Port29015
ports.driverRethinkDB Driver Port28015
ports.adminRethinkDB Admin Port8080
rethinkdbPasswordPassword for the RethinkDB Admin userrethinkdb

Specify each parameter using the --set key=value[,key=value] argument to helm install.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

$ helm install --name my-release -f values.yaml pozetron/rethinkdb

Tip: You can use the default values.yaml

Important: Admin Password Management

The initial admin password is set by the config value rethinkdbPassword. This value is also used by the probe which periodically checks if the RethinkDB Cluster and Proxy are still running. If you change the RethinkDB admin password via a query (i.e. r.db('rethinkdb').table('users').update({password: 'new-password'})) this will cause the probe to fail which then restarts the pods over and over. To stablize the cluster, you also need to use helm upgrade to update the password in the Kubernetes Secrets storage by doing:

$ helm upgrade --set rethinkdbPassword=new-password my-release pozetron/rethinkdb

Opening Up the RethinkDB Admin Console

The admin port is not available outside of the cluster for security reasons. The only way to access the admin console is to use a Kubernetes Proxy. To open up the admin console:

$ kubectl proxy
Starting to serve on 127.0.0.1:8001

Then use the following URL: http://localhost:8001/api/v1/namespaces/NAMESPACE/services/RELEASE_NAME-rethinkdb-admin/proxy Make sure a replace NAMEPSPACE with the correct namespace and RELEASE_NAME that was used when installing the chart.

And then open up your browser to http://localhost:8080 and you should see the admin console

Cleanup orphaned Persistent Volumes

Deleting a StatefulSet will not delete associated Persistent Volumes.

Do the following after deleting the chart release to clean up orphaned Persistent Volumes.

$ kubectl delete pvc -l release=my-release

Failover

If any RethinkDB server fails it gets re-joined eventually. You can test the scenario by killing process of one of the pods:

$ kubectl get pods -l release=my-release
NAME                                          READY     STATUS    RESTARTS   AGE
my-release-rethinkdb-cluster-0                1/1       Running   0          1m
my-release-rethinkdb-cluster-1                1/1       Running   0          2m
my-release-rethinkdb-cluster-2                1/1       Running   0          2m
my-release-rethinkdb-proxy-2517940628-81dxd   1/1       Running   1          1m

$ kubectl exec -it my-release-rethinkdb-cluster-0 -- ps aux | grep 'rethinkdb'
root         7  0.1  2.1 233496 43408 ?        Ssl  16:56   0:00 rethinkdb --ser
root        26  0.0  0.4 146948  8204 ?        S    16:56   0:00 rethinkdb --ser
root       100  0.0  0.7 157192 16060 ?        S    16:56   0:00 rethinkdb --ser

$ kubectl exec -it my-release-rethinkdb-cluster-0 -- kill 7

Scaling

Scaling should be managed by helm upgrade, which is the recommended way. Example:

$ helm upgrade --set cluster.replicas=4 my-release pozetron/rethinkdb

Deploy rethinkdb with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has rethinkdb on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartrethinkdb is pinned at v1.1.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply