Add readiness and liveness probe for git-backend in gerrit-replica chart
This change adds a readiness- and a liveness probe to the
apache-git-http-backend containers in the respective pods. These probes
check, whether the webserver is still reachable under the '/' route,
which just serves the apache default webpage. With this change, the
apache-git-http-backend pod will wait for apache to be ready and
restart, if apache crashed.
Change-Id: I8dfafccbcdf5759eff9c9b79bc937532ce909187
diff --git a/container-images/apache-git-http-backend/config/git-http-backend.conf b/container-images/apache-git-http-backend/config/git-http-backend.conf
index 0996b15..2c84d00 100644
--- a/container-images/apache-git-http-backend/config/git-http-backend.conf
+++ b/container-images/apache-git-http-backend/config/git-http-backend.conf
@@ -24,8 +24,11 @@
# modules, e.g.
LogLevel warn
+ # Don't log probe requests performed by kubernetes
+ SetEnvIFNoCase User-Agent "^kube-probe" dontlog
+
ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
+ CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
diff --git a/container-images/apache-git-http-backend/config/git-https-backend.conf b/container-images/apache-git-http-backend/config/git-https-backend.conf
index 4ee3ea4..e2356f3 100644
--- a/container-images/apache-git-http-backend/config/git-https-backend.conf
+++ b/container-images/apache-git-http-backend/config/git-https-backend.conf
@@ -24,8 +24,11 @@
# modules, e.g.
LogLevel warn
+ # Don't log probe requests performed by kubernetes
+ SetEnvIFNoCase User-Agent "^kube-probe" dontlog
+
ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
+ CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
SSLEngine on
SSLCertificateFile /var/apache/credentials/server.crt
diff --git a/helm-charts/gerrit-replica/README.md b/helm-charts/gerrit-replica/README.md
index 93a48f4..a2998ef 100644
--- a/helm-charts/gerrit-replica/README.md
+++ b/helm-charts/gerrit-replica/README.md
@@ -181,6 +181,8 @@
| | | `requests.memory: 256Mi` |
| | | `limits.cpu: 100m` |
| | | `limits.memory: 256Mi` |
+| `gitBackend.livenessProbe` | Configuration of the liveness probe timings | `{initialDelaySeconds: 10, periodSeconds: 5}` |
+| `gitBackend.readinessProbe` | Configuration of the readiness probe timings | `{initialDelaySeconds: 5, periodSeconds: 1}` |
| `gitBackend.credentials.htpasswd` | `.htpasswd`-file containing username/password-credentials for accessing git | `git:$apr1$O/LbLKC7$Q60GWE7OcqSEMSfe/K8xU.` (user: git, password: secret) |
| `gitBackend.logging.persistence.enabled` | Whether to persist logs | `true` |
| `gitBackend.logging.persistence.size` | Storage size for persisted logs | `1Gi` |
diff --git a/helm-charts/gerrit-replica/templates/git-backend.deployment.yaml b/helm-charts/gerrit-replica/templates/git-backend.deployment.yaml
index e683d53..b46f071 100644
--- a/helm-charts/gerrit-replica/templates/git-backend.deployment.yaml
+++ b/helm-charts/gerrit-replica/templates/git-backend.deployment.yaml
@@ -46,10 +46,34 @@
value: "true"
{{- end }}
ports:
- - containerPort: 80
- - containerPort: 443
+ {{ if eq .Values.gitBackend.service.http.enabled true -}}
+ - name: http-port
+ containerPort: 80
+ {{- end }}
+ {{ if eq .Values.gitBackend.service.https.enabled true -}}
+ - name: https-port
+ containerPort: 443
+ {{- end }}
resources:
{{ toYaml .Values.gitBackend.resources | indent 10 }}
+ livenessProbe:
+ httpGet:
+ path: /
+ {{ if eq .Values.gitBackend.service.http.enabled true -}}
+ port: http-port
+ {{- else }}
+ port: https-port
+ {{- end }}
+{{ toYaml .Values.gitBackend.livenessProbe | indent 10 }}
+ readinessProbe:
+ httpGet:
+ path: /
+ {{ if eq .Values.gitBackend.service.http.enabled true -}}
+ port: http-port
+ {{- else }}
+ port: https-port
+ {{- end }}
+{{ toYaml .Values.gitBackend.readinessProbe | indent 10 }}
volumeMounts:
- name: git-filesystem
mountPath: "/var/gerrit/git"
diff --git a/helm-charts/gerrit-replica/values.yaml b/helm-charts/gerrit-replica/values.yaml
index 1d2abae..76de259 100644
--- a/helm-charts/gerrit-replica/values.yaml
+++ b/helm-charts/gerrit-replica/values.yaml
@@ -86,6 +86,14 @@
cpu: 100m
memory: 256Mi
+ livenessProbe:
+ initialDelaySeconds: 10
+ periodSeconds: 5
+
+ readinessProbe:
+ initialDelaySeconds: 5
+ periodSeconds: 1
+
logging:
persistence:
enabled: true