feat(deploy): optional bundled Redis in the Helm chart
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m22s
ci / test (pull_request) Successful in 15m16s
ci / build (pull_request) Successful in 15m27s
ci / image (pull_request) Successful in 4m43s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m22s
ci / test (pull_request) Successful in 15m16s
ci / build (pull_request) Successful in 15m27s
ci / image (pull_request) Successful in 4m43s
redis.bundled.enabled adds a single Redis for trying UptimeSebi out, like the bundled TimescaleDB: password generated and kept, append-only file on a volume so sessions and schedules survive restarts, read-only root filesystem, kept with its volume on uninstall and adopted by a reinstall. Your own Redis, directly or through Sentinel, stays the way for production. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
a9de8b8d75
commit
d2b669ae71
6 files changed
+158
-9
No files matched your search
@@ -58,6 +58,8 @@ jobs:
|
|||||||
--set checker.enabled=true --set checker.token=usa_x --set statuspage.enabled=true --set statuspage.token=usa_y \
|
--set checker.enabled=true --set checker.token=usa_x --set statuspage.enabled=true --set statuspage.token=usa_y \
|
||||||
--set 'statuspage.hosts={status.example.com}' --set statuspage.ingress.enabled=true \
|
--set 'statuspage.hosts={status.example.com}' --set statuspage.ingress.enabled=true \
|
||||||
--set redis.sentinel.master=m --set 'redis.sentinel.addrs={s1:26379}' --set redis.sentinel.password=p >/dev/null
|
--set redis.sentinel.master=m --set 'redis.sentinel.addrs={s1:26379}' --set redis.sentinel.password=p >/dev/null
|
||||||
|
helm template t "$chart" --set publicURL=https://uptime.example.com --set secretKeys.value=k1:test \
|
||||||
|
--set database.bundled.enabled=true --set redis.bundled.enabled=true --set redis.bundled.persistence.enabled=false >/dev/null
|
||||||
if helm template t "$chart" $base >/dev/null 2>&1; then echo "rendered without a database" >&2; exit 1; fi
|
if helm template t "$chart" $base >/dev/null 2>&1; then echo "rendered without a database" >&2; exit 1; fi
|
||||||
# The install script the API serves must stay POSIX sh for Alpine,
|
# The install script the API serves must stay POSIX sh for Alpine,
|
||||||
# Debian and Raspberry Pi OS; the test renders and checks it.
|
# Debian and Raspberry Pi OS; the test renders and checks it.
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ All settings are environment variables; [`.env.example`](.env.example) lists the
|
|||||||
|
|
||||||
### Kubernetes
|
### Kubernetes
|
||||||
|
|
||||||
The Helm chart in [`deploy/helm/uptimesebi`](deploy/helm/uptimesebi) runs the console and API, and optionally a checker and status page servers in the cluster. Bring your own PostgreSQL with TimescaleDB and your own Redis (directly or through Sentinel); Redis is not bundled. Each release publishes the chart:
|
The Helm chart in [`deploy/helm/uptimesebi`](deploy/helm/uptimesebi) runs the console and API, and optionally a checker and status page servers in the cluster. Bring your own PostgreSQL with TimescaleDB and your own Redis (directly or through Sentinel). Each release publishes the chart:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
helm repo add uptimesebi https://git.zb-server.de/api/packages/zb-server/helm
|
helm repo add uptimesebi https://git.zb-server.de/api/packages/zb-server/helm
|
||||||
@@ -137,7 +137,7 @@ helm install uptime uptimesebi/uptimesebi -n uptime --create-namespace \
|
|||||||
--set ingress.enabled=true --set ingress.tls.enabled=true
|
--set ingress.enabled=true --set ingress.tls.enabled=true
|
||||||
```
|
```
|
||||||
|
|
||||||
Every setting can come from an existing secret instead (`existingSecret`); [`values.yaml`](deploy/helm/uptimesebi/values.yaml) explains them all. Migrations run as a hook before each install and upgrade. To try it out without a database of your own, `--set database.bundled.enabled=true` adds a single TimescaleDB without backups. Pods run unprivileged with a read-only root filesystem; the API pods need amd64 nodes, checkers and status page servers run on ARM too.
|
Every setting can come from an existing secret instead (`existingSecret`); [`values.yaml`](deploy/helm/uptimesebi/values.yaml) explains them all. Migrations run as a hook before each install and upgrade. To try it out without a database and Redis of your own, `--set database.bundled.enabled=true --set redis.bundled.enabled=true` adds a single TimescaleDB and Redis, without backups or high availability. Pods run unprivileged with a read-only root filesystem; the API pods need amd64 nodes, checkers and status page servers run on ARM too.
|
||||||
|
|
||||||
Run as many API, checker and status page instances as you need; they share no local state. The supported setups are:
|
Run as many API, checker and status page instances as you need; they share no local state. The supported setups are:
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ Console: {{ .Values.publicURL }}
|
|||||||
|
|
||||||
Checkers and status page servers outside the cluster: create them in the
|
Checkers and status page servers outside the cluster: create them in the
|
||||||
console (Settings -> Regions) and install them with the command shown there.
|
console (Settings -> Regions) and install them with the command shown there.
|
||||||
{{- if .Values.database.bundled.enabled }}
|
{{- if or .Values.database.bundled.enabled .Values.redis.bundled.enabled }}
|
||||||
|
|
||||||
The bundled database is meant for trying UptimeSebi out: it has no backups
|
The bundled {{ if .Values.database.bundled.enabled }}database{{ end }}{{ if and .Values.database.bundled.enabled .Values.redis.bundled.enabled }} and {{ end }}{{ if .Values.redis.bundled.enabled }}Redis{{ end }} are meant for trying UptimeSebi out: no backups
|
||||||
and no high availability. Its volume and password are kept on uninstall.
|
and no high availability. Their volumes and passwords are kept on uninstall.
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -72,7 +72,7 @@ where $secret is the chart's secret holding values under the last argument.
|
|||||||
{{- $data := dict -}}
|
{{- $data := dict -}}
|
||||||
{{- if and .Values.secretKeys.value (not .Values.secretKeys.existingSecret) }}{{ $_ := set $data "secret-keys" .Values.secretKeys.value }}{{ end -}}
|
{{- if and .Values.secretKeys.value (not .Values.secretKeys.existingSecret) }}{{ $_ := set $data "secret-keys" .Values.secretKeys.value }}{{ end -}}
|
||||||
{{- if and .Values.database.url (not .Values.database.existingSecret) (not .Values.database.bundled.enabled) }}{{ $_ := set $data "database-url" .Values.database.url }}{{ end -}}
|
{{- if and .Values.database.url (not .Values.database.existingSecret) (not .Values.database.bundled.enabled) }}{{ $_ := set $data "database-url" .Values.database.url }}{{ end -}}
|
||||||
{{- if and .Values.redis.url (not .Values.redis.existingSecret) }}{{ $_ := set $data "redis-url" .Values.redis.url }}{{ end -}}
|
{{- if and .Values.redis.url (not .Values.redis.existingSecret) (not .Values.redis.bundled.enabled) }}{{ $_ := set $data "redis-url" .Values.redis.url }}{{ end -}}
|
||||||
{{- if and .Values.redis.sentinel.password (not .Values.redis.sentinel.existingSecret) }}{{ $_ := set $data "redis-sentinel-password" .Values.redis.sentinel.password }}{{ end -}}
|
{{- if and .Values.redis.sentinel.password (not .Values.redis.sentinel.existingSecret) }}{{ $_ := set $data "redis-sentinel-password" .Values.redis.sentinel.password }}{{ end -}}
|
||||||
{{- if and .Values.smtp.url (not .Values.smtp.existingSecret) }}{{ $_ := set $data "smtp-url" .Values.smtp.url }}{{ end -}}
|
{{- if and .Values.smtp.url (not .Values.smtp.existingSecret) }}{{ $_ := set $data "smtp-url" .Values.smtp.url }}{{ end -}}
|
||||||
{{- if and .Values.checker.token (not .Values.checker.existingSecret) }}{{ $_ := set $data "checker-token" .Values.checker.token }}{{ end -}}
|
{{- if and .Values.checker.token (not .Values.checker.existingSecret) }}{{ $_ := set $data "checker-token" .Values.checker.token }}{{ end -}}
|
||||||
@@ -124,7 +124,15 @@ $secret being the chart secret to read values from.
|
|||||||
{{- else }}
|
{{- else }}
|
||||||
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_DATABASE_URL" .Values.database.existingSecret .Values.database.existingSecretKey "database-url") }}
|
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_DATABASE_URL" .Values.database.existingSecret .Values.database.existingSecretKey "database-url") }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.redis.sentinel.master }}
|
{{- if .Values.redis.bundled.enabled }}
|
||||||
|
- name: UPTIME_REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "uptimesebi.fullname" . }}-redis
|
||||||
|
key: password
|
||||||
|
- name: UPTIME_REDIS_URL
|
||||||
|
value: {{ printf "redis://:$(UPTIME_REDIS_PASSWORD)@%s-redis:6379/0" (include "uptimesebi.fullname" .) | quote }}
|
||||||
|
{{- else if .Values.redis.sentinel.master }}
|
||||||
- name: UPTIME_REDIS_SENTINEL_MASTER
|
- name: UPTIME_REDIS_SENTINEL_MASTER
|
||||||
value: {{ .Values.redis.sentinel.master | quote }}
|
value: {{ .Values.redis.sentinel.master | quote }}
|
||||||
- name: UPTIME_REDIS_SENTINEL_ADDRS
|
- name: UPTIME_REDIS_SENTINEL_ADDRS
|
||||||
@@ -139,7 +147,7 @@ $secret being the chart secret to read values from.
|
|||||||
{{- else if or .Values.redis.url .Values.redis.existingSecret }}
|
{{- else if or .Values.redis.url .Values.redis.existingSecret }}
|
||||||
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_REDIS_URL" .Values.redis.existingSecret .Values.redis.existingSecretKey "redis-url") }}
|
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_REDIS_URL" .Values.redis.existingSecret .Values.redis.existingSecretKey "redis-url") }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- fail "set redis.url, redis.existingSecret or redis.sentinel.master: Redis is not bundled" }}
|
{{- fail "set redis.url, redis.existingSecret, redis.sentinel.master or redis.bundled.enabled" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if or .Values.secretKeys.value .Values.secretKeys.existingSecret }}
|
{{- if or .Values.secretKeys.value .Values.secretKeys.existingSecret }}
|
||||||
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_SECRET_KEYS" .Values.secretKeys.existingSecret .Values.secretKeys.existingSecretKey "secret-keys") }}
|
{{ include "uptimesebi.secretEnv" (list $secret "UPTIME_SECRET_KEYS" .Values.secretKeys.existingSecret .Values.secretKeys.existingSecretKey "secret-keys") }}
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
{{- if .Values.redis.bundled.enabled }}
|
||||||
|
{{- $name := printf "%s-redis" (include "uptimesebi.fullname" .) }}
|
||||||
|
{{- $existing := lookup "v1" "Secret" .Release.Namespace $name }}
|
||||||
|
{{- $password := .Values.redis.bundled.password }}
|
||||||
|
{{- if and (not $password) $existing }}{{ $password = index $existing.data "password" | b64dec }}{{ end }}
|
||||||
|
{{- if not $password }}{{ $password = randAlphaNum 32 }}{{ end }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
{{- include "uptimesebi.labels" . | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: redis
|
||||||
|
annotations:
|
||||||
|
# Uninstalling keeps the password along with the kept volume.
|
||||||
|
helm.sh/resource-policy: keep
|
||||||
|
type: Opaque
|
||||||
|
stringData:
|
||||||
|
password: {{ $password | quote }}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
{{- include "uptimesebi.labels" . | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: redis
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
{{- include "uptimesebi.selector" (list . "redis") | nindent 4 }}
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
port: 6379
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
{{- include "uptimesebi.labels" . | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: redis
|
||||||
|
spec:
|
||||||
|
serviceName: {{ $name }}
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
{{- include "uptimesebi.selector" (list . "redis") | nindent 6 }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
{{- include "uptimesebi.selector" (list . "redis") | nindent 8 }}
|
||||||
|
spec:
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 999
|
||||||
|
runAsGroup: 999
|
||||||
|
fsGroup: 999
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: {{ printf "%s:%s" .Values.redis.bundled.image.repository .Values.redis.bundled.image.tag }}
|
||||||
|
command: [redis-server]
|
||||||
|
args:
|
||||||
|
- --requirepass
|
||||||
|
- $(REDIS_PASSWORD)
|
||||||
|
- --appendonly
|
||||||
|
- {{ ternary "yes" "no" .Values.redis.bundled.persistence.enabled | quote }}
|
||||||
|
- --save
|
||||||
|
- ""
|
||||||
|
env:
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ $name }}
|
||||||
|
key: password
|
||||||
|
- name: REDISCLI_AUTH
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ $name }}
|
||||||
|
key: password
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
containerPort: 6379
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command: [redis-cli, ping]
|
||||||
|
periodSeconds: 5
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: redis
|
||||||
|
periodSeconds: 20
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
readOnlyRootFilesystem: true
|
||||||
|
capabilities:
|
||||||
|
drop: [ALL]
|
||||||
|
resources:
|
||||||
|
{{- toYaml .Values.redis.bundled.resources | nindent 12 }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /data
|
||||||
|
{{- if not .Values.redis.bundled.persistence.enabled }}
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.redis.bundled.persistence.enabled }}
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: data
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
{{- with .Values.redis.bundled.persistence.storageClass }}
|
||||||
|
storageClassName: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.redis.bundled.persistence.size }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
@@ -68,7 +68,7 @@ database:
|
|||||||
resources: {}
|
resources: {}
|
||||||
|
|
||||||
# -- Redis --
|
# -- Redis --
|
||||||
# Redis is not bundled: point to your own, directly or through Sentinel.
|
# Point to your own Redis, directly or through Sentinel, or bundle one.
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
# redis://:password@host:6379/0 or rediss:// for TLS.
|
# redis://:password@host:6379/0 or rediss:// for TLS.
|
||||||
@@ -82,6 +82,23 @@ redis:
|
|||||||
password: ""
|
password: ""
|
||||||
existingSecret: ""
|
existingSecret: ""
|
||||||
existingSecretKey: redis-sentinel-password
|
existingSecretKey: redis-sentinel-password
|
||||||
|
# A single Redis in the cluster, for trying UptimeSebi out. Without high
|
||||||
|
# availability: for production use your own Redis.
|
||||||
|
bundled:
|
||||||
|
enabled: false
|
||||||
|
image:
|
||||||
|
repository: redis
|
||||||
|
tag: 8-alpine
|
||||||
|
# Generated on install if empty, then kept; letters and digits only,
|
||||||
|
# it goes into a URL.
|
||||||
|
password: ""
|
||||||
|
# Sessions, schedules and rate limits survive restarts on a volume;
|
||||||
|
# without one a restart signs everyone out.
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
size: 1Gi
|
||||||
|
storageClass: ""
|
||||||
|
resources: {}
|
||||||
|
|
||||||
# -- Migrations --
|
# -- Migrations --
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user