Skip to content

Commit 136dd47

Browse files
authored
Fix/try redict (#569)
2 parents 1120b36 + c4a0593 commit 136dd47

File tree

12 files changed

+203
-9
lines changed

12 files changed

+203
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ To only disable comparing the variable file to the template, set
5757

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

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

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Redict
3+
---
4+
5+
## Seamless migration between providers
6+
7+
We have tested a seamless migration from Redis to Redict on our production
8+
deployment. To reproduce:
9+
10+
1. We have deployed Redict to our production cluster.
11+
12+
- Defaults have been changed to:
13+
14+
```yaml
15+
with_redis: false
16+
with_redict: true
17+
```
18+
19+
These can be changed in their respective `vars/` files.
20+
21+
- Run
22+
23+
```
24+
DEPLOYMENT=prod TAGS=redict make deploy
25+
```
26+
27+
2. Using remote shell and `redict-cli` run:
28+
29+
```sh
30+
replicaof redis 6379
31+
```
32+
33+
This converts the Redict instance into a read-only replica of the Redis.
34+
35+
3. After the data exchange is done, change **all** references in variables to
36+
redis to point to the new hostname, in this case `redis → redict`.
37+
38+
- Run
39+
40+
```
41+
DEPLOYMENT=prod TAGS=packit-service-beat,fedmsg,packit-worker,packit-service make deploy
42+
```
43+
44+
4. Simultaneously run the deployment with the changed hostnames and via
45+
`redict-cli` run:
46+
47+
```sh
48+
replicaof no one
49+
```
50+
51+
to make the redict deployment the primary one.
52+
53+
5. (optional) For safety reasons and easier rollback, it's possible to convert
54+
the former Redis deployment into a replica of Redict, just in case it needs
55+
to be reverted without loss of data. For this you can run in `redis-cli`:
56+
57+
```sh
58+
replicaof redict 6379
59+
```
60+
61+
:::warning References to Redis
62+
63+
Redis is being referenced from:
64+
65+
- `packit-service` (API endpoint)
66+
- `packit-service-fedmsg` (Fedora Messaging listener)
67+
- `packit-service-beat` (triggers periodic tasks)
68+
- `packit-worker` (runs the jobs provided by API, Fedora Messaging and “beat”)
69+
- `flower` (monitoring of the Celery queues)
70+
71+
:::

openshift/flower.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
image: quay.io/packit/flower
2424
env:
2525
- name: CELERY_BROKER_URL
26-
value: redis://redis:6379/0
26+
value: redis://{{ redis_hostname }}:6379/0
2727
- name: FLOWER_PORT
2828
value: "5555"
2929
ports:

openshift/packit-service-beat.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
- name: APP
4242
value: {{ celery_app }}
4343
- name: REDIS_SERVICE_HOST
44-
value: redis
44+
value: {{ redis_hostname }}
4545
- name: POSTGRESQL_USER
4646
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
4747
- name: POSTGRESQL_PASSWORD

openshift/packit-service-fedmsg.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
- name: FEDORA_MESSAGING_CONF
3434
value: /home/packit/.config/fedora.toml
3535
- name: REDIS_SERVICE_HOST
36-
value: redis
36+
value: {{ redis_hostname }}
3737
- name: PROJECT
3838
value: {{ project }}
3939
- name: DEPLOYMENT

openshift/packit-service.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ spec:
5252
- name: DISTGIT_NAMESPACE
5353
value: {{ distgit_namespace }}
5454
- name: REDIS_SERVICE_HOST
55-
value: redis
55+
value: {{ redis_hostname }}
5656
- name: POSTGRESQL_USER
5757
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
5858
- name: POSTGRESQL_PASSWORD

openshift/packit-worker.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ spec:
8686
- name: APP
8787
value: {{ celery_app }}
8888
- name: REDIS_SERVICE_HOST
89-
value: redis
89+
value: {{ redis_hostname }}
9090
- name: POSTGRESQL_USER
9191
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
9292
- name: POSTGRESQL_PASSWORD

openshift/redict.yml.j2

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright Contributors to the Packit project.
2+
# SPDX-License-Identifier: MIT
3+
4+
---
5+
kind: Deployment
6+
apiVersion: apps/v1
7+
metadata:
8+
name: redict
9+
spec:
10+
selector:
11+
matchLabels:
12+
component: redict
13+
template:
14+
metadata:
15+
labels:
16+
component: redict
17+
{% if managed_platform %}
18+
paas.redhat.com/appcode: {{ appcode }}
19+
{% endif %}
20+
spec:
21+
containers:
22+
- name: redict
23+
image: registry.redict.io/redict:7
24+
ports:
25+
- containerPort: 6379
26+
volumeMounts:
27+
- mountPath: /data
28+
name: redict-pv
29+
resources:
30+
# requests and limits have to be the same to have Guaranteed QoS
31+
requests:
32+
memory: "128Mi"
33+
cpu: "10m"
34+
limits:
35+
memory: "256Mi"
36+
cpu: "10m"
37+
volumes:
38+
- name: redict-pv
39+
persistentVolumeClaim:
40+
claimName: redict-pvc
41+
replicas: 1
42+
strategy:
43+
type: Recreate
44+
---
45+
apiVersion: v1
46+
kind: Service
47+
metadata:
48+
name: redict
49+
{% if managed_platform %}
50+
labels:
51+
paas.redhat.com/appcode: {{ appcode }}
52+
{% endif %}
53+
spec:
54+
ports:
55+
- name: "6379"
56+
port: 6379
57+
targetPort: 6379
58+
selector:
59+
component: redict
60+
---
61+
apiVersion: v1
62+
kind: PersistentVolumeClaim
63+
metadata:
64+
name: redict-pvc
65+
{% if managed_platform %}
66+
labels:
67+
paas.redhat.com/appcode: {{ appcode }}
68+
annotations:
69+
kubernetes.io/reclaimPolicy: Delete
70+
{% endif %}
71+
spec:
72+
accessModes:
73+
- ReadWriteOnce
74+
resources:
75+
requests:
76+
storage: 1Gi
77+
{% if managed_platform %}
78+
storageClassName: aws-ebs
79+
{% endif %}

openshift/redis-commander.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
image: rediscommander/redis-commander
2424
env:
2525
- name: REDIS_HOST
26-
value: redis
26+
value: {{ redis_hostname }}
2727
- name: REDIS_PORT
2828
value: "6379"
2929
- name: HTTP_USER

playbooks/deploy.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
tenant: packit # MP+ tenant
1313
with_tokman: true
1414
with_fedmsg: true
15+
with_redis: false
16+
with_redict: true
1517
with_redis_commander: false
1618
with_flower: false
1719
with_dashboard: true
@@ -183,9 +185,20 @@
183185
ansible.builtin.include_tasks: tasks/k8s.yml
184186
loop:
185187
- "{{ lookup('template', '{{ project_dir }}/openshift/redis.yml.j2') }}"
188+
when: with_redis
186189
tags:
187190
- redis
188191

192+
- name: Deploy redict
193+
vars:
194+
k8s_apply: true
195+
ansible.builtin.include_tasks: tasks/k8s.yml
196+
loop:
197+
- "{{ lookup('template', '{{ project_dir }}/openshift/redict.yml.j2') }}"
198+
when: with_redict
199+
tags:
200+
- redict
201+
189202
- name: Deploy fluentd image stream and config
190203
ansible.builtin.include_tasks: tasks/k8s.yml
191204
loop:

0 commit comments

Comments
 (0)