forked from delimitrou/DeathStarBench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request delimitrou#223 from przmk0/redis_cluster_socialnet
(feat) Extend support for Redis Cluster - include post-install health check and dedicated svc config flag
- Loading branch information
Showing
13 changed files
with
159 additions
and
41 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
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
Binary file not shown.
Binary file added
BIN
+97.8 KB
socialNetwork/helm-chart/socialnetwork/charts/redis-cluster-7.6.3.tgz
Binary file not shown.
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
43 changes: 43 additions & 0 deletions
43
socialNetwork/helm-chart/socialnetwork/templates/hooks/redis-cluster/configmap.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,43 @@ | ||
{{- if .Values.global.redis.cluster.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: redis-readiness-script | ||
data: | ||
redis_readiness_check.py: | | ||
import logging | ||
from time import sleep | ||
from typing import Optional | ||
from redis import RedisCluster | ||
from redis.exceptions import RedisClusterException | ||
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s", handlers=[logging.StreamHandler()]) | ||
log = logging.getLogger() | ||
redis_cluster_uri: str = "{{ .Release.Name }}-redis-cluster" | ||
redis_cluster_is_ready: bool = False | ||
redis_cluster_connection: Optional[RedisCluster] = None | ||
while True: | ||
try: | ||
redis_cluster_connection = RedisCluster(host=redis_cluster_uri) | ||
redis_cluster_connection.ping() | ||
break | ||
except Exception as ex: | ||
log.exception(f"Could not connect to Redis Cluster. Sleeping for 5 seconds") | ||
sleep(5) | ||
assert isinstance(redis_cluster_connection, RedisCluster) | ||
while not redis_cluster_is_ready: | ||
redis_cluster_is_ready = True | ||
cluster_info = redis_cluster_connection.cluster_info(target_nodes=RedisCluster.ALL_NODES) | ||
for node, status in cluster_info.items(): | ||
cluster_state = status.get("cluster_state") | ||
log.info(f"cluster {node} -> cluster state: {cluster_state}") | ||
if not cluster_state or cluster_state != "ok": | ||
redis_cluster_is_ready = False | ||
sleep(5) | ||
log.info("Redis Cluster is configured and ready to use!") | ||
{{- end }} |
23 changes: 23 additions & 0 deletions
23
socialNetwork/helm-chart/socialnetwork/templates/hooks/redis-cluster/post-install-hook.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,23 @@ | ||
{{- if .Values.global.redis.cluster.enabled }} | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: redis-cluster-readiness-hook | ||
annotations: | ||
"helm.sh/hook": "post-install" | ||
spec: | ||
containers: | ||
- name: post-install-container | ||
image: python | ||
imagePullPolicy: Always | ||
command: ['sh', '-c', 'python -m pip install redis && python /tmp/redis_readiness_check.py'] | ||
volumeMounts: | ||
- name: redis-readiness-script | ||
mountPath: /tmp | ||
volumes: | ||
- name: redis-readiness-script | ||
configMap: | ||
name: redis-readiness-script | ||
restartPolicy: Never | ||
terminationGracePeriodSeconds: 0 | ||
{{- end }} |
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
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