Skip to content

Commit

Permalink
fix(redis): move away from redis to redict
Browse files Browse the repository at this point in the history
Multiple options available:
- KeyDB (multithreaded open-source fork maintained by Snapchat)
- Valkey (fork keeping the former BSD license)
- Redict (fork switching to LGPL license)

For now switch to the Redict as our needs seem to be satisfied:
- they have a wide variety of containers (scratch, alpine, debian)
- as it has been tested (on prod), it works smooth as a drop-in
  replacement
- it is also present in the Fedora and EPEL repos

As for the switch itself:
- introduce new Kubernetes definition for Redict deployment
- introduce new variables ‹with_redis› and ‹with_redict› to allow
  customizable deployment, in case we decide to revert, or switch
- introduce ‹redis_hostname› that is deduced from the ‹with_*›
  variables; also »FAIL« for neither of them being set

Fixes packit#561

Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Apr 24, 2024
1 parent 1120b36 commit e3749af
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ To only disable comparing the variable file to the template, set

To run only the tasks related to some of the services, this way doing a
partial deployment, you can set the `TAGS` environment variable before calling
`make`. For example, to run only the tasks to deploy Redis and Redis
`make`. For example, to run only the tasks to deploy Redict and Redis
Commander, run:

$ DEPLOYMENT=dev TAGS="redis,redis-commander" make deploy
$ DEPLOYMENT=dev TAGS="redict,redis-commander" make deploy

Use `make tags` to list the currently available tags.

Expand Down
2 changes: 1 addition & 1 deletion openshift/flower.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
image: quay.io/packit/flower
env:
- name: CELERY_BROKER_URL
value: redis://redis:6379/0
value: redis://{{ redis_hostname }}:6379/0
- name: FLOWER_PORT
value: "5555"
ports:
Expand Down
2 changes: 1 addition & 1 deletion openshift/packit-service-beat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
- name: APP
value: {{ celery_app }}
- name: REDIS_SERVICE_HOST
value: redis
value: {{ redis_hostname }}
- name: POSTGRESQL_USER
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
- name: POSTGRESQL_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion openshift/packit-service-fedmsg.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- name: FEDORA_MESSAGING_CONF
value: /home/packit/.config/fedora.toml
- name: REDIS_SERVICE_HOST
value: redis
value: {{ redis_hostname }}
- name: PROJECT
value: {{ project }}
- name: DEPLOYMENT
Expand Down
2 changes: 1 addition & 1 deletion openshift/packit-service.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
- name: DISTGIT_NAMESPACE
value: {{ distgit_namespace }}
- name: REDIS_SERVICE_HOST
value: redis
value: {{ redis_hostname }}
- name: POSTGRESQL_USER
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
- name: POSTGRESQL_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion openshift/packit-worker.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spec:
- name: APP
value: {{ celery_app }}
- name: REDIS_SERVICE_HOST
value: redis
value: {{ redis_hostname }}
- name: POSTGRESQL_USER
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
- name: POSTGRESQL_PASSWORD
Expand Down
79 changes: 79 additions & 0 deletions openshift/redict.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
kind: Deployment
apiVersion: apps/v1
metadata:
name: redict
spec:
selector:
matchLabels:
component: redict
template:
metadata:
labels:
component: redict
{% if managed_platform %}
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
spec:
containers:
- name: redict
image: registry.redict.io/redict:7
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /data
name: redict-pv
resources:
# requests and limits have to be the same to have Guaranteed QoS
requests:
memory: "64Mi"
cpu: "10m"
limits:
memory: "64Mi"
cpu: "10m"
volumes:
- name: redict-pv
persistentVolumeClaim:
claimName: redict-pvc
replicas: 1
strategy:
type: Recreate
---
apiVersion: v1
kind: Service
metadata:
name: redict
{% if managed_platform %}
labels:
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
spec:
ports:
- name: "6379"
port: 6379
targetPort: 6379
selector:
component: redict
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redict-pvc
{% if managed_platform %}
labels:
paas.redhat.com/appcode: {{ appcode }}
annotations:
kubernetes.io/reclaimPolicy: Delete
{% endif %}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
{% if managed_platform %}
storageClassName: aws-ebs
{% endif %}
2 changes: 1 addition & 1 deletion openshift/redis-commander.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
image: rediscommander/redis-commander
env:
- name: REDIS_HOST
value: redis
value: {{ redis_hostname }}
- name: REDIS_PORT
value: "6379"
- name: HTTP_USER
Expand Down
13 changes: 13 additions & 0 deletions playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
tenant: packit # MP+ tenant
with_tokman: true
with_fedmsg: true
with_redis: false
with_redict: true
with_redis_commander: false
with_flower: false
with_dashboard: true
Expand Down Expand Up @@ -183,9 +185,20 @@
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redis.yml.j2') }}"
when: with_redis
tags:
- redis

- name: Deploy redict
vars:
k8s_apply: true
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redict.yml.j2') }}"
when: with_redict
tags:
- redict

- name: Deploy fluentd image stream and config
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
Expand Down
5 changes: 4 additions & 1 deletion playbooks/tasks/set-deployment-facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
ansible.builtin.set_fact:
mandatory_deploymentconfigs:
- postgres-{{ postgres_version }}
- redis
- packit-service
tags:
- always

- name: Set optional_deploymentconfigs fact
ansible.builtin.set_fact:
optional_deploymentconfigs:
Expand All @@ -22,8 +22,11 @@
packit-dashboard: "{{ with_dashboard }}"
pushgateway: "{{ with_pushgateway }}"
nginx: "{{ with_pushgateway }}"
redis: "{{ with_redis }}"
redict: "{{ with_redict }}"
tags:
- always

- name: Set deploymentconfigs fact
ansible.builtin.set_fact:
# To know what DCs rollouts to wait for and also to check in tests
Expand Down
19 changes: 19 additions & 0 deletions playbooks/tasks/set-facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,22 @@
ansible.builtin.set_fact:
sandbox_namespace: "{{ service }}-{{ deployment }}-sandbox"
when: not managed_platform

- name: Set redis hostname
tags:
- always
block:
- name: Set redict as the redis hostname
ansible.builtin.set_fact:
redis_hostname: redict
when: with_redict

- name: Set redis as the redis hostname (backward compatibility)
ansible.builtin.set_fact:
redis_hostname: redis
when: with_redis

- name: Warn if neither is set
ansible.builtin.assert:
that: with_redict or with_redis
fail_msg: "[FAIL] Neither redict or redis is set to be deployed!"

0 comments on commit e3749af

Please sign in to comment.