feat(redis): add shared Redis 8.10.3 to platform
This commit is contained in:
1 parent
eb96f56349
commit
67356b1489
13 files changed
+671
No files matched your search
@@ -0,0 +1,19 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- statefulset.yaml
|
||||
- service.yaml
|
||||
|
||||
configMapGenerator:
|
||||
- name: redis-config
|
||||
files:
|
||||
- redis.conf
|
||||
- start-redis.sh
|
||||
|
||||
labels:
|
||||
- includeSelectors: true
|
||||
pairs:
|
||||
app.kubernetes.io/name: redis
|
||||
app.kubernetes.io/part-of: redis
|
||||
app.kubernetes.io/managed-by: kustomize
|
||||
@@ -0,0 +1,17 @@
|
||||
bind 0.0.0.0
|
||||
protected-mode yes
|
||||
port 6379
|
||||
dir /data
|
||||
aclfile /run/redis-acl/users.acl
|
||||
|
||||
appendonly yes
|
||||
appendfsync everysec
|
||||
save ""
|
||||
|
||||
# Redis "gb" uses binary units: 3gb = 3 GiB.
|
||||
# The container limit is 5Gi. This is a measured-risk starting point: heavy
|
||||
# writes during AOF rewrite can exhaust the remaining fork/COW headroom.
|
||||
# maxmemory is not a hard limit on total process memory.
|
||||
maxmemory 3gb
|
||||
# Preserve keys until the application explicitly deletes or expires them.
|
||||
maxmemory-policy noeviction
|
||||
@@ -0,0 +1,42 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-headless
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app.kubernetes.io/name: redis
|
||||
ports:
|
||||
- name: redis
|
||||
port: 6379
|
||||
targetPort: redis
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-metrics
|
||||
labels:
|
||||
app.kubernetes.io/component: metrics
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app.kubernetes.io/name: redis
|
||||
ports:
|
||||
- name: metrics
|
||||
port: 9121
|
||||
targetPort: metrics
|
||||
# Keep the exporter scrapeable while the Redis readiness probe fails.
|
||||
publishNotReadyAddresses: true
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app.kubernetes.io/name: redis
|
||||
ports:
|
||||
- name: redis
|
||||
port: 6379
|
||||
targetPort: redis
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Restrict usernames to a single ACL token; never interpolate raw passwords
|
||||
# into Redis configuration syntax or command-line arguments.
|
||||
case "${REDIS_USERNAME:-}" in
|
||||
""|default|*[!a-zA-Z0-9_.-]*)
|
||||
echo "REDIS_USERNAME must contain only letters, digits, _, . or - and must not be default." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ -z "${REDISCLI_AUTH:-}" ]; then
|
||||
echo "REDIS_PASSWORD must not be empty." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask 077
|
||||
password_hash="$(printf '%s' "$REDISCLI_AUTH" | sha256sum)"
|
||||
password_hash="${password_hash%% *}"
|
||||
printf 'user default off\nuser %s on #%s ~* &* +@all\n' \
|
||||
"$REDIS_USERNAME" "$password_hash" > /run/redis-acl/users.acl
|
||||
unset password_hash
|
||||
|
||||
exec redis-server /etc/redis/redis.conf
|
||||
@@ -0,0 +1,132 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: redis
|
||||
spec:
|
||||
serviceName: redis-headless
|
||||
replicas: 1
|
||||
persistentVolumeClaimRetentionPolicy:
|
||||
whenDeleted: Retain
|
||||
whenScaled: Retain
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: redis
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: redis
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 60
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 999
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis:8.10.3-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- sh
|
||||
- /etc/redis/start-redis.sh
|
||||
env:
|
||||
- name: REDIS_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: redis-auth
|
||||
key: username
|
||||
- name: REDISCLI_AUTH
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: redis-auth
|
||||
key: password
|
||||
ports:
|
||||
- name: redis
|
||||
containerPort: 6379
|
||||
startupProbe:
|
||||
exec:
|
||||
command: [sh, -ec, 'test "$(redis-cli --user "$REDIS_USERNAME" ping)" = PONG']
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 120
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: [sh, -ec, 'test "$(redis-cli --user "$REDIS_USERNAME" ping)" = PONG']
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: [sh, -ec, 'test "$(redis-cli --user "$REDIS_USERNAME" ping)" = PONG']
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 4Gi
|
||||
limits:
|
||||
memory: 5Gi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /etc/redis
|
||||
readOnly: true
|
||||
- name: acl
|
||||
mountPath: /run/redis-acl
|
||||
- name: exporter
|
||||
image: oliver006/redis_exporter:v1.94.0
|
||||
args:
|
||||
- --redis.addr=redis://127.0.0.1:6379
|
||||
- --redis-only-metrics
|
||||
- --disable-scrape-endpoint
|
||||
- --connection-timeout=5s
|
||||
env:
|
||||
- name: REDIS_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: redis-auth
|
||||
key: username
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: redis-auth
|
||||
key: password
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9121
|
||||
resources:
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
volumes:
|
||||
- name: acl
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 1Mi
|
||||
- name: config
|
||||
configMap:
|
||||
name: redis-config
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
Reference in new issue
Block a user