Badges: add Redis for caching

Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
Aurélien Bompard 2024-04-29 12:59:10 +02:00
parent 321edb65cc
commit 14f399e536
No known key found for this signature in database
GPG key ID: 31584CFEB9BF64AD
5 changed files with 75 additions and 2 deletions

View file

@ -32,3 +32,14 @@ items:
kind: ImageStream
metadata:
name: python-310-custom-builder
# Redis (for caching)
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: redis
spec:
tags:
- name: latest
from:
kind: DockerImage
name: docker.io/bitnami/redis:latest

View file

@ -14,3 +14,19 @@ spec:
targetPort: 8080
selector:
deploymentconfig: frontend
---
apiVersion: v1
kind: Service
metadata:
name: redis
labels:
app: badges
spec:
ports:
- name: redis
port: 6379
protocol: TCP
targetPort: 6379
selector:
app: badges
deploymentconfig: redis

View file

@ -212,3 +212,42 @@ spec:
from:
kind: ImageStreamTag
name: fedbadges:latest
---
# Redis, for caching
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: redis
labels:
app: badges
service: redis
spec:
replicas: 1
selector:
app: badges
deploymentconfig: redis
template:
metadata:
labels:
app: badges
deploymentconfig: redis
spec:
containers:
- name: redis
image: redis:latest
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: badges
key: redis-password
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- redis
from:
kind: ImageStreamTag
name: redis:latest

View file

@ -66,12 +66,17 @@ fasjson_base_url = "https://fasjson{{ env_suffix }}.fedoraproject.org"
# Cache configuation
[consumer_config.cache]
backend = "dogpile.cache.pymemcache"
backend = "dogpile.cache.redis"
expiration_time = 86400
[consumer_config.cache.arguments]
url = "memcached01{{ env_suffix }}:11211"
host = "redis.badges.svc.cluster.local"
port = 6379
password = "{{ (env == 'production')|ternary(badges_prod_redis_password, badges_stg_redis_password) }}"
db = 0
redis_expiration_time = 86400
distributed_lock = true
lock_timeout = 5
thread_local_lock = false
# This is a set of data that tells our consumer what Open Badges Issuer
# should be kept as the issuer of all the badges we create.

View file

@ -6,6 +6,8 @@ metadata:
stringData:
{% if env == 'staging' %}
oidc-client-secret: {{ badges_stg_oidc_client_secret }}
redis-password: {{ badges_stg_redis_password }}
{% else %}
oidc-client-secret: {{ badges_prod_oidc_client_secret }}
redis-password: {{ badges_prod_redis_password }}
{% endif %}