1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

feat: add healtcheck for container (#544)

feat: add netcat based healtcheck

(similar to `redis-cli ping`)

Signed-off-by: Philipp Born <git@pborn.eu>
This commit is contained in:
Philipp B 2022-12-07 15:44:07 +01:00 committed by GitHub
parent c698e9c25e
commit 2a67dc307e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 18 deletions

View file

@ -52,14 +52,9 @@ spec:
- name: dragonfly
containerPort: 6379
protocol: TCP
livenessProbe:
httpGet:
path: /
port: dragonfly
readinessProbe:
httpGet:
path: /
port: dragonfly
{{- with .Values.probes }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if .Values.command.cmd }}
command:
{{ toYaml .Values.command.cmd | nindent 12 }}

View file

@ -55,14 +55,9 @@ spec:
- name: dragonfly
containerPort: 6379
protocol: TCP
livenessProbe:
httpGet:
path: /
port: dragonfly
readinessProbe:
httpGet:
path: /
port: dragonfly
{{- with .Values.probes }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if .Values.command.cmd }}
command:
{{ toYaml .Values.command.cmd | nindent 12 }}

View file

@ -108,6 +108,27 @@ tls:
# HLunol88AeTOcKfD6hBYGvcRfu5NV29jJxZCOBfbFQXjnNlnrhRCag==
# -----END RSA PRIVATE KEY-----
probes:
livenessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
readinessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
command:
# -- Allow overriding the container's command

View file

@ -18,16 +18,18 @@ LABEL org.opencontainers.image.source https://github.com/${ORG_NAME}/dragonfly
RUN addgroup -S -g 1000 dfly && adduser -S -G dfly -u 999 dfly
RUN apk --no-cache add libgcc libstdc++ libunwind boost1.77-fiber \
'su-exec>=0.2'
'su-exec>=0.2' netcat-openbsd
RUN mkdir /data && chown dfly:dfly /data
VOLUME /data
WORKDIR /data
COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY tools/docker/healthcheck.sh /usr/local/bin/healthcheck.sh
COPY --from=builder /build/build-opt/dragonfly /usr/local/bin/
RUN dragonfly -version
HEALTHCHECK CMD /usr/local/bin/healthcheck.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 6380
CMD ["dragonfly", "--logtostderr"]
CMD ["dragonfly", "--logtostderr"]

View file

@ -25,6 +25,8 @@ ARG DEBIAN_FRONTEND=noninteractive
LABEL org.opencontainers.image.title Dragonfly
LABEL org.opencontainers.image.source https://github.com/${ORG_NAME}/dragonfly
RUN apt clean && apt update && apt -y install netcat-openbsd
RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly
RUN mkdir /data && chown dfly:dfly /data
@ -32,9 +34,11 @@ RUN mkdir /data && chown dfly:dfly /data
VOLUME /data
WORKDIR /data
COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY tools/docker/healthcheck.sh /usr/local/bin/healthcheck.sh
COPY --from=builder /build/su-exec /usr/local/bin/
COPY --from=builder /build/dragonfly /usr/local/bin/
HEALTHCHECK CMD /usr/local/bin/healthcheck.sh
ENTRYPOINT ["entrypoint.sh"]
# For inter-container communication.

8
tools/docker/healthcheck.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
HOST="localhost"
PORT=6379
echo "ping" | nc -q1 $HOST $PORT
exit $?