Skip to content

Commit

Permalink
redis
Browse files Browse the repository at this point in the history
  • Loading branch information
mrugges committed Mar 5, 2024
1 parent a106a8a commit 8f711a6
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
37 changes: 37 additions & 0 deletions kubernetes/apps/database/redis/app/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.26.1-standalone-strict/configmap-v1.json
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-healthcheck
labels:
app.kubernetes.io/name: redis
data:
ping_readiness.sh: |-
#!/bin/sh
export REDISCLI_AUTH="$REDIS_PASSWORD"
response=$(
timeout -s 3 $1 \
redis-cli \
-h localhost \
-p $REDIS_PORT \
ping
)
if [ "$response" != "PONG" ]; then
echo "$response"
exit 1
fi
ping_liveness.sh: |-
#!/bin/sh
export REDISCLI_AUTH="$REDIS_PASSWORD"
response=$(
timeout -s 3 $1 \
redis-cli \
-h localhost \
-p $REDIS_PORT \
ping
)
if [ "$response" != "PONG" ] && [ "$response" != "LOADING Redis is loading the dataset in memory" ]; then
echo "$response"
exit 1
fi
94 changes: 94 additions & 0 deletions kubernetes/apps/database/redis/app/helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/helmrelease-helm-v2beta2.json
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: redis
spec:
interval: 15m
chart:
spec:
chart: app-template
version: 2.6.0
sourceRef:
kind: HelmRepository
name: bjw-s
namespace: flux-system
interval: 15m
install:
createNamespace: true
remediation:
retries: 5
upgrade:
remediation:
retries: 5
values:
controllers:
main:
type: statefulset
containers:
main:
image:
repository: redis
tag: 7.2.4-alpine
command:
- sh
args:
- -c
- >-
redis-server
probes:
liveness:
enabled: true
custom: true
spec:
exec:
command:
- sh
- -c
- /health/ping_liveness.sh 5
initialDelaySeconds: 5
timeoutSeconds: 6
periodSeconds: 5
successThreshold: 1
failureThreshold: 5
readiness:
enabled: true
custom: true
spec:
exec:
command:
- sh
- -c
- /health/ping_readiness.sh 1
initialDelaySeconds: 5
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 5
resources:
requests:
cpu: 34m
memory: 204Mi
limits:
memory: 241Mi
env:
REDIS_PORT: "6379"
service:
main:
ports:
http:
port: 6379
persistence:
data:
enabled: true
existingClaim: redis
globalMounts:
- path: /data
healthcheck:
enabled: true
type: configMap
name: redis-healthcheck
defaultMode: 0755
globalMounts:
- path: /health
7 changes: 7 additions & 0 deletions kubernetes/apps/database/redis/app/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./configmap.yaml
- ./helmrelease.yaml
25 changes: 25 additions & 0 deletions kubernetes/apps/database/redis/ks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/kustomize.toolkit.fluxcd.io/kustomization_v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app redis
namespace: flux-system
spec:
targetNamespace: database
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/apps/database/redis/app
prune: true
sourceRef:
kind: GitRepository
name: home-ops-kubernetes
wait: false
interval: 30m
retryInterval: 1m
timeout: 15m
postBuild:
substitute:
APP: *app
VOLSYNC_CAPACITY: 2Gi

0 comments on commit 8f711a6

Please sign in to comment.