Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster setup #42

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion couchdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: couchdb
version: 3.3.3
version: 3.4.0
appVersion: 2.3.1
description: A database featuring seamless multi-master sync, that scales from
big data to mobile, with an intuitive HTTP/JSON API and designed for
Expand Down
1 change: 1 addition & 0 deletions couchdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ CouchDB chart and their default values:
| `couchdbConfig` | Map allowing override elements of server .ini config | *See below* |
| `allowAdminParty` | If enabled, start cluster without admin account | false (requires creating a Secret) |
| `createAdminSecret` | If enabled, create an admin account and cookie secret | true |
| `clusterSetup` | Finalize cluster configuration by calling /_cluster_setup endpoint after installation | false |
| `schedulerName` | Name of the k8s scheduler (other than default) | `nil` |
| `erlangFlags` | Map of flags supplied to the underlying Erlang VM | name: couchdb, setcookie: monster
| `persistentVolume.enabled` | Boolean determining whether to attach a PV to each node | false
Expand Down
6 changes: 4 additions & 2 deletions couchdb/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ Apache CouchDB is starting. Check the status of the Pods using:

kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "couchdb.name" . }},release={{ .Release.Name }}"

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

kubectl exec --namespace {{ .Release.Namespace }} {{ if not .Values.allowAdminParty }}-it {{ end }}{{ template "couchdb.fullname" . }}-0 -c couchdb -- \
curl -s \
http://127.0.0.1:5984/_cluster_setup \
-X POST \
-H "Content-Type: application/json" \
{{- if .Values.allowAdminParty }}
-d '{"action": "finish_cluster"}'
Expand All @@ -18,3 +17,6 @@ some required system databases:
{{- end }}

Then it's time to relax.

As of chart version 3.4.0, the helm chart will attempt automatically to complete
cluster setup after installation if the `clusterSetup` value is set to true.
76 changes: 76 additions & 0 deletions couchdb/templates/clustersetup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{ if .Values.clusterSetup }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-setup-script
labels:
app: {{ template "couchdb.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
setup.sh: |
set -e
BASE_URL=http://{{ template "couchdb.fullname" . }}:5984
set -x

echo "Waiting for CouchDB service to start..."
until curl --silent -max-time 5 --head --fail "${BASE_URL}/_up"; do
flimzy marked this conversation as resolved.
Show resolved Hide resolved
printf "%s: CouchDB not up yet. Will try again\n" "$(date)"
sleep 2
done

echo "Initializing cluster"
touch /tmp/curl.cf
{{ if not .Values.allowAdminParty }}
echo "-u $(cat /tmp/admin-password/adminUsername):$(cat /tmp/admin-password/adminPassword)" >> /tmp/curl.cf
{{ end }}
curl -silent "${BASE_URL}/_cluster_setup" \
-H "Content-Type: application/json" \
-d '{"action": "finish_cluster"}' \
-K /tmp/curl.cf

echo "Success!"
---
apiVersion: batch/v1
kind: Job
metadata:
name: cluster-setup-job
labels:
app: {{ template "couchdb.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: cluster-setup-job
labels:
app: {{ template "couchdb.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
restartPolicy: Never
volumes:
- name: admin-password-volume
secret:
secretName: {{ template "couchdb.fullname" . }}
- name: cluster-setup-script-volume
configMap:
name: cluster-setup-script
containers:
- name: cluster-setup-job
image: "curlimages/curl:7.72.0"
command: [ "/bin/sh", "/tmp/setup/setup.sh" ]
volumeMounts:
- name: admin-password-volume
readOnly: true
mountPath: /tmp/admin-password
- name: cluster-setup-script-volume
mountPath: /tmp/setup
{{ end }}
2 changes: 2 additions & 0 deletions couchdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ allowAdminParty: false
## created ahead of time.
createAdminSecret: true

clusterSetup: false

adminUsername: admin
# adminPassword: this_is_not_secure
# adminHash: -pbkdf2-this_is_not_necessarily_secure_either
Expand Down
Binary file added docs/couchdb-3.4.0.tgz
Binary file not shown.