Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/valkey support #597

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions openshift/configmap-redis_like_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: redis-like-config
data:
redis.conf: |
timeout 1800
2 changes: 1 addition & 1 deletion openshift/packit-service-beat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
requests:
memory: "160Mi"
cpu: "5m"
epehemeral-storage: "80Ki"
ephemeral-storage: "80Ki"
limits:
memory: "256Mi"
cpu: "50m"
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 @@ -91,7 +91,7 @@ spec:
requests:
memory: "320Mi"
cpu: "10m"
epehemeral-storage: "300Ki"
ephemeral-storage: "300Ki"
limits:
# run_httpd.sh does 'alembic upgrade head' which might require more memory
# If you see '/usr/bin/run_httpd.sh: line 16: Killed alembic upgrade head'
Expand Down
6 changes: 6 additions & 0 deletions openshift/redict.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
85 changes: 85 additions & 0 deletions openshift/valkey.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
kind: Deployment
apiVersion: apps/v1
metadata:
name: valkey
spec:
selector:
matchLabels:
component: valkey
template:
metadata:
labels:
component: valkey
{% if managed_platform %}
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
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:
memory: "128Mi"
cpu: "10m"
limits:
memory: "256Mi"
cpu: "10m"
volumes:
- name: valkey-pv
persistentVolumeClaim:
claimName: valkey-pvc
- name: redis-like-config
configMap: {name: redis-like-config}
replicas: 1
strategy:
type: Recreate
---
apiVersion: v1
kind: Service
metadata:
name: valkey
{% if managed_platform %}
labels:
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
spec:
ports:
- name: "6379"
port: 6379
targetPort: 6379
selector:
component: valkey
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: valkey-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 %}
19 changes: 7 additions & 12 deletions playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
tenant: packit # MP+ tenant
with_tokman: true
with_fedmsg: true
with_redis: false
with_redict: true
kv_database: "redict"
with_kv_database: true
with_redis_commander: false
with_flower: false
with_dashboard: true
Expand Down Expand Up @@ -183,20 +183,15 @@
tags:
- postgres

- name: Deploy redis
- name: Deploy key-value database ({{ kv_database }})
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redis.yml.j2') }}"
when: with_redis
- "{{ lookup('file', '{{ project_dir }}/openshift/configmap-redis_like_config.yml') }}"
- "{{ lookup('template', '{{ project_dir }}/openshift/{{ kv_database }}.yml.j2') }}"
when: with_kv_database
tags:
- kv_database
- redis
mfocko marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy redict
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redict.yml.j2') }}"
when: with_redict
tags:
- redict
mfocko marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy fluentd image stream and config
Expand Down
4 changes: 2 additions & 2 deletions playbooks/roles/deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ deployment: "{{ lookup('env', 'DEPLOYMENT') }}" # noqa: var-naming[no-role-prefi
tenant: packit # noqa: var-naming[no-role-prefix] # MP+ tenant
with_tokman: true # noqa: var-naming[no-role-prefix]
with_fedmsg: true # noqa: var-naming[no-role-prefix]
with_redis: false # noqa: var-naming[no-role-prefix]
with_redict: true # noqa: var-naming[no-role-prefix]
kv_database: "redict" # noqa: var-naming[no-role-prefix]
with_kv_database: true # noqa: var-naming[no-role-prefix]
with_redis_commander: false # noqa: var-naming[no-role-prefix]
with_flower: false # noqa: var-naming[no-role-prefix]
with_dashboard: true # noqa: var-naming[no-role-prefix]
Expand Down
15 changes: 5 additions & 10 deletions playbooks/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,15 @@
tags:
- postgres

- name: Deploy redis
- name: Deploy key-value database ({{ kv_database }})
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redis.yml.j2') }}"
when: with_redis
- "{{ lookup('file', '{{ project_dir }}/openshift/configmap-redis_like_config.yml') }}"
- "{{ lookup('template', '{{ project_dir }}/openshift/{{ kv_database }}.yml.j2') }}"
when: with_kv_database
tags:
- kv_database
- redis
mfocko marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy redict
ansible.builtin.include_tasks: tasks/k8s.yml
loop:
- "{{ lookup('template', '{{ project_dir }}/openshift/redict.yml.j2') }}"
when: with_redict
tags:
- redict
mfocko marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy fluentd image stream and config
Expand Down
4 changes: 2 additions & 2 deletions playbooks/tasks/set-deployment-facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
packit-dashboard: "{{ with_dashboard }}"
pushgateway: "{{ with_pushgateway }}"
nginx: "{{ with_pushgateway }}"
redis: "{{ with_redis }}"
redict: "{{ with_redict }}"
redis: "{{ with_kv_database and kv_database == 'redis' }}"
redict: "{{ with_kv_database and kv_database == 'redict' }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
redict: "{{ with_kv_database and kv_database == 'redict' }}"
redict: "{{ with_kv_database and kv_database == 'redict' }}"
valkey: "{{ with_kv_database and kv_database == 'valkey' }}"

Not sure why we need this facts but isn't valkey missing here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, must've missed it.

This builds up the optional_deploymentconfigs, from that we build the deploymentconfigs and finally it's checked here

- name: Wait for deploymentconfig rollouts to complete
# timeout 15min to not wait indefinitely in case of a problem
ansible.builtin.command: timeout 15m oc rollout status -w deploy/{{ item }}
register: oc_rollout_status
changed_when: false
failed_when: '"successfully rolled out" not in oc_rollout_status.stdout'
loop: "{{ deploymentconfigs }}"

that they're running. It's a bit flaky though, cause it doesn't work properly if you don't run oc project ‹packit namespace› beforehand in the terminal.

tags:
- always

Expand Down
26 changes: 2 additions & 24 deletions playbooks/tasks/set-facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,5 @@
- name: Set Redis-like hostname
tags:
- always
block:
# Needed for nice message of the sanity check
- name: Set default for the hostname
ansible.builtin.set_fact:
redis_hostname: None

- name: Set Redict as the hostname
ansible.builtin.set_fact:
redis_hostname: redict
when: with_redict

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

- name: Sanity check for deploying exactly one of Redis or Redict
ansible.builtin.assert:
that: with_redict != with_redis
success_msg: |
[INFO] Deploying {{ redis_hostname }}
fail_msg: |
[FAIL] Check vars (‹with_redict› and ‹with_redis›).
Cannot deploy none or both of Redis and Redict!
ansible.builtin.set_fact:
redis_hostname: "{{ kv_database }}"
3 changes: 3 additions & 0 deletions vars/packit/dev_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ check_up_to_date: false
# edit the queue name in secrets/*/fedora.toml
with_fedmsg: false

# kv_database: redict
mfocko marked this conversation as resolved.
Show resolved Hide resolved
# with_kv_database: true

with_redis_commander: false

with_flower: true
Expand Down
3 changes: 3 additions & 0 deletions vars/packit/prod_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ api_key: ""
# edit the queue name in secrets/*/fedora.toml
# with_fedmsg: true

# kv_database: valkey
mfocko marked this conversation as resolved.
Show resolved Hide resolved
# with_kv_database: true

# with_redis_commander: false

with_flower: true
Expand Down
3 changes: 3 additions & 0 deletions vars/packit/stg_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ api_key: ""
# edit the queue name in secrets/*/fedora.toml
# with_fedmsg: true

# kv_database: valkey
mfocko marked this conversation as resolved.
Show resolved Hide resolved
# with_kv_database: true

# with_redis_commander: false

with_flower: true
Expand Down
Loading