Skip to content

Commit 27cf27b

Browse files
committed
feat(ops): adds scheduler helm chart
1 parent 42b054a commit 27cf27b

File tree

9 files changed

+353
-0
lines changed

9 files changed

+353
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: scheduler
3+
description: Deploys the scheduler workers and cronjobs
4+
5+
type: application
6+
version: 0.7.1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To use this make sure you have the following in your helm config for vscode:
2+
# "helm-intellisense.customValueFileNames": [
3+
# "prod-values.yaml",
4+
# "dev-values.yaml",
5+
# "values.yaml"
6+
# ]
7+
8+
app:
9+
name: "oso"
10+
command: ["python"]
11+
args: []
12+
queues:
13+
- name: "run_requests"
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
5+
# Disable the pgisready check due to our use of cloudsql proxy injected into the
6+
pod.
7+
{{- define "app.logging.config" }}
8+
# Default log configuration for a python service. This can be
9+
# used by uvicorn Thanks to:
10+
# https://gist.github.com/liviaerxin/d320e33cbcddcc5df76dd92948e5be3b for a
11+
# starting point.
12+
version: 1
13+
disable_existing_loggers: False
14+
formatters:
15+
default:
16+
# "()": uvicorn.logging.DefaultFormatter
17+
format: '{{ .Values.app.logging.format }}'
18+
access:
19+
# "()": uvicorn.logging.AccessFormatter
20+
format: '{{ .Values.app.logging.format }}'
21+
handlers:
22+
default:
23+
formatter: default
24+
class: logging.StreamHandler
25+
stream: ext://sys.stderr
26+
access:
27+
formatter: access
28+
class: logging.StreamHandler
29+
stream: ext://sys.stdout
30+
loggers:
31+
uvicorn.error:
32+
level: {{ .Values.app.logging.uvicorn.level }}
33+
handlers:
34+
- default
35+
propagate: no
36+
uvicorn.access:
37+
level: {{ .Values.app.logging.uvicorn.level }}
38+
handlers:
39+
- access
40+
propagate: no
41+
{{ .Values.app.logging.appRoot.loggerName }}:
42+
level: {{ .Values.app.logging.appRoot.level }}
43+
handlers:
44+
- default
45+
propagate: no
46+
root:
47+
level: {{ .Values.app.logging.root.level }}
48+
handlers:
49+
- default
50+
propagate: no
51+
{{- end }}
52+
53+
{{/*
54+
This is copied due to some kind of error with helm and flux when overriding
55+
portions of this
56+
*/}}
57+
58+
{{/*
59+
Create a default fully qualified app name.
60+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
61+
If release name contains chart name it will be used as a full name.
62+
*/}}
63+
{{- define "app.fullname" -}}
64+
{{- if .Values.global.fullnameOverride -}}
65+
{{- .Values.global.fullnameOverride | trunc 63 | trimSuffix "-" -}}
66+
{{- else -}}
67+
{{- $name := "app" -}}
68+
{{- if contains $name .Release.Name -}}
69+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
70+
{{- else -}}
71+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
72+
{{- end -}}
73+
{{- end -}}
74+
{{- end -}}
75+
76+
{{- define "app.labels" -}}
77+
app.kubernetes.io/name: {{ include "app.fullname" . }}
78+
{{- end -}}
79+
80+
{{- define "app.selectorLabels" -}}
81+
{{ include "app.labels" . }}
82+
component: {{ required "app component name is required" .Values.app.name }}
83+
{{- end -}}
84+
85+
{{- define "app.serviceAccountName" -}}
86+
{{- if .Values.global.serviceAccountNameOverride -}}
87+
{{ .Values.global.serviceAccountNameOverride }}
88+
{{- else -}}
89+
{{ include "app.fullname" . }}
90+
{{- end -}}
91+
{{- end -}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if .Values.app.roles.enableClusterRoleBinding -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ include "app.fullname" . }}-cluster-role-binding
6+
subjects:
7+
- kind: ServiceAccount
8+
name: {{ include "app.serviceAccountName" . }}
9+
namespace: {{ .Release.Namespace }}
10+
roleRef:
11+
kind: ClusterRole
12+
name: {{ include "app.fullname" . }}-cluster-role
13+
apiGroup: rbac.authorization.k8s.io
14+
{{- end -}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{ if .Values.app.roles.clusterRoles }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "app.fullname" . }}-cluster-role
6+
rules:
7+
{{ with .Values.app.roles.clusterRoles }}
8+
{{- toYaml . | nindent 2 }}
9+
{{ end }}
10+
{{ end }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{{ range .Values.app.crons }}
2+
{{ $resources := .resources | default $.Values.app.resources }}
3+
{{ $tolerations := .tolerations | default $.Values.app.tolerations }}
4+
{{ $nodeSelector := .nodeSelector | default $.Values.app.nodeSelector }}
5+
{{ $affinity := .affinity | default $.Values.app.affinity }}
6+
{{ $name := required "Cron name is required" .name }}
7+
{{ $volumeMounts := .volumeMounts | default $.Values.app.volumeMounts }}
8+
{{ $volumes := .volumes | default $.Values.app.volumes }}
9+
{{ $nodeSelector := .nodeSelector | default $.Values.app.nodeSelector }}
10+
{{ $image := .image | default $.Values.app.image }}
11+
{{ $extraEnvVars := .envVars | default dict }}
12+
{{ $args := required "Cron args are required" .args }}
13+
---
14+
apiVersion: batch/v1
15+
kind: CronJob
16+
metadata:
17+
name: {{ include "app.fullname" $ }}-{{ $name }}
18+
labels:
19+
{{- include "app.labels" $ | nindent 4 }}
20+
spec:
21+
# Run the main cron every hour
22+
schedule: "0 * * * *"
23+
jobTemplate:
24+
spec:
25+
template:
26+
metadata:
27+
labels:
28+
cron: {{ $name }}
29+
{{- include "app.selectorLabels" $ | nindent 12 }}
30+
spec:
31+
restartPolicy: OnFailure
32+
{{- if .serviceAccountName }}
33+
serviceAccountName: {{ .serviceAccountName }}
34+
{{- else }}
35+
serviceAccountName: {{ include "app.serviceAccountName" $ }}
36+
{{- end }}
37+
{{- with $affinity }}
38+
affinity:
39+
{{ toYaml . | nindent 12 }}
40+
{{- end }}
41+
{{- with $nodeSelector }}
42+
nodeSelector:
43+
{{ toYaml . | nindent 12 }}
44+
{{- end }}
45+
{{- with $tolerations }}
46+
tolerations:
47+
{{ toYaml . | nindent 12 }}
48+
{{- end }}
49+
containers:
50+
- name: {{ $.Values.app.name }}
51+
image: {{ $image.repo }}:{{ $image.tag }}
52+
{{- if .command -}}
53+
command: {{ toYaml .command | nindent 12 }}
54+
{{- else -}}
55+
command: ["uv"]
56+
{{- end }}
57+
args: {{ toYaml $args | nindent 12 }}
58+
imagePullPolicy: Always
59+
{{- with $resources }}
60+
resources:
61+
{{ toYaml . | nindent 14 }}
62+
{{- end }}
63+
{{- with $volumeMounts }}
64+
volumeMounts:
65+
{{- toYaml . | nindent 14 }}
66+
{{- end }}
67+
env:
68+
{{- range $key, $value := $.Values.app.envVars }}
69+
- name: {{ $key }}
70+
value: {{ $value | quote }}
71+
{{- end }}
72+
{{- range $.Values.app.rawEnvVars }}
73+
{{- toYaml . | nindent 14 }}
74+
{{- end }}
75+
{{- with $volumes }}
76+
volumes:
77+
{{- toYaml . | nindent 12 }}
78+
{{- end }}
79+
{{- end -}}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{{ range .Values.app.queues }}
2+
{{ $resources := .resources | default $.Values.app.resources }}
3+
{{ $tolerations := .tolerations | default $.Values.app.tolerations }}
4+
{{ $nodeSelector := .nodeSelector | default $.Values.app.nodeSelector }}
5+
{{ $affinity := .affinity | default $.Values.app.affinity }}
6+
{{ $name := required "Queue name is required" .name }}
7+
{{ $volumeMounts := .volumeMounts | default $.Values.app.volumeMounts }}
8+
{{ $volumes := .volumes | default $.Values.app.volumes }}
9+
{{ $nodeSelector := .nodeSelector | default $.Values.app.nodeSelector }}
10+
{{ $image := .image | default $.Values.app.image }}
11+
{{ $extraEnvVars := .envVars | default dict }}
12+
---
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: {{ include "app.fullname" . }}-{{ $name }}
17+
labels:
18+
{{- include "app.labels" . | nindent 4 }}
19+
spec:
20+
# for now this application is a single process + thread
21+
replicas: 1
22+
selector:
23+
matchLabels:
24+
component: {{ $.Values.app.name }}
25+
queue: {{ $name }}
26+
template:
27+
metadata:
28+
labels:
29+
queue: {{ $name }}
30+
{{- include "app.selectorLabels" . | nindent 8 }}
31+
spec:
32+
{{- if .serviceAccountName }}
33+
serviceAccountName: {{ .serviceAccountName }}
34+
{{- else }}
35+
serviceAccountName: {{ include "app.serviceAccountName" $ }}
36+
{{- end }}
37+
{{- with $affinity }}
38+
affinity:
39+
{{ toYaml . | nindent 8 }}
40+
{{- end }}
41+
{{- with $nodeSelector }}
42+
nodeSelector:
43+
{{ toYaml . | nindent 8 }}
44+
{{- end }}
45+
{{- with $tolerations }}
46+
tolerations:
47+
{{ toYaml . | nindent 8 }}
48+
{{- end }}
49+
containers:
50+
- name: {{ $.Values.app.name }}
51+
image: {{ $image.repo }}:{{ $image.tag }}
52+
{{- if .command -}}
53+
command: {{ toYaml .command | nindent 10 }}
54+
{{- else -}}
55+
command: ["uv"]
56+
{{- end }}
57+
{{- if .args -}}
58+
args: {{ toYaml .args | nindent 10 }}
59+
{{- else }}
60+
args:
61+
- run
62+
- --directory
63+
- warehouse/scheduler
64+
- scheduler
65+
- run
66+
- "{{ $name }}"
67+
{{- end }}
68+
imagePullPolicy: Always
69+
ports:
70+
- containerPort: 8000
71+
{{- with $resources }}
72+
resources:
73+
{{ toYaml . | nindent 10 }}
74+
{{- end }}
75+
{{- with $volumeMounts }}
76+
volumeMounts:
77+
{{- toYaml . | nindent 10 }}
78+
{{- end }}
79+
env:
80+
{{- range $key, $value := $.Values.app.envVars }}
81+
- name: {{ $key }}
82+
value: {{ $value | quote }}
83+
{{- end }}
84+
{{- range $key, $value := $extraEnvVars }}
85+
- name: {{ $key }}
86+
value: {{ $value | quote }}
87+
{{- end }}
88+
{{- range $.Values.app.rawEnvVars }}
89+
{{- toYaml . | nindent 12 }}
90+
{{- end }}
91+
{{- with $volumes }}
92+
volumes:
93+
{{- toYaml . | nindent 8 }}
94+
{{- end }}
95+
{{- end }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{- if .Values.app.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "app.serviceAccountName" . }}
6+
{{- end -}}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
global:
2+
fullnameOverride: ""
3+
serviceAccountNameOverride: ""
4+
app:
5+
queues: []
6+
crons: []
7+
# name: "oso" # This must be set
8+
# command: []
9+
# args: []
10+
# By default we enable json logs via the OSO_ENABLE_JSON_LOGS env var
11+
serviceAccount:
12+
create: true
13+
enableJsonLogs: true
14+
image:
15+
repo: ghcr.io/opensource-observer/oso
16+
tag: latest
17+
logging:
18+
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
19+
root:
20+
level: "ERROR"
21+
oso_mcp:
22+
level: "DEBUG"
23+
uvicorn:
24+
level: "INFO"
25+
affinity: {}
26+
nodeSelector: {}
27+
tolerations: []
28+
resources: {}
29+
envVars: {}
30+
# if you want to set env vars in a raw format but this makes it harder to
31+
# extend with flux
32+
rawEnvVars: []
33+
volumes: []
34+
volumeMounts: []
35+
livenessProbe: {}
36+
roles:
37+
clusterRoles: []
38+
enableClusterRoleBinding: false
39+

0 commit comments

Comments
 (0)