From 64cdcec63077eb97b0ab844dce32f0ffd07c1c8a Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Tue, 8 Oct 2024 12:56:04 +0200 Subject: [PATCH] feat(kv-db): add default config for redis-like DBs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The leaks in short-running pods result in idle connections to Redict/Valkey, all of these KV-databases have ‹timeout› option in their config that allows for iterative cleanup of hanging connections. This mitigates the issue to the point of still having free connections slots to Redict/Valkey, i.e., the pods shall be killed, but handlers do not end up in a retry-loop trying to connect to Redict/Valkey. Since the config is 1:1 between all Redis, Redict, and Valkey, create one ConfigMap, map the config into the databases and pass the path to the config as an argument. Tested with Redict and Valkey. »NOT« tested with Redis. Related to packit/packit-service#2522 Signed-off-by: Matej Focko --- openshift/configmap-redis_like_config.yml | 8 ++++++++ openshift/redict.yml.j2 | 6 ++++++ openshift/valkey.yml.j2 | 6 ++++++ playbooks/deploy.yml | 1 + playbooks/roles/deploy/tasks/main.yml | 1 + 5 files changed, 22 insertions(+) create mode 100644 openshift/configmap-redis_like_config.yml diff --git a/openshift/configmap-redis_like_config.yml b/openshift/configmap-redis_like_config.yml new file mode 100644 index 0000000..f234dbd --- /dev/null +++ b/openshift/configmap-redis_like_config.yml @@ -0,0 +1,8 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: redis-like-config +data: + redis.conf: | + timeout 1800 diff --git a/openshift/redict.yml.j2 b/openshift/redict.yml.j2 index 6486950..80889f9 100644 --- a/openshift/redict.yml.j2 +++ b/openshift/redict.yml.j2 @@ -21,11 +21,15 @@ spec: containers: - name: redict image: registry.redict.io/redict:7 + args: + - "/etc/redislike/redis.conf" ports: - containerPort: 6379 volumeMounts: - mountPath: /data name: redict-pv + - mountPath: /etc/redislike + name: redis-like-config resources: # requests and limits have to be the same to have Guaranteed QoS requests: @@ -38,6 +42,8 @@ spec: - name: redict-pv persistentVolumeClaim: claimName: redict-pvc + - name: redis-like-config + configMap: {name: redis-like-config} replicas: 1 strategy: type: Recreate diff --git a/openshift/valkey.yml.j2 b/openshift/valkey.yml.j2 index 1deab4f..12e95c2 100644 --- a/openshift/valkey.yml.j2 +++ b/openshift/valkey.yml.j2 @@ -21,11 +21,15 @@ spec: containers: - name: valkey image: valkey/valkey:8.0.0 + args: + - "/etc/redislike/redis.conf" ports: - containerPort: 6379 volumeMounts: - mountPath: /data name: valkey-pv + - mountPath: /etc/redislike + name: redis-like-config resources: # requests and limits have to be the same to have Guaranteed QoS requests: @@ -38,6 +42,8 @@ spec: - name: valkey-pv persistentVolumeClaim: claimName: valkey-pvc + - name: redis-like-config + configMap: {name: redis-like-config} replicas: 1 strategy: type: Recreate diff --git a/playbooks/deploy.yml b/playbooks/deploy.yml index 0cddac8..f9cc696 100644 --- a/playbooks/deploy.yml +++ b/playbooks/deploy.yml @@ -186,6 +186,7 @@ - name: Deploy key-value database ({{ kv_database }}) ansible.builtin.include_tasks: tasks/k8s.yml loop: + - "{{ lookup('file', '{{ project_dir }}/openshift/configmap-redis_like_config.yml') }}" - "{{ lookup('template', '{{ project_dir }}/openshift/{{ kv_database }}.yml.j2') }}" when: with_kv_database tags: diff --git a/playbooks/roles/deploy/tasks/main.yml b/playbooks/roles/deploy/tasks/main.yml index b546d50..f35e1cc 100644 --- a/playbooks/roles/deploy/tasks/main.yml +++ b/playbooks/roles/deploy/tasks/main.yml @@ -144,6 +144,7 @@ - name: Deploy key-value database ({{ kv_database }}) ansible.builtin.include_tasks: tasks/k8s.yml loop: + - "{{ lookup('file', '{{ project_dir }}/openshift/configmap-redis_like_config.yml') }}" - "{{ lookup('template', '{{ project_dir }}/openshift/{{ kv_database }}.yml.j2') }}" when: with_kv_database tags: