blob: 14a9c8bc582726e4bc3f44d5b8746c0d05e2ebca [file] [log] [blame]
Tinoj Josephdd1fd9d2022-08-01 23:59:26 +05301apiVersion: v1
2kind: ConfigMap
3metadata:
4 name: {{ template "redis.fullname" . }}-health
5 namespace: {{ .Release.Namespace | quote }}
6 labels:
7 app: {{ template "redis.name" . }}
8 chart: {{ template "redis.chart" . }}
9 heritage: {{ .Release.Service }}
10 release: {{ .Release.Name }}
11data:
12 ping_readiness_local.sh: |-
13 #!/bin/bash
14{{- if .Values.usePasswordFile }}
15 password_aux=`cat ${REDIS_PASSWORD_FILE}`
16 export REDIS_PASSWORD=$password_aux
17{{- end }}
18 export REDISCLI_AUTH="$REDIS_PASSWORD"
19 response=$(
20 timeout -s 3 $1 \
21 redis-cli \
22 -h localhost \
23{{- if .Values.tls.enabled }}
24 -p $REDIS_TLS_PORT \
25 --tls \
26 --cacert {{ template "redis.tlsCACert" . }} \
27 {{- if .Values.tls.authClients }}
28 --cert {{ template "redis.tlsCert" . }} \
29 --key {{ template "redis.tlsCertKey" . }} \
30 {{- end }}
31{{- else }}
32 -p $REDIS_PORT \
33{{- end }}
34 ping
35 )
36 if [ "$response" != "PONG" ]; then
37 echo "$response"
38 exit 1
39 fi
40 ping_liveness_local.sh: |-
41 #!/bin/bash
42{{- if .Values.usePasswordFile }}
43 password_aux=`cat ${REDIS_PASSWORD_FILE}`
44 export REDIS_PASSWORD=$password_aux
45{{- end }}
46 export REDISCLI_AUTH="$REDIS_PASSWORD"
47 response=$(
48 timeout -s 3 $1 \
49 redis-cli \
50 -h localhost \
51{{- if .Values.tls.enabled }}
52 -p $REDIS_TLS_PORT \
53 --tls \
54 --cacert {{ template "redis.tlsCACert" . }} \
55 {{- if .Values.tls.authClients }}
56 --cert {{ template "redis.tlsCert" . }} \
57 --key {{ template "redis.tlsCertKey" . }} \
58 {{- end }}
59{{- else }}
60 -p $REDIS_PORT \
61{{- end }}
62 ping
63 )
64 if [ "$response" != "PONG" ] && [ "$response" != "LOADING Redis is loading the dataset in memory" ]; then
65 echo "$response"
66 exit 1
67 fi
68{{- if .Values.global.redis.sentinel.enabled }}
69 ping_sentinel.sh: |-
70 #!/bin/bash
71{{- if .Values.usePasswordFile }}
72 password_aux=`cat ${REDIS_PASSWORD_FILE}`
73 export REDIS_PASSWORD=$password_aux
74{{- end }}
75 export REDISCLI_AUTH="$REDIS_PASSWORD"
76 response=$(
77 timeout -s 3 $1 \
78 redis-cli \
79 -h localhost \
80{{- if .Values.tls.enabled }}
81 -p $REDIS_SENTINEL_TLS_PORT_NUMBER \
82 --tls \
83 --cacert {{ template "redis.tlsCACert" . }} \
84 {{- if .Values.tls.authClients }}
85 --cert {{ template "redis.tlsCert" . }} \
86 --key {{ template "redis.tlsCertKey" . }} \
87 {{- end }}
88{{- else }}
89 -p $REDIS_SENTINEL_PORT \
90{{- end }}
91 ping
92 )
93 if [ "$response" != "PONG" ]; then
94 echo "$response"
95 exit 1
96 fi
97 parse_sentinels.awk: |-
98 /ip/ {FOUND_IP=1}
99 /port/ {FOUND_PORT=1}
100 /runid/ {FOUND_RUNID=1}
101 !/ip|port|runid/ {
102 if (FOUND_IP==1) {
103 IP=$1; FOUND_IP=0;
104 }
105 else if (FOUND_PORT==1) {
106 PORT=$1;
107 FOUND_PORT=0;
108 } else if (FOUND_RUNID==1) {
109 printf "\nsentinel known-sentinel {{ .Values.sentinel.masterSet }} %s %s %s", IP, PORT, $0; FOUND_RUNID=0;
110 }
111 }
112{{- end }}
113 ping_readiness_master.sh: |-
114 #!/bin/bash
115{{- if .Values.usePasswordFile }}
116 password_aux=`cat ${REDIS_MASTER_PASSWORD_FILE}`
117 export REDIS_MASTER_PASSWORD=$password_aux
118{{- end }}
119 export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
120 response=$(
121 timeout -s 3 $1 \
122 redis-cli \
123 -h $REDIS_MASTER_HOST \
124 -p $REDIS_MASTER_PORT_NUMBER \
125{{- if .Values.tls.enabled }}
126 --tls \
127 --cacert {{ template "redis.tlsCACert" . }} \
128 {{- if .Values.tls.authClients }}
129 --cert {{ template "redis.tlsCert" . }} \
130 --key {{ template "redis.tlsCertKey" . }} \
131 {{- end }}
132{{- end }}
133 ping
134 )
135 if [ "$response" != "PONG" ]; then
136 echo "$response"
137 exit 1
138 fi
139 ping_liveness_master.sh: |-
140 #!/bin/bash
141{{- if .Values.usePasswordFile }}
142 password_aux=`cat ${REDIS_MASTER_PASSWORD_FILE}`
143 export REDIS_MASTER_PASSWORD=$password_aux
144{{- end }}
145 export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
146 response=$(
147 timeout -s 3 $1 \
148 redis-cli \
149 -h $REDIS_MASTER_HOST \
150 -p $REDIS_MASTER_PORT_NUMBER \
151{{- if .Values.tls.enabled }}
152 --tls \
153 --cacert {{ template "redis.tlsCACert" . }} \
154 {{- if .Values.tls.authClients }}
155 --cert {{ template "redis.tlsCert" . }} \
156 --key {{ template "redis.tlsCertKey" . }} \
157 {{- end }}
158{{- end }}
159 ping
160 )
161 if [ "$response" != "PONG" ] && [ "$response" != "LOADING Redis is loading the dataset in memory" ]; then
162 echo "$response"
163 exit 1
164 fi
165 ping_readiness_local_and_master.sh: |-
166 script_dir="$(dirname "$0")"
167 exit_status=0
168 "$script_dir/ping_readiness_local.sh" $1 || exit_status=$?
169 "$script_dir/ping_readiness_master.sh" $1 || exit_status=$?
170 exit $exit_status
171 ping_liveness_local_and_master.sh: |-
172 script_dir="$(dirname "$0")"
173 exit_status=0
174 "$script_dir/ping_liveness_local.sh" $1 || exit_status=$?
175 "$script_dir/ping_liveness_master.sh" $1 || exit_status=$?
176 exit $exit_status