Skip to content

Commit 29bd7f1

Browse files
K8s deployment helm chart
1 parent 0cf8ac1 commit 29bd7f1

File tree

12 files changed

+249
-34
lines changed

12 files changed

+249
-34
lines changed

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,3 @@ services:
1111
environment:
1212
DATABASE_URL: mysql://root:rootpassword@ispyb/ispyb_build
1313
LOG_LEVEL: DEBUG
14-
15-
opa:
16-
image: docker.io/openpolicyagent/opa:0.59.0
17-
restart: unless-stopped
18-
command: >
19-
run
20-
--server
21-
--config-file /config.yml
22-
--watch
23-
/policy
24-
volumes:
25-
- ./opa.yml:/config.yml:cached,z
26-
- ../policy/:/policy:cached,z
27-
env_file: opa.env
28-
29-
ispyb:
30-
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
31-
restart: unless-stopped
32-
environment:
33-
MARIADB_ROOT_PASSWORD: rootpassword

.devcontainer/opa.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

charts/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Chart Bundles
2+
*.tgz

charts/data-processing/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: data-processing
3+
repository: ""
4+
version: 0.1.0
5+
digest: sha256:bac0b96b8e2519051015ea74ef616cbc76de21a1803714ef9fa25ab896a10f93
6+
generated: "2024-03-28T11:43:46.834271769Z"

charts/data-processing/Chart.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v2
2+
name: data-processing
3+
description: A deployment providing processed data collected during beamline session as part of the graph federation
4+
type: application
5+
6+
version: 0.1.0
7+
8+
dependencies:
9+
- name: data-processing
10+
version: 0.1.0
11+
condition: data-processing.enabled
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v2
2+
name: data-processing
3+
description: A service providing processed data collected during beamline sessions as part of the graph federation
4+
type: application
5+
6+
version: 0.1.0
7+
8+
appVersion: 0.1.0-rc1
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "datasets.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "datasets.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "datasets.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "datasets.labels" -}}
37+
helm.sh/chart: {{ include "datasets.chart" . }}
38+
{{ include "datasets.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "datasets.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "datasets.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "datasets.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "datasets.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Create the database URL string
66+
*/}}
67+
{{- define "datasets.databaseURL" -}}
68+
{{- $host_parts := urlParse .Values.database.host }}
69+
{{- $raw_user_info := printf "%s:$DATABASE_PASSWORD" .Values.database.user }}
70+
{{- $url_parts := set $host_parts "userinfo" $raw_user_info }}
71+
{{- $raw_database_url := urlJoin $url_parts }}
72+
{{- replace "$DATABASE_PASSWORD" "$(DATABASE_PASSWORD)" $raw_database_url }}
73+
{{- end }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "data-processing.fullname" . }}
5+
labels:
6+
{{- include "data-processing.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "data-processing.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "data-processing.selectorLabels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
serviceAccountName: {{ include "data-processing.serviceAccountName" . }}
26+
securityContext:
27+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
securityContext:
31+
{{- toYaml .Values.securityContext | nindent 12 }}
32+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
33+
imagePullPolicy: {{ .Values.image.pullPolicy }}
34+
args:
35+
- serve
36+
env:
37+
- name: DATABASE_PASSWORD
38+
valueFrom:
39+
secretKeyRef:
40+
name: {{ .Values.database.password.secretName }}
41+
key: {{ .Values.database.password.secretKey }}
42+
- name: DATABASE_URL
43+
value: {{ include "data-processing.databaseURL" . }}
44+
- name: LOG_LEVEL
45+
value: {{ .Values.logLevel }}
46+
- name: OTEL_COLLECTOR_URL
47+
value: {{ tpl .Values.otelCollectorUrl . }}
48+
ports:
49+
- name: http
50+
containerPort: {{ .Values.service.port }}
51+
protocol: TCP
52+
resources:
53+
{{- toYaml .Values.resources | nindent 12 }}
54+
{{- with .Values.nodeSelector }}
55+
nodeSelector:
56+
{{- toYaml . | nindent 8 }}
57+
{{- end }}
58+
{{- with .Values.affinity }}
59+
affinity:
60+
{{- toYaml . | nindent 8 }}
61+
{{- end }}
62+
{{- with .Values.tolerations }}
63+
tolerations:
64+
{{- toYaml . | nindent 8 }}
65+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "data-processing.fullname" . }}
5+
labels:
6+
{{- include "data-processing.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "data-processing.selectorLabels" . | nindent 4 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "dataprocessing.serviceAccountName" . }}
6+
labels:
7+
{{- include "dataprocessing.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}

0 commit comments

Comments
 (0)