1
0
Fork 0
forked from infra/ansible

bodhi-stg: add a valkey pod

Signed-off-by: Mattia Verga <mattia.verga@tiscali.it>
This commit is contained in:
Mattia Verga 2026-04-06 11:29:59 +02:00 committed by Mattia Verga
commit 2dc6e6ec68
5 changed files with 163 additions and 0 deletions

View file

@ -13,3 +13,5 @@ spec:
targetPort: 8080
selector:
app: bodhi-web
# bodhi-valkey service is configured in deployment_yml.j2
# because it exists only for staging, at the moment

View file

@ -49,5 +49,27 @@ items:
to:
kind: ImageStreamTag
name: bodhi-critpathcron:latest
{% if env == "staging" %}
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
build: bodhi-valkey
name: bodhi-valkey
spec:
runPolicy: Serial
source:
dockerfile: |-
{{ load_file('dockerfile-valkey') | indent(8) }}
type: Dockerfile
strategy:
type: Docker
dockerStrategy:
noCache: True
output:
to:
kind: ImageStreamTag
name: bodhi-valkey:latest
{% endif %}
kind: List
metadata: {}

View file

@ -34,6 +34,17 @@ spec:
- name: config-volume
mountPath: /etc/bodhi
readOnly: true
{% if env == "staging" %}
- name: wait-for-valkey
image: image-registry.openshift-image-registry.svc:5000/bodhi/bodhi-valkey:latest
command: ['/bin/sh', '-c', 'until valkey-cli -h bodhi-valkey -p 6379 -a "$BODHI_VALKEY_PASSWORD" ping; do echo "Waiting for Valkey..."; sleep 2; done']
env:
- name: BODHI_VALKEY_PASSWORD
valueFrom:
secretKeyRef:
name: bodhi-valkey-secret
key: password
{% endif %}
containers:
- name: bodhi-web
image: image-registry.openshift-image-registry.svc:5000/bodhi/bodhi-base:latest
@ -348,3 +359,79 @@ spec:
- name: fedora-messaging-key-volume
secret:
secretName: bodhi-fedora-messaging-key
{% if env == "staging" %}
---
# bodhi-valkey
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: bodhi-valkey
name: bodhi-valkey
spec:
replicas: 1
selector:
matchLabels:
app: bodhi-valkey
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: bodhi-valkey
annotations:
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"bodhi-valkey:latest","namespace":"bodhi"},"fieldPath":"spec.template.spec.containers[?(@.name==\"bodhi-valkey\")].image"}]'
spec:
containers:
- name: bodhi-valkey
image: image-registry.openshift-image-registry.svc:5000/bodhi/bodhi-valkey:latest
env:
- name: BODHI_VALKEY_PASSWORD
valueFrom:
secretKeyRef:
name: bodhi-valkey-secret
key: password
resources: {}
volumeMounts:
- name: bodhi-valkey-data-volume
mountPath: /data
ports:
- containerPort: 6379
protocol: TCP
readinessProbe:
timeoutSeconds: 10
initialDelaySeconds: 5
periodSeconds: 60
exec:
command: ['/bin/sh', '-c', 'valkey-cli -a "$BODHI_VALKEY_PASSWORD" ping']
livenessProbe:
timeoutSeconds: 60
initialDelaySeconds: 30
periodSeconds: 120
failureThreshold: 5
exec:
command: ['/bin/sh', '-c', 'valkey-cli -a "$BODHI_VALKEY_PASSWORD" ping']
volumes:
- name: bodhi-valkey-data-volume
persistentVolumeClaim:
claimName: "bodhi-valkey-storage{{ '-stg' if env == 'staging' else '' }}"
---
# bodhi-valkey Service
apiVersion: v1
kind: Service
metadata:
name: bodhi-valkey
labels:
app: bodhi-valkey
spec:
selector:
app: bodhi-valkey
ports:
- port: 6379
targetPort: 6379
protocol: TCP
type: ClusterIP
{% endif %}

View file

@ -0,0 +1,33 @@
{% if env == "staging" %}
FROM fedora:43
{% else %}
FROM fedora:43
{% endif %}
LABEL \
name="bodhi-valkey" \
vendor="Fedora Infrastructure" \
license="MIT"
{% if env == "staging" %}
RUN curl -o /etc/yum.repos.d/infra-tags.repo https://infrastructure.fedoraproject.org/infra/ansible/files/common/fedora-infra-tags.repo
RUN curl -o /etc/yum.repos.d/infra-tags-stg.repo https://infrastructure.fedoraproject.org/infra/ansible/files/common/fedora-infra-tags-stg.repo
{% else %}
RUN curl -o /etc/yum.repos.d/infra-tags.repo https://infrastructure.fedoraproject.org/infra/ansible/files/common/fedora-infra-tags.repo
{% endif %}
RUN dnf -y update && dnf install -y valkey && dnf clean all
RUN chmod 0770 /etc/valkey
RUN mkdir /run/valkey && chown valkey:valkey /run/valkey
RUN mkdir -m 0770 /data && chown valkey:0 /data
VOLUME /data
WORKDIR /data
COPY valkey-docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/valkey-docker-entrypoint.sh"]
USER valkey
EXPOSE 6379
CMD ["valkey-server"]

View file

@ -0,0 +1,19 @@
#!/bin/sh
cat /etc/valkey/valkey.conf | \
sed \
-e 's@^dir .*@dir /data@' \
-e 's@^logfile .*@logfile ""@' \
-e 's@^bind @# bind @' \
> /etc/valkey/valkey-docker.conf
if [ "${BODHI_VALKEY_PASSWORD+set}" = "set" ] ; then
echo "requirepass ${BODHI_VALKEY_PASSWORD}" >> /etc/valkey/valkey-docker.conf
fi
if [ "$1" = "valkey-server" ] ; then
shift
set -- valkey-server /etc/valkey/valkey-docker.conf "$@"
fi
exec "$@"