Merge pull request #5 from apache/update-gh-pages

Serve GitHub pages from docs folder of master branch
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index fd7bedc..a1db437 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -33,3 +33,4 @@
 - [ ] Chart Version bumped
 - [ ] e2e tests pass
 - [ ] Variables are documented in the README.md
+- [ ] Chart tgz added to /docs and index updated
diff --git a/Makefile b/Makefile
index 6963b96..bf58f7e 100644
--- a/Makefile
+++ b/Makefile
@@ -16,18 +16,10 @@
 lint:
 	@helm lint couchdb
 
-.PHONY: package
-package: lint
-	@helm package couchdb
-
 .PHONY: publish
-publish:
-	@git checkout gh-pages
-	@git checkout -b gh-pages-update
+publish: lint
+	@helm package couchdb -d docs
 	@helm repo index docs --url https://apache.github.io/couchdb-helm
-	@git add -i
-	@git commit
-	@echo "To complete the publish step, push the branch to your GitHub remote and create a PR against gh-pages"
 
 # Run end to end tests using KinD
 .PHONY: test
diff --git a/README.md b/README.md
index b17607b..3bfca11 100644
--- a/README.md
+++ b/README.md
@@ -9,22 +9,12 @@
 
 ## Testing
 
-`make test` will run an integration test using [Kind][5]. This stands up a Kubernetes cluster locally and ensures the chart will
-deploy using the default options and Helm.
+`make test` will run an integration test using [Kind][5]. This stands up a Kubernetes cluster locally and ensures the chart will deploy using the default options and Helm.
 
 ## Releasing
 
-The Helm chart is published to a Helm epository hosted by GitHub pages. This is maintained in the `gh-pages` branch of this repository.
-
-To publish a new release, perform the following steps:
-
- 1. Create a Helm bundle (*.tgz) for the current couchdb chart
- 2. Switch to the `gh-pages` branch
- 3. Run `helm repo index docs --url https://apache.github.io/couchdb-helm` to generate the Helm repository index
- 4. `git add` the tgz bundle and the `index.yaml` files. Do not delete the old chart bundles!
- 5. Commit the changes and create a PR to `gh-pages`.
-
-`make publish` automates these steps for you.
+Chart versions are immutable. On every version change, `make publish` should be
+run to create a new chart bundle and update the repostory metadata.
 
 ## Feedback / Issues / Contributing
 
diff --git a/couchdb/Chart.yaml b/couchdb/Chart.yaml
index 1d33948..7cfee20 100644
--- a/couchdb/Chart.yaml
+++ b/couchdb/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v1
 name: couchdb
-version: 2.2.0
+version: 2.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
@@ -15,4 +15,6 @@
 maintainers:
   - name: kocolosk
     email: kocolosk@apache.org
+  - name: willholley
+    email: willholley@apache.org
 icon: http://couchdb.apache.org/CouchDB-visual-identity/logo/CouchDB-couch-symbol.svg
diff --git a/couchdb/README.md b/couchdb/README.md
index a0bfc15..b48cd5b 100644
--- a/couchdb/README.md
+++ b/couchdb/README.md
@@ -20,7 +20,8 @@
 
 ## Prerequisites
 
-- Kubernetes 1.8+ with Beta APIs enabled
+- Kubernetes 1.9+ with Beta APIs enabled
+- Ingress requires Kubernetes 1.14+
 
 ## Installing the Chart
 
@@ -109,35 +110,41 @@
 A variety of other parameters are also configurable. See the comments in the
 `values.yaml` file for further details:
 
-|           Parameter             |                Default                 |
-|---------------------------------|----------------------------------------|
-| `adminUsername`                 | admin                                  |
-| `adminPassword`                 | auto-generated                         |
-| `cookieAuthSecret`              | auto-generated                         |
-| `image.repository`              | couchdb                                |
-| `image.tag`                     | 2.3.1                                  |
-| `image.pullPolicy`              | IfNotPresent                           |
-| `searchImage.repository`        | kocolosk/couchdb-search                |
-| `searchImage.tag`               | 0.1.0                                  |
-| `searchImage.pullPolicy`        | IfNotPresent                           |
-| `initImage.repository`          | busybox                                |
-| `initImage.tag`                 | latest                                 |
-| `initImage.pullPolicy`          | Always                                 |
-| `ingress.enabled`               | false                                  |
-| `ingress.hosts`                 | chart-example.local                    |
-| `ingress.annotations`           |                                        |
-| `ingress.tls`                   |                                        |
-| `persistentVolume.accessModes`  | ReadWriteOnce                          |
-| `persistentVolume.storageClass` | Default for the Kube cluster           |
-| `podManagementPolicy`           | Parallel                               |
-| `affinity`                      |                                        |
-| `resources`                     |                                        |
-| `service.annotations`           |                                        |
-| `service.enabled`               | true                                   |
-| `service.type`                  | ClusterIP                              |
-| `service.externalPort`          | 5984                                   |
-| `dns.clusterDomainSuffix`       | cluster.local                          |
-
+|           Parameter               |                Default                 |
+|-----------------------------------|----------------------------------------|
+| `adminUsername`                   | admin                                  |
+| `adminPassword`                   | auto-generated                         |
+| `cookieAuthSecret`                | auto-generated                         |
+| `image.repository`                | couchdb                                |
+| `image.tag`                       | 2.3.1                                  |
+| `image.pullPolicy`                | IfNotPresent                           |
+| `searchImage.repository`          | kocolosk/couchdb-search                |
+| `searchImage.tag`                 | 0.1.0                                  |
+| `searchImage.pullPolicy`          | IfNotPresent                           |
+| `initImage.repository`            | busybox                                |
+| `initImage.tag`                   | latest                                 |
+| `initImage.pullPolicy`            | Always                                 |
+| `ingress.enabled`                 | false                                  |
+| `ingress.hosts`                   | chart-example.local                    |
+| `ingress.annotations`             |                                        |
+| `ingress.path`                    | /                                      |
+| `ingress.tls`                     |                                        |
+| `persistentVolume.accessModes`    | ReadWriteOnce                          |
+| `persistentVolume.storageClass`   | Default for the Kube cluster           |
+| `podManagementPolicy`             | Parallel                               |
+| `affinity`                        |                                        |
+| `annotations`                     |                                        |
+| `tolerations`                     |                                        |
+| `resources`                       |                                        |
+| `service.annotations`             |                                        |
+| `service.enabled`                 | true                                   |
+| `service.type`                    | ClusterIP                              |
+| `service.externalPort`            | 5984                                   |
+| `dns.clusterDomainSuffix`         | cluster.local                          |
+| `networkPolicy.enabled`           | true                                   |
+| `serviceAccount.enabled`          | true                                   |
+| `serviceAccount.create`           | true                                   |
+| `serviceAccount.imagePullSecrets` |                                        |
 
 ## Feedback, Issues, Contributing
 
@@ -161,6 +168,9 @@
 - [@mainephd](https://github.com/mainephd)
 - [@AdamDang](https://github.com/AdamDang)
 - [@mrtyler](https://github.com/mrtyler)
+- [@kevinwlau](https://github.com/kevinwlau)
+- [@jeyenzo](https://github.com/jeyenzo)
+- [@Pinpin31.](https://github.com/Pinpin31)
 
 [1]: http://mail-archives.apache.org/mod_mbox/couchdb-user/
 [2]: http://mail-archives.apache.org/mod_mbox/couchdb-dev/
diff --git a/couchdb/templates/_helpers.tpl b/couchdb/templates/_helpers.tpl
index 0450a66..3a9288f 100644
--- a/couchdb/templates/_helpers.tpl
+++ b/couchdb/templates/_helpers.tpl
@@ -61,3 +61,14 @@
     {{ $.Values.erlangFlags.name }}@{{ template "couchdb.fullname" $ }}-{{ $index0 }}.{{ template "couchdb.fullname" $ }}.{{ $.Release.Namespace }}.svc.{{ $.Values.dns.clusterDomainSuffix }}{{ if ne $index1 $nodeCount }},{{ end }}
   {{- end -}}
 {{- end -}}
+
+{{/*
+If serviceAccount.name is specified, use that, else use the couchdb instance name
+*/}}
+{{- define "couchdb.serviceAccount" -}}
+{{- if .Values.serviceAccount.name -}}
+{{- .Values.serviceAccount.name }}
+{{- else -}}
+{{- template "couchdb.fullname" . -}}
+{{- end -}}
+{{- end -}}
diff --git a/couchdb/templates/ingress.yaml b/couchdb/templates/ingress.yaml
index e73d7a5..5131a6a 100644
--- a/couchdb/templates/ingress.yaml
+++ b/couchdb/templates/ingress.yaml
@@ -1,7 +1,7 @@
 {{- if .Values.ingress.enabled -}}
 {{- $serviceName := include "couchdb.fullname" . -}}
 {{- $servicePort := .Values.service.externalPort -}}
-apiVersion: extensions/v1beta1
+apiVersion: networking.k8s.io/v1beta1
 kind: Ingress
 metadata:
   name: {{ template "couchdb.fullname" . }}
@@ -20,7 +20,7 @@
     - host: {{ $host }}
       http:
         paths:
-          - path: /
+          - path: {{ .Values.ingress.path | quote }}
             backend:
               serviceName: {{ $serviceName }}
               servicePort: {{ $servicePort }}
diff --git a/couchdb/templates/networkpolicy.yaml b/couchdb/templates/networkpolicy.yaml
new file mode 100644
index 0000000..2830708
--- /dev/null
+++ b/couchdb/templates/networkpolicy.yaml
@@ -0,0 +1,31 @@
+
+{{- if .Values.networkPolicy.enabled }}
+kind: NetworkPolicy
+apiVersion: networking.k8s.io/v1
+metadata:
+  name: {{ template "couchdb.fullname" . }}
+  labels:
+    app: {{ template "couchdb.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  podSelector:
+    matchLabels:
+{{ include "couchdb.ss.selector" . | indent 6 }}
+  ingress:
+    - ports:
+        - protocol: TCP
+          port: 5984
+    - ports:
+        - protocol: TCP
+          port: 9100
+        - protocol: TCP
+          port: 4369
+      from:
+        - podSelector:
+            matchLabels:
+{{ include "couchdb.ss.selector" . | indent 14 }}
+  policyTypes:
+    - Ingress
+{{- end }}
diff --git a/couchdb/templates/serviceaccount.yaml b/couchdb/templates/serviceaccount.yaml
new file mode 100644
index 0000000..bb82799
--- /dev/null
+++ b/couchdb/templates/serviceaccount.yaml
@@ -0,0 +1,15 @@
+{{- if .Values.serviceAccount.create }}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: {{ template "couchdb.serviceAccount" . }}
+  labels:
+    app: {{ template "couchdb.name" . }}
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+{{- if .Values.serviceAccount.imagePullSecrets }}
+imagePullSecrets:
+{{ toYaml .Values.serviceAccount.imagePullSecrets }}
+{{- end }}
+{{- end }}
diff --git a/couchdb/templates/statefulset.yaml b/couchdb/templates/statefulset.yaml
index fab2c36..7c7b744 100644
--- a/couchdb/templates/statefulset.yaml
+++ b/couchdb/templates/statefulset.yaml
@@ -1,4 +1,4 @@
-apiVersion: apps/v1beta2
+apiVersion:  apps/v1
 kind: StatefulSet
 metadata:
   name: {{ template "couchdb.fullname" . }}
@@ -18,10 +18,17 @@
     metadata:
       labels:
 {{ include "couchdb.ss.selector" . | indent 8 }}
+{{- with .Values.annotations }}
+      annotations:
+{{ toYaml . | indent 8 }}
+{{- end }}
     spec:
       {{- if .Values.schedulerName }}
       schedulerName: "{{ .Values.schedulerName }}"
       {{- end }}
+      {{- if .Values.serviceAccount.enabled }}
+      serviceAccountName: {{ template "couchdb.serviceAccount" . }}
+      {{- end }}
       initContainers:
         - name: init-copy
           image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}"
@@ -105,6 +112,10 @@
       nodeSelector:
 {{ toYaml .Values.nodeSelector | indent 8 }}
 {{- end }}
+{{- with .Values.tolerations }}
+      tolerations:
+{{ toYaml . | indent 8 }}
+{{- end }}
 {{- with .Values.affinity }}
       affinity:
 {{ toYaml . | indent 8 }}
diff --git a/couchdb/values.yaml b/couchdb/values.yaml
index e3461dd..f94faf7 100644
--- a/couchdb/values.yaml
+++ b/couchdb/values.yaml
@@ -25,11 +25,24 @@
 # adminPassword: this_is_not_secure
 # cookieAuthSecret: neither_is_this
 
+## When enabled, will deploy a networkpolicy that allows CouchDB pods to
+## communicate with each other for clustering and ingress on port 5984
+networkPolicy:
+  enabled: true
+
 ## Use an alternate scheduler, e.g. "stork".
 ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
 ##
 # schedulerName:
 
+# Use a service account
+serviceAccount:
+  enabled: true
+  create: true
+# name:
+# imagePullSecrets:
+# - name: myimagepullsecret
+
 ## The storage volume used by each Pod in the StatefulSet. If a
 ## persistentVolume is not enabled, the Pods will use `emptyDir` ephemeral
 ## local storage. Setting the storageClass attribute to "-" disables dynamic
@@ -80,6 +93,12 @@
   #             - couchdb
   #       topologyKey: "kubernetes.io/hostname"
 
+## Optional pod annotations
+annotations:
+
+## Optional tolerations
+tolerations:
+
 ## A StatefulSet requires a headless Service to establish the stable network
 ## identities of the Pods, and that Service is created automatically by this
 ## chart without any additional configuration. The Service block below refers
@@ -98,6 +117,7 @@
   enabled: false
   hosts:
     - chart-example.local
+  path: /
   annotations:
     # kubernetes.io/ingress.class: nginx
     # kubernetes.io/tls-acme: "true"
diff --git a/docs/couchdb-2.2.0.tgz b/docs/couchdb-2.2.0.tgz
new file mode 100644
index 0000000..5bf2044
--- /dev/null
+++ b/docs/couchdb-2.2.0.tgz
Binary files differ
diff --git a/docs/couchdb-2.3.0.tgz b/docs/couchdb-2.3.0.tgz
new file mode 100644
index 0000000..2f657d8
--- /dev/null
+++ b/docs/couchdb-2.3.0.tgz
Binary files differ
diff --git a/docs/couchdb-2.4.0.tgz b/docs/couchdb-2.4.0.tgz
new file mode 100644
index 0000000..916f501
--- /dev/null
+++ b/docs/couchdb-2.4.0.tgz
Binary files differ
diff --git a/docs/index.yaml b/docs/index.yaml
new file mode 100644
index 0000000..7dda827
--- /dev/null
+++ b/docs/index.yaml
@@ -0,0 +1,73 @@
+apiVersion: v1
+entries:
+  couchdb:
+  - apiVersion: v1
+    appVersion: 2.3.1
+    created: 2019-10-31T09:24:23.82691Z
+    description: A database featuring seamless multi-master sync, that scales from
+      big data to mobile, with an intuitive HTTP/JSON API and designed for reliability.
+    digest: daddf6cc7fe8bb63d6fa8679565d4496d92c23d9ff85b19521fca74c6412bc11
+    home: https://couchdb.apache.org/
+    icon: http://couchdb.apache.org/CouchDB-visual-identity/logo/CouchDB-couch-symbol.svg
+    keywords:
+    - couchdb
+    - database
+    - nosql
+    maintainers:
+    - email: kocolosk@apache.org
+      name: kocolosk
+    - email: willholley@apache.org
+      name: willholley
+    name: couchdb
+    sources:
+    - https://github.com/apache/couchdb-docker
+    urls:
+    - https://apache.github.io/couchdb-helm/couchdb-2.4.0.tgz
+    version: 2.4.0
+  - apiVersion: v1
+    appVersion: 2.3.1
+    created: 2019-10-31T09:24:23.825167Z
+    description: A database featuring seamless multi-master sync, that scales from
+      big data to mobile, with an intuitive HTTP/JSON API and designed for reliability.
+    digest: 0eba7c20ec47bc8556b3cb3b5137b578d46b37397493087d61b8199066f84782
+    home: https://couchdb.apache.org/
+    icon: http://couchdb.apache.org/CouchDB-visual-identity/logo/CouchDB-couch-symbol.svg
+    keywords:
+    - couchdb
+    - database
+    - nosql
+    maintainers:
+    - email: kocolosk@apache.org
+      name: kocolosk
+    - email: willholley@apache.org
+      name: willholley
+    name: couchdb
+    sources:
+    - https://github.com/apache/couchdb-docker
+    urls:
+    - https://apache.github.io/couchdb-helm/couchdb-2.3.0.tgz
+    version: 2.3.0
+  - apiVersion: v1
+    appVersion: 2.3.1
+    created: 2019-10-31T09:24:23.82274Z
+    description: A database featuring seamless multi-master sync, that scales from
+      big data to mobile, with an intuitive HTTP/JSON API and designed for reliability.
+    digest: f68e6187c2b65a02fdde9d49ec38e76a68c3d82421e5ea9e599bac87f4193c6a
+    home: https://couchdb.apache.org/
+    icon: http://couchdb.apache.org/CouchDB-visual-identity/logo/CouchDB-couch-symbol.svg
+    keywords:
+    - couchdb
+    - database
+    - nosql
+    maintainers:
+    - email: kocolosk@apache.org
+      name: kocolosk
+    - email: willholley@apache.org
+      name: willholley
+    name: couchdb
+    sources:
+    - https://github.com/apache/couchdb-docker
+    urls:
+    - https://apache.github.io/couchdb-helm/couchdb-2.2.0.tgz
+    version: 2.2.0
+generated: 2019-10-31T09:24:23.77682Z
diff --git a/test/e2e-kind.sh b/test/e2e-kind.sh
index 59c1dbe..4cb57b4 100755
--- a/test/e2e-kind.sh
+++ b/test/e2e-kind.sh
@@ -35,11 +35,8 @@
 
 create_kind_cluster() {
     if ! [ -x "$(command -v kind)" ]; then
-        echo 'Installing kind...'
-
-        curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-linux-amd64"
-        chmod +x kind
-        sudo mv kind /usr/local/bin/kind
+        echo 'kind not found. See https://kind.sigs.k8s.io/ for installation instructions.'
+        exit
     fi
 
     kind delete cluster --name "$CLUSTER_NAME" || true
@@ -83,7 +80,7 @@
 }
 
 install_charts() {
-    docker_exec ct lint-and-install --chart-repos couchdb=https://apache.github.io/couchdb-helm --chart-dirs .
+    docker_exec ct lint-and-install --charts couchdb --upgrade --chart-dirs .
     echo
 }