Skip to content

Commit 853161b

Browse files
authored
Prepare chart for migration to OCI (#337)
* Prepare chart for migration to OCI Signed-off-by: Sergio Castaño Arteaga <[email protected]> * Do not use feature added in PG 17 Signed-off-by: Sergio Castaño Arteaga <[email protected]> --------- Signed-off-by: Sergio Castaño Arteaga <[email protected]>
1 parent 07df775 commit 853161b

File tree

9 files changed

+94
-24
lines changed

9 files changed

+94
-24
lines changed

charts/gitjobs/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: gitjobs
33
description: GitJobs is an open source job board platform
44
type: application
5-
version: 0.1.1-0
5+
version: 0.1.1-1
66
appVersion: 0.1.0
77
kubeVersion: ">= 1.19.0-0"
88
keywords:
@@ -16,6 +16,6 @@ maintainers:
1616
1717
dependencies:
1818
- name: postgresql
19-
version: 16.3.2
19+
version: 18.0.15
2020
repository: https://charts.bitnami.com/bitnami
2121
condition: postgresql.enabled

charts/gitjobs/templates/_helpers.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ longest resource name ("db-migrator-install" = 19 chars).
7878
Provide an init container to verify the database is accessible
7979
*/}}
8080
{{- define "chart.checkDbIsReadyInitContainer" -}}
81+
{{- $securityContext := default (dict) .Values.checkDbIsReadyInitContainer.securityContext }}
8182
name: check-db-ready
8283
{{ if .Values.postgresql.image.registry -}}
8384
image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
@@ -92,6 +93,11 @@ env:
9293
value: "{{ .Values.db.port }}"
9394
- name: PGUSER
9495
value: "{{ .Values.db.user }}"
96+
{{- if $securityContext }}
97+
securityContext:{{- toYaml $securityContext | nindent 2 }}
98+
{{- else }}
99+
securityContext: {}
100+
{{- end }}
95101
command: ['sh', '-c', 'until pg_isready; do echo waiting for database; sleep 2; done;']
96102
{{- end -}}
97103

charts/gitjobs/templates/db_migrator_job.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ metadata:
1313
spec:
1414
template:
1515
spec:
16+
{{- with .Values.dbmigrator.job.podSecurityContext }}
17+
securityContext:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
1620
{{- with .Values.imagePullSecrets }}
1721
imagePullSecrets:
1822
{{- toYaml . | nindent 8 }}
@@ -24,6 +28,10 @@ spec:
2428
- name: dbmigrator
2529
image: {{ .Values.dbmigrator.job.image.repository }}:{{ .Values.imageTag | default (printf "v%s" .Chart.AppVersion) }}
2630
imagePullPolicy: {{ .Values.pullPolicy }}
31+
{{- with .Values.dbmigrator.job.containerSecurityContext }}
32+
securityContext:
33+
{{- toYaml . | nindent 12 }}
34+
{{- end }}
2735
env:
2836
- name: TERN_CONF
2937
value: {{ .Values.configDir }}/tern.conf

charts/gitjobs/templates/server_deployment.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ spec:
1717
app.kubernetes.io/component: server
1818
{{- include "chart.selectorLabels" . | nindent 8 }}
1919
spec:
20+
{{- with .Values.server.deploy.podSecurityContext }}
21+
securityContext:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
2024
{{- with .Values.imagePullSecrets }}
2125
imagePullSecrets:
2226
{{- toYaml . | nindent 8 }}
@@ -32,12 +36,20 @@ spec:
3236
{{ $kubectlImageVersion := ternary "1.33" $kubeVersion (semverCompare ">=1.34.0-0" (printf "%s.0" $kubeVersion)) }}
3337
image: "docker.io/bitnamilegacy/kubectl:{{ $kubectlImageVersion }}"
3438
imagePullPolicy: IfNotPresent
39+
{{- with .Values.checkDbIsReadyInitContainer.securityContext }}
40+
securityContext:
41+
{{- toYaml . | nindent 12 }}
42+
{{- end }}
3543
command: ['kubectl', 'wait', '--namespace={{ .Release.Namespace }}', '--for=condition=complete', 'job/{{ include "chart.resourceNamePrefix" . }}dbmigrator-install', '--timeout=60s']
3644
{{- end }}
3745
containers:
3846
- name: server
3947
image: {{ .Values.server.deploy.image.repository }}:{{ .Values.imageTag | default (printf "v%s" .Chart.AppVersion) }}
4048
imagePullPolicy: {{ .Values.pullPolicy }}
49+
{{- with .Values.server.deploy.containerSecurityContext }}
50+
securityContext:
51+
{{- toYaml . | nindent 12 }}
52+
{{- end }}
4153
volumeMounts:
4254
- name: server-config
4355
mountPath: {{ .Values.configDir | quote }}
@@ -46,6 +58,10 @@ spec:
4658
- name: http
4759
containerPort: 9000
4860
protocol: TCP
61+
{{- with .Values.server.deploy.readinessProbe }}
62+
readinessProbe:
63+
{{- toYaml . | nindent 12 }}
64+
{{- end }}
4965
resources:
5066
{{- toYaml .Values.server.deploy.resources | nindent 12 }}
5167
command: ['gitjobs-server', '-c', '{{ .Values.configDir }}/server.yml']

charts/gitjobs/templates/server_ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
service:
1616
name: {{ include "chart.resourceNamePrefix" . }}server
1717
port:
18-
number: {{ .Values.server.service.port }}
18+
number: {{ .Values.server.ingress.backendServicePort }}
1919
{{- with .Values.server.ingress.rules }}
2020
rules:
2121
{{- toYaml . | nindent 4 }}

charts/gitjobs/templates/server_service.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ metadata:
55
labels:
66
app.kubernetes.io/component: server
77
{{- include "chart.labels" . | nindent 4 }}
8+
{{- with .Values.server.service.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
812
spec:
9-
type: {{ .Values.server.service.type }}
13+
{{- $serviceType := default "ClusterIP" .Values.server.service.type }}
14+
{{- if eq $serviceType "LoadBalancer" }}
15+
allocateLoadBalancerNodePorts: {{ .Values.server.service.allocateLoadBalancerNodePorts }}
16+
{{- end }}
17+
type: {{ $serviceType }}
1018
ports:
11-
- port: {{ .Values.server.service.port }}
12-
targetPort: http
13-
protocol: TCP
14-
name: http
19+
{{- toYaml .Values.server.service.ports | nindent 4 }}
1520
selector:
1621
app.kubernetes.io/component: server
1722
{{- include "chart.selectorLabels" . | nindent 4 }}

charts/gitjobs/templates/syncer_cronjob.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ spec:
1515
spec:
1616
template:
1717
spec:
18+
{{- with .Values.syncer.cronjob.podSecurityContext }}
19+
securityContext:
20+
{{- toYaml . | nindent 12 }}
21+
{{- end }}
1822
{{- with .Values.imagePullSecrets }}
1923
imagePullSecrets:
2024
{{- toYaml . | nindent 12 }}
@@ -26,6 +30,10 @@ spec:
2630
- name: syncer
2731
image: {{ .Values.syncer.cronjob.image.repository }}:{{ .Values.imageTag | default (printf "v%s" .Chart.AppVersion) }}
2832
imagePullPolicy: {{ .Values.pullPolicy }}
33+
{{- with .Values.syncer.cronjob.containerSecurityContext }}
34+
securityContext:
35+
{{- toYaml . | nindent 16 }}
36+
{{- end }}
2937
resources:
3038
{{- toYaml .Values.syncer.cronjob.resources | nindent 16 }}
3139
volumeMounts:

charts/gitjobs/values.yaml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ fullnameOverride: ""
1818
# Directory path where the configuration files should be mounted
1919
configDir: "/home/gitjobs/.config/gitjobs"
2020

21+
# Check database readiness init container configuration
22+
checkDbIsReadyInitContainer:
23+
securityContext: {}
24+
2125
# Database configuration
2226
db:
2327
host: ""
2428
port: 5432
2529
dbname: gitjobs
26-
user: postgres
27-
password: postgres
30+
user: gitjobs
31+
password: gitjobs
2832

2933
# Email configuration
3034
email:
@@ -51,9 +55,11 @@ log:
5155
# Database migrator configuration
5256
dbmigrator:
5357
job:
58+
containerSecurityContext: {}
5459
image:
5560
# Database migrator image repository (without the tag)
5661
repository: gitjobs/dbmigrator
62+
podSecurityContext: {}
5763

5864
# Server configuration
5965
server:
@@ -138,41 +144,65 @@ server:
138144
enabled: true
139145
annotations:
140146
kubernetes.io/ingress.class: nginx
147+
backendServicePort: 80
141148
rules: []
142149
tls: []
143150

144151
# Service configuration
145152
service:
153+
allocateLoadBalancerNodePorts: true
154+
annotations: {}
155+
ports:
156+
- name: http
157+
port: 80
158+
protocol: TCP
159+
targetPort: 9000
146160
type: NodePort
147-
port: 80
148161

149162
# Deployment configuration
150163
deploy:
151-
replicaCount: 1
164+
containerSecurityContext: {}
152165
image:
153-
# Database migrator image repository (without the tag)
166+
# Server image repository (without the tag)
154167
repository: gitjobs/server
168+
podSecurityContext: {}
169+
readinessProbe:
170+
httpGet:
171+
path: /health-check
172+
port: 9000
173+
replicaCount: 1
155174
resources: {}
156175

157176
# Syncer configuration
158177
syncer:
159178
cronjob:
179+
containerSecurityContext: {}
160180
image:
161181
# Syncer image repository (without the tag)
162182
repository: gitjobs/syncer
183+
podSecurityContext: {}
163184
resources: {}
164185

165186
# PostgreSQL configuration
166187
postgresql:
167188
enabled: true
168189
auth:
169-
username: postgres
170-
password: postgres
190+
username: gitjobs
191+
password: gitjobs
171192
database: gitjobs
193+
global:
194+
security:
195+
allowInsecureImages: true
172196
image:
173-
repository: bitnamilegacy/postgresql
174-
tag: 17.2.0-debian-12-r3
175-
postgresqlDataDir: /data/pgdata
197+
registry: docker.io
198+
repository: artifacthub/postgres
199+
tag: latest
200+
persistence:
201+
mountPath: /data
176202
primary:
177-
persistence:
178-
mountPath: /data
203+
extraVolumes:
204+
- name: run
205+
emptyDir: {}
206+
extraVolumeMounts:
207+
- name: run
208+
mountPath: /var/run/postgresql

database/migrations/functions/jobboard/search_jobs.sql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ begin
166166
where project_id = any(
167167
select project_id
168168
from project p
169-
join json_table((p_filters->'projects'), '$[*]' columns (
170-
foundation text path '$.foundation',
171-
name text path '$.name'
172-
)) fp
169+
join jsonb_to_recordset(p_filters->'projects') as fp(foundation text, name text)
173170
on p.foundation = fp.foundation and p.name = fp.name
174171
)
175172
)

0 commit comments

Comments
 (0)