-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helm chart update to deploy Redis with sentinels.
- Loading branch information
1 parent
72b2eec
commit 3fca425
Showing
11 changed files
with
2,608 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
apiVersion: v2 | ||
name: redis | ||
description: A Helm chart for Redis | ||
name: redis-csm | ||
description: Helm Chart for Redis with Sentinels | ||
type: application | ||
version: 0.1.0 | ||
appVersion: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{/* | ||
Namespace for all resources to be installed into | ||
If not defined in values file then the helm release namespace is used | ||
By default this is not set so the helm release namespace will be used | ||
*/}} | ||
|
||
{{- define "custom.namespace" -}} | ||
{{ .Values.namespace | default .Release.Namespace }} | ||
{{- end -}} |
2,292 changes: 2,292 additions & 0 deletions
2,292
charts/csm-authorization/charts/redis/templates/redis-cm.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
charts/csm-authorization/charts/redis/templates/redis-secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: redis-csm-secret | ||
namespace: {{ include "custom.namespace" . }} | ||
type: kubernetes.io/basic-auth | ||
stringData: | ||
password: K@ravi123! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
charts/csm-authorization/charts/redis/templates/sentinel.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ .Values.redis.sentinel }} | ||
spec: | ||
serviceName: {{ .Values.redis.sentinel }} | ||
replicas: {{ .Values.redis.replicas }} | ||
selector: | ||
matchLabels: | ||
app: {{ .Values.redis.sentinel }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Values.redis.sentinel }} | ||
annotations: | ||
checksum/secret: {{ include (print $.Template.BasePath "/redis-secret.yaml") . | sha256sum }} | ||
spec: | ||
initContainers: | ||
- name: config | ||
image: {{ .Values.redis.images.redis }} | ||
command: [ "sh", "-c" ] | ||
env: | ||
- name: REDIS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: redis-csm-secret | ||
key: password | ||
args: | ||
- | | ||
replicas=$( expr {{ .Values.redis.replicas | int }} - 1) | ||
for i in $(seq 0 $replicas) | ||
do | ||
node=$( echo "{{ .Values.redis.name }}-$i.{{ .Values.redis.name }}" ) | ||
nodes=$( echo "$nodes*$node" ) | ||
done | ||
loop=$(echo $nodes | sed -e "s/"*"/\n/g") | ||
for i in $loop | ||
do | ||
echo "Finding master at $i" | ||
MASTER=$(redis-cli --no-auth-warning --raw -h $i -a $REDIS_PASSWORD info replication | awk '{print $1}' | grep master_host: | cut -d ":" -f2) | ||
if [ "$MASTER" = "" ]; then | ||
echo "Master not found..." | ||
echo "Sleeping 5 seconds for pods to come up..." | ||
sleep 5 | ||
MASTER= | ||
else | ||
echo "Master found at $MASTER..." | ||
break | ||
fi | ||
done | ||
echo "sentinel monitor mymaster $MASTER 6379 2" >> /tmp/master | ||
echo "port 5000 | ||
sentinel resolve-hostnames yes | ||
sentinel announce-hostnames yes | ||
$(cat /tmp/master) | ||
sentinel down-after-milliseconds mymaster 5000 | ||
sentinel failover-timeout mymaster 60000 | ||
sentinel parallel-syncs mymaster 2 | ||
sentinel auth-pass mymaster $REDIS_PASSWORD | ||
" > /etc/redis/sentinel.conf | ||
cat /etc/redis/sentinel.conf | ||
volumeMounts: | ||
- name: redis-config | ||
mountPath: /etc/redis/ | ||
containers: | ||
- name: sentinel | ||
image: {{ .Values.redis.images.redis }} | ||
command: ["redis-sentinel"] | ||
args: ["/etc/redis/sentinel.conf"] | ||
ports: | ||
- containerPort: 5000 | ||
name: {{ .Values.redis.sentinel }} | ||
volumeMounts: | ||
- name: redis-config | ||
mountPath: /etc/redis/ | ||
- name: data | ||
mountPath: /data | ||
volumes: | ||
- name: redis-config | ||
emptyDir: {} | ||
- name: data | ||
emptyDir : {} | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Values.redis.sentinel }} | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- port: 5000 | ||
targetPort: 5000 | ||
name: sentinel | ||
selector: | ||
app: sentinel | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Values.redis.sentinel }}-svc | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 5000 | ||
targetPort: 5000 | ||
nodePort: 32003 | ||
name: {{ .Values.redis.sentinel }}-svc | ||
selector: | ||
app: {{ .Values.redis.sentinel }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
redis: | ||
name: redis-csm | ||
sentinel: sentinel | ||
rediscommander: rediscommander | ||
replicas: 5 | ||
images: | ||
redis: redis:7.2.4-alpine | ||
commander: rediscommander/redis-commander:latest | ||
|
Oops, something went wrong.