Use healthcheck plugin for probes in gerrit chart

Change-Id: I2c40e6d987f895a15a36bfff842e82925a70e45e
diff --git a/helm-charts/gerrit/README.md b/helm-charts/gerrit/README.md
index 081b5a3..81f5533 100644
--- a/helm-charts/gerrit/README.md
+++ b/helm-charts/gerrit/README.md
@@ -158,6 +158,8 @@
 |                                        |                                                                                                     | `limits.memory: 6Gi`                                                                     |
 | `gerrit.persistence.enabled`           | Whether to persist the Gerrit site                                                                  | `true`                                                                                   |
 | `gerrit.persistence.size`              | Storage size for persisted Gerrit site                                                              | `10Gi`                                                                                   |
+| `gerrit.livenessProbe`                 | Configuration of the liveness probe timings                                                         | `{initialDelaySeconds: 30, periodSeconds: 5}`                                            |
+| `gerrit.readinessProbe`                | Configuration of the readiness probe timings                                                        | `{initialDelaySeconds: 5, periodSeconds: 1}`                                             |
 | `gerrit.service.type`                  | Which kind of Service to deploy                                                                     | `NodePort`                                                                               |
 | `gerrit.service.http.port`             | Port over which to expose HTTP                                                                      | `80`                                                                                     |
 | `gerrit.ingress.host`                  | REQUIRED: Host name to use for the Ingress (required for Ingress)                                   | `nil`                                                                                    |
@@ -232,6 +234,14 @@
     memory resource limit set for the container (e.g. `-Xmx4g`). In your calculation,
     allow memory for other components running in the container.
 
+To enable liveness- and readiness probes, the healthcheck plugin will be installed
+by default. Note, that by configuring to use a packaged or downloaded version of
+the healthcheck plugin, the configured version will take precedence over the default
+version. The plugin is by default configured to disable the `querychanges` and
+`auth` healthchecks, since these would not work on a new and empty Gerrit server.
+The default configuration can be overwritten by adding the `healthcheck.config`
+file as a key-value pair to `gerrit.etc.config` as for every other configuration.
+
 ### Installing Gerrit plugins
 
 There are several different ways to install plugins for Gerrit:
diff --git a/helm-charts/gerrit/templates/gerrit.configmap.yaml b/helm-charts/gerrit/templates/gerrit.configmap.yaml
index a2c440b..4048d50 100644
--- a/helm-charts/gerrit/templates/gerrit.configmap.yaml
+++ b/helm-charts/gerrit/templates/gerrit.configmap.yaml
@@ -12,6 +12,15 @@
   {{ $key }}:
 {{ toYaml $value | indent 4 }}
   {{- end }}
+  {{- if not (hasKey .Values.gerrit.etc.config "healthcheck.config") }}
+  healthcheck.config: |-
+    [healthcheck "auth"]
+      # On new instances there may be no users to use for healthchecks
+      enabled = false
+    [healthcheck "querychanges"]
+      # On new instances there won't be any changes to query
+      enabled = false
+  {{- end }}
 ---
 apiVersion: v1
 kind: ConfigMap
diff --git a/helm-charts/gerrit/templates/gerrit.stateful-set.yaml b/helm-charts/gerrit/templates/gerrit.stateful-set.yaml
index 6432eb8..6216aa4 100644
--- a/helm-charts/gerrit/templates/gerrit.stateful-set.yaml
+++ b/helm-charts/gerrit/templates/gerrit.stateful-set.yaml
@@ -112,12 +112,12 @@
 {{ toYaml .Values.gerrit.resources | indent 10 }}
         livenessProbe:
           httpGet:
-            path: /config/server/version
+            path: /config/server/healthcheck~status
             port: gerrit-port
 {{ toYaml .Values.gerrit.livenessProbe | indent 10 }}
         readinessProbe:
           httpGet:
-            path: /config/server/version
+            path: /config/server/healthcheck~status
             port: gerrit-port
 {{ toYaml .Values.gerrit.readinessProbe | indent 10 }}
       volumes: