diff --git a/README.md b/README.md index 46885e53a..ad5ff00b0 100644 --- a/README.md +++ b/README.md @@ -377,6 +377,7 @@ The `helm delete` command removes all the Kubernetes components associated with | `connections.redisPort` | The Redis server port number | `6379` | | `connections.redisUser` | The Redis [user](https://redis.io/docs/management/security/acl/) name. The value in this parameter overrides the value set in the `options` object in `local.json` if you add custom configuration file | `default` | | `connections.redisDBNum` | Number of the redis logical database to be [selected](https://redis.io/commands/select/). The value in this parameter overrides the value set in the `options` object in `local.json` if you add custom configuration file | `0` | +| `connections.redisClusterNodes` | List of nodes in the Redis cluster. There is no need to specify every node in the cluster, 3 should be enough. You can specify multiple values. It must be specified in the `host:port` format | `[]` | | `connections.redisSentinelGroupName` | Name of a group of Redis instances composed of a master and one or more slaves. Used if `connections.redisConnectorName` is set to `ioredis` | `mymaster` | | `connections.redisPassword` | The password set for the Redis account. If set to, it takes priority over the `connections.redisExistingSecret`. The value in this parameter overrides the value set in the `options` object in `local.json` if you add custom configuration file | `""` | | `connections.redisSecretKeyName` | The name of the key that contains the Redis user password | `redis-password` | @@ -422,8 +423,8 @@ The `helm delete` command removes all the Kubernetes components associated with | `imagePullSecrets` | Container image registry secret name | `""` | | `requestFilteringAgent.allowPrivateIPAddress` | Defines if it is allowed to connect private IP address or not. `requestFilteringAgent` parameters are used if JWT is disabled: `jwt.enabled=false` | `false` | | `requestFilteringAgent.allowMetaIPAddress` | Defines if it is allowed to connect meta address or not | `false` | -| `requestFilteringAgent.allowIPAddressList` | Defines the list of IP addresses allowed to connect. This values are preferred than `requestFilteringAgent.denyIPAddressList` | '[]' | -| `requestFilteringAgent.denyIPAddressList` | Defines the list of IP addresses allowed to connect | '[]' | +| `requestFilteringAgent.allowIPAddressList` | Defines the list of IP addresses allowed to connect. This values are preferred than `requestFilteringAgent.denyIPAddressList` | `[]` | +| `requestFilteringAgent.denyIPAddressList` | Defines the list of IP addresses allowed to connect | `[]` | | `docservice.podAnnotations` | Map of annotations to add to the Docservice deployment pods | `rollme: "{{ randAlphaNum 5 \| quote }}"` | | `docservice.replicas` | Docservice replicas quantity. If the `docservice.autoscaling.enabled` parameter is enabled, it is ignored | `2` | | `docservice.updateStrategy.type` | Docservice deployment update strategy type | `Recreate` | diff --git a/sources/scripts/test_ds.py b/sources/scripts/test_ds.py index c8e9e041b..4dee6a1ce 100755 --- a/sources/scripts/test_ds.py +++ b/sources/scripts/test_ds.py @@ -13,6 +13,10 @@ redisPassword = os.environ.get('REDIS_SERVER_PWD') redisDBNum = os.environ.get('REDIS_SERVER_DB_NUM') redisConnectTimeout = 15 +if os.environ.get('REDIS_CLUSTER_NODES'): + redisClusterNodes = list(os.environ.get('REDIS_CLUSTER_NODES').split(" ")) + redisClusterNode = redisClusterNodes[0].split(":")[0] + redisClusterPort = redisClusterNodes[0].split(":")[1] if redisConnectorName == 'ioredis': redisSentinelGroupName = os.environ.get('REDIS_SENTINEL_GROUP_NAME') @@ -72,10 +76,33 @@ def get_redis_status(): ) rc.ping() except Exception as msg_redis: - logger_test_ds.error(f'Failed to check the availability of the Redis... {msg_redis}\n') + logger_test_ds.error(f'Failed to check the availability of the Redis Standalone... {msg_redis}\n') total_result['CheckRedis'] = 'Failed' else: - logger_test_ds.info('Successful connection to Redis') + logger_test_ds.info('Successful connection to Redis Standalone') + return rc.ping() + + +def get_redis_cluster_status(): + install_module('redis') + from redis.cluster import RedisCluster as Redis + from redis.cluster import ClusterNode + global rc + try: + nodes = [ClusterNode(redisClusterNode, redisClusterPort)] + rc = Redis( + startup_nodes=nodes, + username=redisUser, + password=redisPassword, + socket_connect_timeout=redisConnectTimeout, + retry_on_timeout=True + ) + rc.ping() + except Exception as msg_redis: + logger_test_ds.error(f'Failed to check the availability of the Redis Cluster... {msg_redis}\n') + total_result['CheckRedis'] = 'Failed' + else: + logger_test_ds.info('Successful connection to Redis Cluster') return rc.ping() @@ -98,10 +125,10 @@ def get_redis_sentinel_status(): ) rc.ping() except Exception as msg_redis: - logger_test_ds.error(f'Failed to check the availability of the Redis... {msg_redis}\n') + logger_test_ds.error(f'Failed to check the availability of the Redis Sentinel... {msg_redis}\n') total_result['CheckRedis'] = 'Failed' else: - logger_test_ds.info('Successful connection to Redis') + logger_test_ds.info('Successful connection to Redis Sentinel') return rc.ping() @@ -122,9 +149,12 @@ def check_redis_key(): def check_redis(): logger_test_ds.info('Checking Redis availability...') - if redisConnectorName == 'redis': + if redisConnectorName == 'redis' and not os.environ.get('REDIS_CLUSTER_NODES'): if get_redis_status() is True: check_redis_key() + elif redisConnectorName == 'redis' and os.environ.get('REDIS_CLUSTER_NODES'): + if get_redis_cluster_status() is True: + check_redis_key() elif redisConnectorName == 'ioredis': if get_redis_sentinel_status() is True: check_redis_key() diff --git a/templates/configmaps/documentserver.yaml b/templates/configmaps/documentserver.yaml index 231ffd20e..f71695cf5 100644 --- a/templates/configmaps/documentserver.yaml +++ b/templates/configmaps/documentserver.yaml @@ -18,6 +18,9 @@ data: REDIS_SERVER_PORT: {{ .Values.connections.redisPort | quote }} REDIS_SERVER_USER: {{ .Values.connections.redisUser }} REDIS_SERVER_DB_NUM: {{ .Values.connections.redisDBNum | quote }} + {{- if.Values.connections.redisClusterNodes }} + REDIS_CLUSTER_NODES: {{ join " " .Values.connections.redisClusterNodes }} + {{- end }} {{- if eq .Values.connections.redisConnectorName "ioredis" }} REDIS_SENTINEL_GROUP_NAME: {{ .Values.connections.redisSentinelGroupName }} {{- end }} diff --git a/values.yaml b/values.yaml index 144dd0cf9..e63f0114b 100644 --- a/values.yaml +++ b/values.yaml @@ -35,8 +35,10 @@ connections: ## If you need to connect to Redis Sentinel, set the value `ioredis` redisConnectorName: redis ## connections.redisHost The IP address or the name of the Redis host + ## Not used if values are set in `connections.redisClusterNodes` redisHost: redis-master ## connections.redisPort The Redis server port number + ## Not used if values are set in `connections.redisClusterNodes` redisPort: "6379" ## connections.redisUser The Redis user name ## ref: https://redis.io/docs/management/security/acl/ @@ -45,7 +47,17 @@ connections: ## connections.redisDBNum Number of the redis logical database to be selected ## ref: https://redis.io/commands/select/ ## The value in this parameter overrides the value set in the `options` object in `local.json` if you add custom configuration file + ## Not used if values are set in `connections.redisClusterNodes` redisDBNum: "0" + ## connections.redisClusterNodes List of nodes in the Redis cluster + ## There is no need to specify every node in the cluster, 3 should be enough + ## You can specify multiple values + ## It must be specified in the `host:port` format + ## Example: + ## redisClusterNodes: + ## - 10.244.0.79:6379 + ## - 192.168.1.25:6379 + redisClusterNodes: [] ## connections.redisSentinelGroupName Name of a group of Redis instances composed of a master and one or more slaves ## Used if `connections.redisConnectorName` is set to `ioredis` redisSentinelGroupName: mymaster