Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 191 additions & 11 deletions README.md

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions demo/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ kubectl apply -f redis.yaml
kubectl apply -f rabbitmq.yaml
kubectl apply -f storage.yaml

# Wait for all four to be Running
# Wait for the three dependency pods to be Running
kubectl get pods -n euro-office -w
```

Expand All @@ -110,7 +110,7 @@ Verify connectivity before installing the chart:
# Postgres
kubectl run pgtest --rm -it --restart=Never -n euro-office \
--image=postgres:16 -- \
psql "postgresql://onlyoffice:onlyoffice@pg-postgresql:5432/onlyoffice" -c "SELECT 1;"
psql "postgresql://eurooffice:eurooffice@pg-postgresql:5432/eurooffice" -c "SELECT 1;"

# Redis
kubectl run redistest --rm -it --restart=Never -n euro-office \
Expand All @@ -135,7 +135,7 @@ Expected sequence:
3. `converter-*` → 1/1 Running
4. `docservice-*` → 2/2 Running (docservice + proxy sidecar)
5. `example-0` → 1/1 Running
5. `adminpanel-0` → 1/1 Running
6. `adminpanel-0` → 1/1 Running

Press Ctrl-C once everything reads Running or Completed.

Expand Down Expand Up @@ -211,6 +211,10 @@ sudo rm -rf /tmp/euro-office-shared
- `rabbitmq.yaml` — RabbitMQ deployment, service, and secret
- `storage.yaml` — `nfs` StorageClass and static PVs backed by the host-mounted shared directory
- `my-values.yml` — Helm chart overrides (image references, connection URLs, JWT secret, env vars)
- `my-values.redis-standalone.yml` — enables Redis for both editor data and statistics using standalone Redis
- `my-values.redis-data-only.yml` — enables Redis for editor data while keeping statistics in memory
- `my-values.redis-sentinel.yml` — Sentinel configuration overlay for an external Redis Sentinel deployment
- `my-values.redis-cluster.yml` — Cluster configuration overlay for an external Redis Cluster deployment

## Limitations

Expand All @@ -220,3 +224,28 @@ This setup is for local testing only:
- The shared host volume at `/tmp/euro-office-shared` only works because k3d nodes run on a single host; in a real cluster, replace `storage.yaml` with proper NFS or another RWX provisioner
- Single-replica databases with no backups
- No TLS, no ingress, port-forwarding only

## Redis editor-storage examples

The base `my-values.yml` leaves both editor stores in their default `memory`
mode. Apply one of the overlays together with the base values file to select a
Redis topology. Only one Redis topology may be configured at a time.

The standalone overlay works with the `redis.yaml` manifest included here:

```bash
helm install docs .. -n euro-office \
-f my-values.yml -f my-values.redis-standalone.yml --timeout 10m
```

The data-only overlay demonstrates that the two storage modules can be chosen
independently:

```bash
helm install docs .. -n euro-office \
-f my-values.yml -f my-values.redis-data-only.yml --timeout 10m
```

The Sentinel and Cluster overlays contain example node names and require an
external topology with those names, or equivalent values edited for the target
environment. They do not deploy Sentinel or Cluster resources.
19 changes: 19 additions & 0 deletions demo/my-values.redis-cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Apply together with my-values.yml after providing a reachable Redis Cluster
# deployment. This file does not deploy a Redis Cluster itself.
#
# helm install docs .. -n euro-office -f my-values.yml -f my-values.redis-cluster.yml

docservice:
editorDataStorage: cluster
editorStatStorage: cluster

connections:
# Startup/readiness fallback endpoint. Cluster discovery uses redisClusterNodes.
redisHost: redis-cluster-0.euro-office.svc.cluster.local
redisPort: 6379
redisClusterNodes:
- redis-cluster-0.euro-office.svc.cluster.local:6379
- redis-cluster-1.euro-office.svc.cluster.local:6379
- redis-cluster-2.euro-office.svc.cluster.local:6379
# Redis Cluster does not support selecting a non-zero logical database.
redisDBNum: "0"
7 changes: 7 additions & 0 deletions demo/my-values.redis-data-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Editor data uses Redis; editor statistics keep the memory backend.
# Apply together with my-values.yml:
# helm install docs .. -n euro-office -f my-values.yml -f my-values.redis-data-only.yml

docservice:
editorDataStorage: standalone
editorStatStorage: memory
19 changes: 19 additions & 0 deletions demo/my-values.redis-sentinel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Apply together with my-values.yml after providing a reachable Redis Sentinel
# deployment. This file does not deploy Sentinel itself.
#
# helm install docs .. -n euro-office -f my-values.yml -f my-values.redis-sentinel.yml

docservice:
editorDataStorage: sentinel
editorStatStorage: sentinel

connections:
# Fallback/startup endpoint. Sentinel discovery uses redisSentinelNodes.
redisHost: redis-sentinel.euro-office.svc.cluster.local
redisPort: 26379
redisSentinelNodes:
- redis-sentinel-0.euro-office.svc.cluster.local:26379
- redis-sentinel-1.euro-office.svc.cluster.local:26379
- redis-sentinel-2.euro-office.svc.cluster.local:26379
redisSentinelGroupName: mymaster
redisSentinelNoPass: true
6 changes: 6 additions & 0 deletions demo/my-values.redis-standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Apply together with my-values.yml:
# helm install docs .. -n euro-office -f my-values.yml -f my-values.redis-standalone.yml

docservice:
editorDataStorage: standalone
editorStatStorage: standalone
5 changes: 2 additions & 3 deletions demo/my-values.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Skip the demo app
# Enable the demo app
example:
enabled: true
dsUrl: "http://localhost:8082/"
Expand All @@ -23,7 +23,6 @@ connections:
dbUser: eurooffice
dbPassword: eurooffice

redisConnectorName: ioredis
redisHost: redis-master.euro-office.svc.cluster.local
redisPort: 6379
redisPassword: redis
Expand Down Expand Up @@ -52,4 +51,4 @@ requestFilteringAgent:

log:

level: DEBUG
level: DEBUG
65 changes: 43 additions & 22 deletions sources/scripts/test_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@
import time
import logging

redisConnectorName = os.environ.get('REDIS_CONNECTOR_NAME')

def redis_tls_options(prefix):
if os.environ.get(f'{prefix}_TLS') != 'true':
return {}
options = {'ssl': True, 'ssl_cert_reqs': 'required'}
ca_certs = os.environ.get(f'{prefix}_CA_CERTS')
if ca_certs:
options['ssl_ca_certs'] = ca_certs
return options


redisHost = os.environ.get('REDIS_SERVER_HOST')
redisPort = os.environ.get('REDIS_SERVER_PORT')
redisUser = os.environ.get('REDIS_SERVER_USER')
redisPassword = os.environ.get('REDIS_SERVER_PWD')
redisTLSOptions = redis_tls_options('REDIS_SERVER')
redisSentinelTLSOptions = redis_tls_options('REDIS_SENTINEL')
redisSentinelUser = os.environ.get('REDIS_SENTINEL_USER')
redisSentinelPassword = os.environ.get('REDIS_SENTINEL_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':
if os.environ.get('REDIS_SENTINEL_NODES'):
redisSentinelGroupName = os.environ.get('REDIS_SENTINEL_GROUP_NAME')
if os.environ.get('REDIS_SENTINEL_NODES'):
redisSentinelNodes = list(os.environ.get('REDIS_SENTINEL_NODES').split(" "))
Expand Down Expand Up @@ -73,7 +86,8 @@ def get_redis_status():
password=redisPassword,
username=redisUser,
socket_connect_timeout=redisConnectTimeout,
retry=retry_strategy
retry=retry_strategy,
**redisTLSOptions
)
rc.ping()
except Exception as msg_redis:
Expand All @@ -98,7 +112,8 @@ def get_redis_cluster_status():
username=redisUser,
password=redisPassword,
socket_connect_timeout=redisConnectTimeout,
retry=retry_strategy
retry=retry_strategy,
**redisTLSOptions
)
rc.ping()
except Exception as msg_redis:
Expand All @@ -117,7 +132,12 @@ def get_redis_sentinel_status():
retry_strategy = Retry(ExponentialBackoff(), retries=3)
global rc
try:
sentinel = Sentinel([(redisSentinelNode, redisSentinelPort)], socket_timeout=redisConnectTimeout, sentinel_kwargs={'password': redisSentinelPassword})
sentinel_kwargs = dict(redisSentinelTLSOptions)
if redisSentinelUser:
sentinel_kwargs['username'] = redisSentinelUser
if redisSentinelPassword:
sentinel_kwargs['password'] = redisSentinelPassword
sentinel = Sentinel([(redisSentinelNode, redisSentinelPort)], socket_timeout=redisConnectTimeout, sentinel_kwargs=sentinel_kwargs)
master_host, master_port = sentinel.discover_master(redisSentinelGroupName)
rc = redis.Redis(
host=master_host,
Expand All @@ -126,7 +146,8 @@ def get_redis_sentinel_status():
password=redisPassword,
username=redisUser,
socket_connect_timeout=redisConnectTimeout,
retry=retry_strategy
retry=retry_strategy,
**redisTLSOptions
)
rc.ping()
except Exception as msg_redis:
Expand Down Expand Up @@ -154,14 +175,14 @@ def check_redis_key():

def check_redis():
logger_test_ds.info('Checking Redis availability...')
if redisConnectorName == 'redis' and not os.environ.get('REDIS_CLUSTER_NODES'):
if get_redis_status() is True:
if os.environ.get('REDIS_SENTINEL_NODES'):
if get_redis_sentinel_status() is True:
check_redis_key()
elif redisConnectorName == 'redis' and os.environ.get('REDIS_CLUSTER_NODES'):
elif 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:
else:
if get_redis_status() is True:
check_redis_key()


Expand Down Expand Up @@ -362,17 +383,17 @@ def total_status():
logger_test_ds.info('As a result of the check, the following results were obtained:')
for key, value in total_result.items():
logger_test_ds.info(f'{key} = {value}')
if total_result['CheckDS'] != 'Success':
if any(value != 'Success' for value in total_result.values()):
sys.exit(1)


init_logger('test')
logger_test_ds = logging.getLogger('test.ds')
check_redis()
check_db()
check_mq()
if storageS3 == 'false':
check_dir_access()
get_ds_status()
total_status()

if __name__ == '__main__':
init_logger('test')
logger_test_ds = logging.getLogger('test.ds')
check_redis()
check_db()
check_mq()
if storageS3 == 'false':
check_dir_access()
get_ds_status()
total_status()
78 changes: 78 additions & 0 deletions sources/scripts/test_ds_tls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python3
"""Connectivity hook TLS regression tests. Run with Python 3 and redis-py:

python3 sources/scripts/test_ds_tls.py
"""

import importlib.util
import itertools
import os
from pathlib import Path
import unittest
from unittest.mock import Mock, patch

import redis
import redis.cluster


SCRIPT = Path(__file__).with_name("test_ds.py")


class RedisTLSConnectivity(unittest.TestCase):
def test_tls_and_ca_settings_reach_each_client(self):
for topology, node_tls, sentinel_tls, node_ca, sentinel_ca in itertools.product(
("standalone", "cluster", "sentinel"), (False, True), (False, True),
("", "/ca/nodes.pem"), ("", "/ca/sentinels.pem"),
):
with self.subTest(topology=topology, node_tls=node_tls, sentinel_tls=sentinel_tls,
node_ca=node_ca, sentinel_ca=sentinel_ca):
env = {
"DB_PORT": "5432",
"REDIS_SERVER_HOST": "redis", "REDIS_SERVER_PORT": "6379",
"REDIS_SERVER_TLS": str(node_tls).lower(),
"REDIS_SENTINEL_TLS": str(sentinel_tls).lower(),
"REDIS_SERVER_CA_CERTS": node_ca,
"REDIS_SENTINEL_CA_CERTS": sentinel_ca,
}
if topology == "cluster":
env["REDIS_CLUSTER_NODES"] = "redis:6379"
elif topology == "sentinel":
env.update({"REDIS_SENTINEL_NODES": "sentinel:26379",
"REDIS_SENTINEL_GROUP_NAME": "mymaster"})
spec = importlib.util.spec_from_file_location("connectivity_hook", SCRIPT)
hook = importlib.util.module_from_spec(spec)
with patch.dict(os.environ, env, clear=True):
spec.loader.exec_module(hook)
hook.logger_test_ds = Mock()
with patch.object(redis, "Redis") as standalone, \
patch.object(redis.cluster, "RedisCluster") as cluster, \
patch.object(redis, "Sentinel") as sentinel:
sentinel.return_value.discover_master.return_value = ("master", 6379)
client = cluster if topology == "cluster" else standalone
client.return_value.ping.return_value = True
check = {"standalone": hook.get_redis_status,
"cluster": hook.get_redis_cluster_status,
"sentinel": hook.get_redis_sentinel_status}[topology]
self.assertIs(check(), True)
self.assert_tls_options(client.call_args.kwargs, node_tls, node_ca)
if topology == "sentinel":
self.assert_tls_options(sentinel.call_args.kwargs["sentinel_kwargs"],
sentinel_tls, sentinel_ca)
self.assertEqual(client.call_args.kwargs["host"], "master")

def assert_tls_options(self, options, enabled, ca):
if enabled:
self.assertIs(options["ssl"], True)
self.assertEqual(options["ssl_cert_reqs"], "required")
if ca:
self.assertEqual(options["ssl_ca_certs"], ca)
else:
self.assertNotIn("ssl_ca_certs", options)
else:
self.assertNotIn("ssl", options)
self.assertNotIn("ssl_cert_reqs", options)
self.assertNotIn("ssl_ca_certs", options)


if __name__ == "__main__":
unittest.main()
Loading
Loading