How to Deploy CouchDB on GKE



Robin Storage on Google Marketplace

In this tutorial, we will deploy a CouchDB database on Google Kubernetes Engine (GKE) using Helm and load data in the database.

Before you start this tutorial, make sure you have installed Robin Storage on GKE.

Deploy CouchDB Database on GKE using Helm

Let us create a CouchDB database using Helm and Robin Storage. In the Cloud Shell Run the following command in the Cloud Shell. This command will install CouchDB cluster as a StatefulSet. We are setting the storageClass to robin-0-3 to benefit from data management capabilities Robin Storage brings.

helm install incubator/couchdb --name couch --tls --set persistentVolume.storageClass=robin-0-3 --set persistentVolume.enabled=true --namespace default --tiller-namespace default

Let’s confirm that our Database is deployed and all relevant Kubernetes resources are ready.

helm list --tls --tiller-namespace default -c couch

You should be able to see an output showing the status of your CouchDB database.

Get Service IP address of our CouchDB database:

export IP_ADDRESS=$(kubectl get service couch-svc-couchdb -o jsonpath={.spec.clusterIP})

Get admin user and password of our CouchDB from Kubernetes Secret:

export COUCHDB_USER=$(kubectl get secret couch-couchdb -o go-template='{{ .data.adminUsername }}’ | base64 –decode)

export COUCHDB_PASSWORD=$(kubectl get secret couch-couchdb -o go-template='{{ .data.adminPassword }}’ | base64 –decode)

Adding data to the CouchDB database

Let us load data into our CouchDB database. Let us create a database robindb:

curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb

Let’s create document employees under database robindb and add 5 records to it:

curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb/"employees" -d '{ "features": [ { " Name " : " John " , " age " :" 23 " , " Designation " : " Designer " }, { " Name " : " Smith " , " age " :" 24 " , " Designation " : " Programmer " }, { " Name " : " Emma " , " age " :" 22 " , " Designation " : " Manager "}, { " Name " : " Shawn " , " age " :" 32 " , " Designation " : " Lead " }, { " Name " : " Chris " , " age " :" 28 " , " Designation " : " Engineer " } ] }'

After adding document, we should see the following :

curl -X GET
http://$COUCHDB_USER:$COUCHDB_PASSWORD@$IP_ADDRESS:5984/robindb/employees

{“_id”:”employees”,”_rev”:”1-eb488c58ef864b93a1e462bb8f33b9e1″,”features”:[{”
Name “:” John “,” age “:” 23 “,” Designation “:” Designer “},{” Name “:” Smith “,” age
“:” 24 “,” Designation “:” Programmer “},{” Name “:” Emma “,” age “:” 22 “,”
Designation “:” Manager “},{” Name “:” Shawn “,” age “:” 32 “,” Designation “:” Lead”},{” Name “:” Chris “,” age “:” 28 “,” Designation “:” Engineer “}]}

We have now deployed a CouchDB database on GKE with some sample data.

To benefit from data management capabilities Robin brings, such as taking snapshots, making clones, and creating backups, we have to register this CouchDB Helm release as an application with Robin.

Registering the Helm release as an application

To benefit from the data management capabilities, we’ll register our CouchDB database with Robin. Doing so will let Robin map and track all resources associated with the Helm release for this CouchDB app. To register the Helm release as an application, run the following command:

robin app register couch --app helm/couch

Let’s verify Robin is now tracking our CouchDB Helm release as a single entity (app).

robin app list --name couch

You should see an output similar to this.

We have successfully registered our Helm release as an app called “couch”. Let us check the status on the app:

robin app info couch

The output should look like this.

This concludes the Deploy CouchDB on GKE tutorial. Now that we have deployed the CouchDB database, loaded data, and registered the CouchDB Helm release with Robin Storage, we can create a CouchDB database snapshot and create a CouchDB clone that includes the app plus data.


Snapshot CouchDB on GKE Tutorial


CouchDB on GKE – Clone Tutorial


Share with: