Skip to content

Commit 005eb77

Browse files
committed
setup celery beat
1 parent f31cb27 commit 005eb77

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: vela-controller-beat
5+
labels:
6+
app.kubernetes.io/name: vela-controller-beat
7+
app.kubernetes.io/instance: {{ .Release.Name }}
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app.kubernetes.io/name: vela-controller-beat
13+
template:
14+
metadata:
15+
labels:
16+
app.kubernetes.io/name: vela-controller-beat
17+
app.kubernetes.io/instance: {{ .Release.Name }}
18+
spec:
19+
serviceAccountName: vela-controller
20+
initContainers:
21+
{{ include "vela.waitForPostgresInitContainer" (dict) | nindent 8 }}
22+
containers:
23+
- name: vela-controller-beat
24+
image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}"
25+
imagePullPolicy: Always
26+
command: ["celery", "-A", "simplyblock.vela.worker", "beat", "--loglevel=info"]
27+
envFrom:
28+
- configMapRef:
29+
name: vela-controller-config
30+
env:
31+
- name: VELA_GRAFANA_SECURITY_ADMIN_USER
32+
valueFrom:
33+
secretKeyRef:
34+
name: vela-grafana-secret
35+
key: VELA_GRAFANA_SECURITY_ADMIN_USER
36+
- name: VELA_GRAFANA_SECURITY_ADMIN_PASSWORD
37+
valueFrom:
38+
secretKeyRef:
39+
name: vela-grafana-secret
40+
key: VELA_GRAFANA_SECURITY_ADMIN_PASSWORD
41+
- name: DB_USER
42+
valueFrom:
43+
secretKeyRef:
44+
name: database
45+
key: superuser-username
46+
- name: DB_PASSWORD
47+
valueFrom:
48+
secretKeyRef:
49+
name: database
50+
key: superuser-password
51+
- name: DB_HOST
52+
value: database
53+
- name: VELA_BROKER_URL
54+
value: 'sqla+postgresql+psycopg://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):5432/postgres'
55+
- name: VELA_RESULT_BACKEND
56+
value: 'db+postgresql+psycopg://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):5432/postgres'
57+
- name: VELA_DEPLOYMENT_PASSWORD_SECRET
58+
valueFrom:
59+
secretKeyRef:
60+
name: vela-controller-secret
61+
key: deployment-password-secret
62+
- name: VELA_POSTGRES_URL
63+
value: 'postgresql+asyncpg://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):5432/postgres'
64+
{{- with .Values.containerSecurityContext }}
65+
securityContext:
66+
{{- toYaml . | nindent 12 }}
67+
{{- end }}
68+
{{- with .Values.podSecurityContext }}
69+
securityContext:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}

containers/compose-dev.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ services:
4747
restart: unless-stopped
4848

4949

50+
controller-beat:
51+
build:
52+
context: ..
53+
dockerfile: containers/Containerfile
54+
volumes:
55+
- ~/.kube/config:/home/vela/.kube/config:ro
56+
- ..:/app
57+
command: 'bash -c "python -m venv /tmp/venv && source /tmp/venv/bin/activate && pip install -e . && celery -A simplyblock.vela.worker beat --loglevel=info"'
58+
environment:
59+
VELA_BROKER_URL: 'sqla+postgresql+psycopg://postgres:vela@database:5432/vela'
60+
VELA_RESULT_BACKEND: 'db+postgresql+psycopg://postgres:vela@database:5432/vela'
61+
VELA_POSTGRES_URL: 'postgresql+asyncpg://postgres:vela@database:5432/vela'
62+
VELA_JWT_SECRET: 'secret'
63+
VELA_ENABLE_DB_EXTERNAL_IPV6_LOADBALANCER: 'false'
64+
depends_on:
65+
database:
66+
condition: service_healthy
67+
restart: unless-stopped
68+
69+
5070
database:
5171
image: docker.io/postgres:17
5272
environment:

containers/compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,44 @@ services:
9393
restart: unless-stopped
9494

9595

96+
controller-beat:
97+
build:
98+
context: ..
99+
dockerfile: containers/Containerfile
100+
volumes:
101+
- ~/.kube/config:/home/vela/.kube/config:ro
102+
- ..:/app
103+
- beat_schedule:/tmp/beat
104+
command: 'bash -c "python -m venv /tmp/venv && source /tmp/venv/bin/activate && pip install -e . && celery -A simplyblock.vela.worker beat --loglevel=info --schedule=/tmp/beat/celerybeat-schedule"'
105+
environment:
106+
VELA_BROKER_URL: 'sqla+postgresql+psycopg://postgres:vela@database:5432/vela'
107+
VELA_RESULT_BACKEND: 'db+postgresql+psycopg://postgres:vela@database:5432/vela'
108+
VELA_ROOT_PATH: '/vela'
109+
VELA_JWT_SECRET: 'http://auth:8080/auth/realms/vela/protocol/openid-connect/certs'
110+
VELA_POSTGRES_URL: 'postgresql+asyncpg://postgres:vela@database:5432/vela'
111+
VELA_CORS_ORIGINS: '["http://localhost:3000"]'
112+
VELA_PGMETA_CRYPTO_KEY: 'secret'
113+
VELA_KEYCLOAK_URL: 'http://auth:8080/auth/'
114+
VELA_KEYCLOAK_ADMIN_NAME: 'admin'
115+
VELA_KEYCLOAK_ADMIN_SECRET: 'admin'
116+
VELA_CLOUDFLARE__API_TOKEN: 'your_cloudflare_api_token'
117+
VELA_CLOUDFLARE__ZONE_ID: 'your_cloudflare_zone_id'
118+
VELA_CLOUDFLARE__BRANCH_REF: 'branch-ref.staging.vela.run'
119+
VELA_CLOUDFLARE__BRANCH_DB_REF: 'branch-db-ref.staging.vela.run'
120+
VELA_CLOUDFLARE__DOMAIN_SUFFIX: 'example.com'
121+
VELA_DEPLOYMENT_NAMESPACE_PREFIX: 'vela'
122+
VELA_GRAFANA_URL: 'http://grafana:3000'
123+
VELA_ENABLE_DB_EXTERNAL_IPV6_LOADBALANCER: 'false'
124+
VELA_GRAFANA_SECURITY_ADMIN_USER: "admin"
125+
VELA_GRAFANA_SECURITY_ADMIN_PASSWORD: "password"
126+
VELA_SIMPLYBLOCK_CSI_NAMESPACE: 'simplyblock-csi'
127+
VELA_DEPLOYMENT_PASSWORD_SECRET: 'secret'
128+
depends_on:
129+
database:
130+
condition: service_healthy
131+
restart: unless-stopped
132+
133+
96134
auth:
97135
image: quay.io/keycloak/keycloak:26.4
98136
environment:
@@ -168,3 +206,4 @@ services:
168206
volumes:
169207
caddy_data:
170208
caddy_config:
209+
beat_schedule:

src/worker/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Settings(BaseSettings):
1919
# Chord callback always fires even when individual sub-tasks fail.
2020
app.conf.task_chord_propagates = False
2121

22+
app.conf.beat_schedule_filename = "/tmp/celerybeat-schedule"
23+
2224
# Register tasks — must be imported after `app` is defined.
2325
from ..api.organization.project.branch import resize_tasks as _api_resize_tasks # noqa: E402, F401
2426
from ..deployment import resize as _deployment_resize # noqa: E402, F401

0 commit comments

Comments
 (0)