This is an automated email from the ASF dual-hosted git repository.
willholley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-helm.git
The following commit(s) were added to refs/heads/main by this push:
new 7b52f9f Automatically finalize the cluster with a post-install job
(#108)
7b52f9f is described below
commit 7b52f9f53064d57b42cc07166c4ccc6584668db3
Author: rileyai-dev <[email protected]>
AuthorDate: Tue Jan 17 19:13:49 2023 +0100
Automatically finalize the cluster with a post-install job (#108)
Create a job after the installation to finalize the cluster. The job can
also create default databases such as _global_changes.
---
couchdb/Chart.yaml | 2 +-
couchdb/NEWS.md | 4 ++++
couchdb/README.md | 15 +++++++++-----
couchdb/README.md.gotmpl | 7 ++++++-
couchdb/templates/NOTES.txt | 2 +-
couchdb/templates/job.yaml | 50 +++++++++++++++++++++++++++++++++++++++++++++
couchdb/values.yaml | 15 ++++++++++++++
7 files changed, 87 insertions(+), 8 deletions(-)
diff --git a/couchdb/Chart.yaml b/couchdb/Chart.yaml
index 2dfde9a..027ee63 100644
--- a/couchdb/Chart.yaml
+++ b/couchdb/Chart.yaml
@@ -1,6 +1,6 @@
apiVersion: v1
name: couchdb
-version: 4.0.0
+version: 4.1.0
appVersion: 3.2.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
diff --git a/couchdb/NEWS.md b/couchdb/NEWS.md
index 1aefac1..9aef513 100644
--- a/couchdb/NEWS.md
+++ b/couchdb/NEWS.md
@@ -1,5 +1,9 @@
# NEWS
+## 4.1.0
+
+- Added the `autoSetup` to automatically finalize the cluster after
installation
+
## 4.0.0
- Simplified the `adminHash` in the secret
diff --git a/couchdb/README.md b/couchdb/README.md
index 5b6c8b0..364600b 100644
--- a/couchdb/README.md
+++ b/couchdb/README.md
@@ -1,6 +1,6 @@
# CouchDB
-

+

Apache CouchDB is a database featuring seamless multi-master sync, that scales
from big data to mobile, with an intuitive HTTP/JSON API and designed for
@@ -18,7 +18,7 @@ storage volumes to each Pod in the Deployment.
```bash
$ helm repo add couchdb https://apache.github.io/couchdb-helm
$ helm install couchdb/couchdb \
- --version=4.0.0 \
+ --version=4.1.0 \
--set allowAdminParty=true \
--set couchdbConfig.couchdb.uuid=$(curl
https://www.uuidgenerator.net/api/version4 2>/dev/null | tr -d -)
```
@@ -44,7 +44,7 @@ Afterwards install the chart replacing the UUID
```bash
$ helm install \
--name my-release \
- --version=4.0.0 \
+ --version=4.1.0 \
--set couchdbConfig.couchdb.uuid=decafbaddecafbaddecafbaddecafbad \
couchdb/couchdb
```
@@ -78,7 +78,7 @@ and then install the chart while overriding the
`createAdminSecret` setting:
```bash
$ helm install \
--name my-release \
- --version=4.0.0 \
+ --version=4.1.0 \
--set createAdminSecret=false \
--set couchdbConfig.couchdb.uuid=decafbaddecafbaddecafbaddecafbad \
couchdb/couchdb
@@ -133,7 +133,7 @@ version semantics. You can upgrade directly from
`stable/couchdb` to this chart
```bash
$ helm repo add couchdb https://apache.github.io/couchdb-helm
-$ helm upgrade my-release --version=4.0.0 couchdb/couchdb
+$ helm upgrade my-release --version=4.1.0 couchdb/couchdb
```
## Configuration
@@ -193,6 +193,11 @@ A variety of other parameters are also configurable. See
the comments in the
| `annotations` |
|
| `tolerations` |
|
| `resources` |
|
+| `autoSetup.enabled` | false (if set to true, must have
`service.enabled` set to true and a correct `adminPassword` - deploy it with
the `--wait` flag to avoid first jobs failure) |
+| `autoSetup.image.repository` | alpine/curl
|
+| `autoSetup.image.tag` | latest
|
+| `autoSetup.image.pullPolicy` | Always
|
+| `autoSetup.defaultDatabases` | [`_global_changes`]
|
| `service.annotations` |
|
| `service.enabled` | true
|
| `service.type` | ClusterIP
|
diff --git a/couchdb/README.md.gotmpl b/couchdb/README.md.gotmpl
index 28d8761..3eefec8 100644
--- a/couchdb/README.md.gotmpl
+++ b/couchdb/README.md.gotmpl
@@ -184,7 +184,12 @@ A variety of other parameters are also configurable. See
the comments in the
| `topologySpreadConstraints` |
|
| `annotations` |
|
| `tolerations` |
|
-| `resources` |
|
|
+| `resources` |
|
+| `autoSetup.enabled` | false (if set to true, must have
`service.enabled` set to true and a correct `adminPassword` - deploy it with
the `--wait` flag to avoid first jobs failure) |
+| `autoSetup.image.repository` | alpine/curl
|
+| `autoSetup.image.tag` | latest
|
+| `autoSetup.image.pullPolicy` | Always
|
+| `autoSetup.defaultDatabases` | [`_global_changes`]
|
| `service.annotations` |
|
| `service.enabled` | true
|
| `service.type` | ClusterIP
|
diff --git a/couchdb/templates/NOTES.txt b/couchdb/templates/NOTES.txt
index 0727ca1..7a9dccd 100644
--- a/couchdb/templates/NOTES.txt
+++ b/couchdb/templates/NOTES.txt
@@ -2,7 +2,7 @@ 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
+Skip this step if autoSetup is enabled - 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 -- \
diff --git a/couchdb/templates/job.yaml b/couchdb/templates/job.yaml
new file mode 100644
index 0000000..fa5aafc
--- /dev/null
+++ b/couchdb/templates/job.yaml
@@ -0,0 +1,50 @@
+{{- if .Values.autoSetup -}}
+{{- if and .Values.autoSetup.enabled .Values.service.enabled -}}
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: "{{ .Release.Name }}-post-install"
+ labels:
+ app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
+ app.kubernetes.io/instance: {{ .Release.Name | quote }}
+ app.kubernetes.io/version: {{ .Chart.AppVersion }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ annotations:
+ "helm.sh/hook": post-install
+spec:
+ template:
+ metadata:
+ name: "{{ .Release.Name }}-post-install"
+ labels:
+ app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
+ app.kubernetes.io/instance: {{ .Release.Name | quote }}
+ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ spec:
+ restartPolicy: OnFailure
+ containers:
+ - name: cluster-setup
+ image: {{ .Values.autoSetup.image.repository }}:{{
.Values.autoSetup.image.tag }}
+ imagePullPolicy: {{ .Values.autoSetup.image.pullPolicy }}
+ command:
+ - 'sh'
+ - '-c'
+ - 'curl -s http://$COUCHDB_ADDRESS/_cluster_setup -X POST -H
"Content-Type: application/json" -d "{\"action\": \"finish_cluster\"}" -u
$COUCHDB_ADMIN:$COUCHDB_PASS && export IFS=","; for db_name in $DEFAULT_DBS; do
curl -X PUT http://$COUCHDB_ADDRESS/$db_name -u $COUCHDB_ADMIN:$COUCHDB_PASS;
done'
+ env:
+ - name: DEFAULT_DBS
+ value: {{ join "," .Values.autoSetup.defaultDatabases }}
+ - name: COUCHDB_ADDRESS
+ value: "{{ template "couchdb.svcname" . }}.{{ .Release.Namespace
}}.svc.cluster.local:{{ .Values.service.externalPort}}"
+ - name: COUCHDB_ADMIN
+ valueFrom:
+ secretKeyRef:
+ name: {{ template "couchdb.fullname" . }}
+ key: adminUsername
+ - name: COUCHDB_PASS
+ valueFrom:
+ secretKeyRef:
+ name: {{ template "couchdb.fullname" . }}
+ key: adminPassword
+ backoffLimit: 2
+ ttlSecondsAfterFinished: 600
+{{- end -}}
+{{- end -}}
diff --git a/couchdb/values.yaml b/couchdb/values.yaml
index bc61ca2..1deb2c5 100644
--- a/couchdb/values.yaml
+++ b/couchdb/values.yaml
@@ -9,6 +9,21 @@ clusterSize: 3
# ref: https://kubernetes.io/docs/concepts/configuration/secret/
allowAdminParty: false
+# Set it to true to automatically enable the cluster after installation.
+# It will create a post-install job that will send the {"action":
"finish_cluster"}
+# message to CouchDB to finalize the cluster and add the defaultDatabases
listed.
+# Note that this job needs service.enabled to be set to true and if you use
adminHash,
+# a valid adminPassword in the secret. Also set the --wait flag when you
install to
+# avoid first jobs failure (helm install --wait ...)
+autoSetup:
+ enabled: false
+ image:
+ repository: alpine/curl
+ tag: latest
+ pullPolicy: Always
+ defaultDatabases:
+ - _global_changes
+
# -- If createAdminSecret is enabled a Secret called <ReleaseName>-couchdb will
# be created containing auto-generated credentials. Users who prefer to set
# these values themselves have a couple of options: