17 changed files with 162 additions and 68 deletions
@ -0,0 +1 @@ |
|||
user default on >quay ~quay:* +@all -@dangerous |
|||
@ -1,49 +0,0 @@ |
|||
[Unit] |
|||
Description=Redis cache for Quay |
|||
Documentation=https://hub.docker.com/_/redis |
|||
After=network.target var-lib-virtiofs-data.mount |
|||
Requires=var-lib-virtiofs-data.mount |
|||
|
|||
# Only start if Redis has been configured |
|||
ConditionPathExists=/etc/quadlets/quay/redis/redis.env |
|||
ConditionPathExists=/etc/quadlets/quay/redis/redis.conf |
|||
|
|||
# Start/stop this unit when the target is started/stopped |
|||
PartOf=quay.target |
|||
|
|||
[Container] |
|||
ContainerName=quay-redis |
|||
Image=quay-redis.image |
|||
|
|||
# Network configuration |
|||
Network=host |
|||
|
|||
# Redis configuration with authentication |
|||
Exec=redis-server /usr/local/etc/redis/redis.conf |
|||
|
|||
# No need for root privileges |
|||
User=10026 |
|||
Group=10000 |
|||
|
|||
# Storage |
|||
Volume=/var/lib/virtiofs/data/quay/redis:/data:Z |
|||
Volume=/etc/quadlets/quay/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro,Z |
|||
|
|||
# Health check |
|||
HealthCmd=redis-cli -t 5 ping | grep -qFx PONG |
|||
HealthInterval=30s |
|||
HealthTimeout=5s |
|||
HealthStartPeriod=10s |
|||
HealthRetries=3 |
|||
|
|||
[Service] |
|||
Restart=always |
|||
RestartSec=10 |
|||
TimeoutStartSec=300 |
|||
TimeoutStopSec=30 |
|||
|
|||
# These environment variables are sourced to be used by systemd in the Exec* commands |
|||
EnvironmentFile=/etc/quadlets/quay/redis/redis.env |
|||
|
|||
[Install] |
|||
WantedBy=quay.target |
|||
@ -1,5 +0,0 @@ |
|||
[Unit] |
|||
Description=podman pull docker.io/library/redis:7 |
|||
|
|||
[Image] |
|||
Image=docker.io/library/redis:7 |
|||
@ -0,0 +1,18 @@ |
|||
##
|
|||
## Makefile for Redis quadlet
|
|||
##
|
|||
|
|||
# Redis runs as UID 10021 / GID 10000 on the host
|
|||
PROJECT_UID = 10021 |
|||
PROJECT_GID = 10000 |
|||
|
|||
# Include common Makefile
|
|||
include ../../scripts/common.mk |
|||
|
|||
TARGET_FILES += $(TARGET_CHROOT)/etc/quadlets/redis/acl.d |
|||
$(TARGET_CHROOT)/etc/quadlets/redis/acl.d: |
|||
install -m 0700 -o root -g root -D -d $@ |
|||
|
|||
TARGET_REDIS_ACL_FILES = $(patsubst config/examples/acl.d/%, $(TARGET_CHROOT)/etc/quadlets/redis/acl.d/%, $(wildcard config/examples/acl.d/*)) |
|||
$(TARGET_REDIS_ACL_FILES): $(TARGET_CHROOT)/etc/quadlets/redis/acl.d/%.acl: config/examples/acl.d/%.acl |
|||
install -m 0600 -o root -g root $< $@ |
|||
@ -0,0 +1 @@ |
|||
user probe on >probe +ping |
|||
@ -0,0 +1,11 @@ |
|||
# Network settings |
|||
port 6379 |
|||
bind 127.0.0.1 |
|||
|
|||
# ACL file for multi-tenant access control (generated from acl.d/*.acl fragments) |
|||
aclfile /usr/local/etc/redis/users.acl |
|||
|
|||
# AOF persistence mode |
|||
save "" |
|||
appendonly yes |
|||
appendfsync everysec |
|||
@ -0,0 +1,26 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [[ $# -eq 0 ]]; then |
|||
set -- /etc/quadlets/redis/users.acl /etc/quadlets/redis/acl.d/*.acl |
|||
fi |
|||
|
|||
target_file="$1" |
|||
shift |
|||
for file in "$@"; do |
|||
cat "$file" |
|||
echo |
|||
done > "$target_file" |
|||
|
|||
if ! grep -qE '^user +default' "$target_file"; then |
|||
echo "Warning: 'user default' entry not found in ACL files. Disabling it in $target_file." >&2 |
|||
echo "user default off" |
|||
fi >> "$target_file" |
|||
|
|||
# Remove empty lines from the generated ACL file |
|||
sed -i '/^$/d' "$target_file" |
|||
|
|||
if [[ -n "${REDIS_UID:-}" && -n "${REDIS_GID:-}" ]]; then |
|||
chown "$REDIS_UID:$REDIS_GID" "$target_file" |
|||
fi |
|||
@ -0,0 +1,5 @@ |
|||
# Redis ACL fragments
|
|||
TARGET_REDIS_FILES = $(patsubst other/redis/%.acl, $(TARGET_CHROOT)/etc/quadlets/redis/acl.d/%.acl, $(wildcard other/redis/*.acl)) |
|||
TARGET_EXAMPLE_FILES += $(TARGET_REDIS_FILES) |
|||
$(TARGET_CHROOT)/etc/quadlets/redis/acl.d/%.acl: other/redis/%.acl |
|||
install -D -m 0644 -o root -g root $< $@ |
|||
@ -0,0 +1,59 @@ |
|||
[Unit] |
|||
Description=Redis |
|||
Documentation=https://hub.docker.com/_/redis/ |
|||
After=network.target |
|||
RequiresMountsFor=/var/lib/virtiofs/data |
|||
|
|||
# Start/stop this unit when the target is started/stopped |
|||
PartOf=redis.target |
|||
|
|||
# Only start if Redis has been configured |
|||
ConditionPathExists=/etc/quadlets/redis/redis.conf |
|||
|
|||
[Container] |
|||
ContainerName=redis-server |
|||
Image=redis-server.image |
|||
|
|||
# Network configuration |
|||
Network=host |
|||
|
|||
# Redis configuration |
|||
Exec=redis-server /usr/local/etc/redis/redis.conf |
|||
|
|||
# No need for root privileges |
|||
User=redis |
|||
Group=redis |
|||
|
|||
# UID/GID mapping to map the redis user (999) & group (1000) inside the container to host UID 10021 / GID 10000 |
|||
UIDMap=0:1000000:65535 |
|||
UIDMap=+999:10021:1 |
|||
GIDMap=0:1000000:65535 |
|||
GIDMap=+1000:10000:1 |
|||
|
|||
# Volume mounts for data persistence and configuration |
|||
Volume=/var/lib/virtiofs/data/redis:/data:Z |
|||
Volume=/etc/quadlets/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro,Z |
|||
Volume=/etc/quadlets/redis/users.acl:/usr/local/etc/redis/users.acl:ro,Z |
|||
|
|||
# Password for the "probe" user for health checks |
|||
Environment=REDISCLI_AUTH=probe |
|||
|
|||
# Health check |
|||
HealthCmd=redis-cli --user probe ping | grep -qFx PONG |
|||
HealthInterval=30s |
|||
HealthTimeout=5s |
|||
HealthStartPeriod=10s |
|||
HealthRetries=3 |
|||
|
|||
[Service] |
|||
Restart=always |
|||
RestartSec=5 |
|||
TimeoutStartSec=300 |
|||
TimeoutStopSec=30 |
|||
|
|||
# Concatenate all ACL fragments into a single users.acl before starting |
|||
Environment=REDIS_UID=10021 REDIS_GID=10000 |
|||
ExecStartPre=/etc/quadlets/redis/generate-acl.sh |
|||
|
|||
[Install] |
|||
WantedBy=redis.target |
|||
@ -0,0 +1,9 @@ |
|||
[Unit] |
|||
Description=podman pull docker.io/library/redis |
|||
Documentation=https://hub.docker.com/_/redis/ |
|||
|
|||
# Only start if Redis has been configured |
|||
ConditionPathExists=/etc/quadlets/redis/redis.conf |
|||
|
|||
[Image] |
|||
Image=docker.io/library/redis:8-alpine |
|||
@ -0,0 +1,13 @@ |
|||
[Unit] |
|||
Description=Redis Service Target |
|||
Documentation=man:systemd.target(5) |
|||
Requires=redis-server.service |
|||
After=redis-server.service |
|||
|
|||
AllowIsolate=yes |
|||
|
|||
# Only start if Redis has been configured |
|||
ConditionPathExists=/etc/quadlets/redis/redis.conf |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
|||
@ -0,0 +1 @@ |
|||
d$ /var/lib/virtiofs/data/redis 0700 10021 10000 - |
|||
Loading…
Reference in new issue