couchdb-helm icon indicating copy to clipboard operation
couchdb-helm copied to clipboard

Figure out a way to avoid manual action after deploying a cluster with the helm chart

Open colearendt opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. After deploying the helm chart, there is a very helpful / explanatory message in NOTES.txt about cluster state:

Once all of the Pods are fully Ready, execute the following command to create
some required system databases

Describe the solution you'd like It would be nice if this manual command did not need to be run. What is it for? Is there a way to deploy a one-shot job or something alongside that will do this bootstrapping for us? What are the downsides if you run this command multiple times?

At a minimum, the quoting on the command was a little off which made it tricky to use

Describe alternatives you've considered

Additional context

It also surprises me that this is printed every time. I suspect there are values in helm that we could use to determine whether this is necessary to print. For instance, I'm pretty sure you can tell when you have an install vs. an upgrade.

https://github.com/apache/couchdb-helm/blob/78eff8c0fc3d8524f1a5c0c27880eaf2df98a2f4/couchdb/templates/NOTES.txt#L5-L8

colearendt avatar Jul 27 '22 01:07 colearendt

Just a bit more digging on this. At a minimum, this request seems to create the _replicator and _users databases.

It is also not idempotent:

First response:

curl -i -s http://127.0.0.1:5984/_cluster_setup -XPOST -H 'Content-Type: application/json' -d '{"action": "finish_cluster"}' -u admin
Enter host password for user 'admin':
HTTP/1.1 201 Created
Cache-Control: must-revalidate
Content-Length: 12
Content-Type: application/json
Date: Fri, 29 Jul 2022 13:38:34 GMT
Server: CouchDB/3.2.1 (Erlang OTP/23)
X-Couch-Request-ID: 4786904116
X-CouchDB-Body-Time: 0

{"ok":true}

Second:

curl -i -s http://127.0.0.1:5984/_cluster_setup -XPOST -H 'Content-Type: application/json' -d '{"action": "finish_cluster"}' -u admin
Enter host password for user 'admin':
HTTP/1.1 400 Bad Request
Cache-Control: must-revalidate
Content-Length: 63
Content-Type: application/json
Date: Fri, 29 Jul 2022 13:35:24 GMT
Server: CouchDB/3.2.1 (Erlang OTP/23)

{"error":"bad_request","reason":"Cluster is already finished"}

colearendt avatar Jul 29 '22 13:07 colearendt

Hi @colearendt,

I contributed with automation of placement couchdb nodes across availability zones in the cluster.

You can use the placementConfig parameters in values.yaml to use this feature, and in the last step the creation of system databases is executed in order to avoid manually steps on cluster creation.

Please use the tag 0.3.0 in placementConfig.image.tagin order to use the latest version of placement-manager code.

I understand that you may not want to automate the placement of nodes across availability zones, but it's useful if you're using a cluster in a cloud environment like AWS and you want to configure HA, for example.

fsalazarh avatar Sep 13 '22 13:09 fsalazarh