Skip to content

Commit b85722f

Browse files
authored
Prepare chart for migration to OCI (#672)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
1 parent b67b525 commit b85722f

9 files changed

Lines changed: 89 additions & 18 deletions

File tree

.ct.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
helm-extra-args: --timeout 180s
22
chart-repos:
3-
- stable=https://charts.helm.sh/stable
3+
- bitnami=https://charts.bitnami.com/bitnami
4+
validate-maintainers: false

charts/gitvote/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: gitvote
33
description: GitVote is a GitHub application that allows holding a vote on issues and pull requests
44
type: application
5-
version: 1.5.0
5+
version: 1.5.1-0
66
appVersion: 1.5.0
77
kubeVersion: ">= 1.19.0-0"
88
home: https://gitvote.dev
@@ -18,8 +18,8 @@ maintainers:
1818
email: cynthiasg@icloud.com
1919
dependencies:
2020
- name: postgresql
21-
version: 8.2.1
22-
repository: https://charts.helm.sh/stable
21+
version: 18.0.15
22+
repository: https://charts.bitnami.com/bitnami
2323
condition: postgresql.enabled
2424
annotations:
2525
artifacthub.io/category: skip-prediction

charts/gitvote/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ longest resource name ("dbmigrator-install" = 18 chars).
7979
Provide an init container to verify the database is accessible
8080
*/}}
8181
{{- define "chart.checkDbIsReadyInitContainer" -}}
82+
{{- $securityContext := default (dict) .Values.checkDbIsReadyInitContainer.securityContext }}
8283
name: check-db-ready
84+
{{ if .Values.postgresql.image.registry -}}
85+
image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
86+
{{- else }}
8387
image: {{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
88+
{{- end }}
8489
imagePullPolicy: {{ .Values.pullPolicy }}
8590
env:
8691
- name: PGHOST
@@ -89,5 +94,10 @@ env:
8994
value: "{{ .Values.db.port }}"
9095
- name: PGUSER
9196
value: "{{ .Values.db.user }}"
97+
{{- if $securityContext }}
98+
securityContext:{{- toYaml $securityContext | nindent 2 }}
99+
{{- else }}
100+
securityContext: {}
101+
{{- end }}
92102
command: ['sh', '-c', 'until pg_isready; do echo waiting for database; sleep 2; done;']
93103
{{- end -}}

charts/gitvote/templates/dbmigrator_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/gitvote/templates/dbmigrator_secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ stringData:
1111
database = {{ .Values.db.dbname }}
1212
user = {{ .Values.db.user }}
1313
password = {{ .Values.db.password }}
14+
sslmode = prefer

charts/gitvote/templates/gitvote_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: gitvote
1818
{{- include "chart.selectorLabels" . | nindent 8 }}
1919
spec:
20+
{{- with .Values.gitvote.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: gitvote
3947
image: {{ .Values.gitvote.deploy.image.repository }}:{{ .Values.imageTag | default (printf "v%s" .Chart.AppVersion) }}
4048
imagePullPolicy: {{ .Values.pullPolicy }}
49+
{{- with .Values.gitvote.deploy.containerSecurityContext }}
50+
securityContext:
51+
{{- toYaml . | nindent 12 }}
52+
{{- end }}
4153
volumeMounts:
4254
- name: gitvote-config
4355
mountPath: {{ .Values.configDir | quote }}
@@ -46,6 +58,10 @@ spec:
4658
- name: http
4759
containerPort: 9000
4860
protocol: TCP
61+
{{- with .Values.gitvote.deploy.readinessProbe }}
62+
readinessProbe:
63+
{{- toYaml . | nindent 12 }}
64+
{{- end }}
4965
resources:
5066
{{- toYaml .Values.gitvote.deploy.resources | nindent 12 }}
5167
command: ['gitvote', '-c', '{{ .Values.configDir }}/gitvote.yml']

charts/gitvote/templates/gitvote_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" . }}gitvote
1717
port:
18-
number: {{ .Values.gitvote.service.port }}
18+
number: {{ .Values.gitvote.ingress.backendServicePort }}
1919
{{- with .Values.gitvote.ingress.rules }}
2020
rules:
2121
{{- toYaml . | nindent 4 }}

charts/gitvote/templates/gitvote_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: gitvote
77
{{- include "chart.labels" . | nindent 4 }}
8+
{{- with .Values.gitvote.service.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
812
spec:
9-
type: {{ .Values.gitvote.service.type }}
13+
{{- $serviceType := default "ClusterIP" .Values.gitvote.service.type }}
14+
{{- if eq $serviceType "LoadBalancer" }}
15+
allocateLoadBalancerNodePorts: {{ .Values.gitvote.service.allocateLoadBalancerNodePorts }}
16+
{{- end }}
17+
type: {{ $serviceType }}
1018
ports:
11-
- port: {{ .Values.gitvote.service.port }}
12-
targetPort: http
13-
protocol: TCP
14-
name: http
19+
{{- toYaml .Values.gitvote.service.ports | nindent 4 }}
1520
selector:
1621
app.kubernetes.io/component: gitvote
1722
{{- include "chart.selectorLabels" . | nindent 4 }}

charts/gitvote/values.yaml

Lines changed: 38 additions & 8 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/gitvote/.config/gitvote"
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: gitvote
26-
user: postgres
27-
password: postgres
30+
password: gitvote
31+
user: gitvote
2832

2933
# Log configuration
3034
log:
@@ -34,9 +38,11 @@ log:
3438
# Database migrator configuration
3539
dbmigrator:
3640
job:
41+
containerSecurityContext: {}
3742
image:
3843
# Database migrator image repository (without the tag)
3944
repository: ghcr.io/cncf/gitvote/dbmigrator
45+
podSecurityContext: {}
4046

4147
# GitVote service configuration
4248
gitvote:
@@ -62,30 +68,54 @@ gitvote:
6268
enabled: true
6369
annotations:
6470
kubernetes.io/ingress.class: nginx
71+
backendServicePort: 80
6572
rules: []
6673
tls: []
6774

6875
# Service configuration
6976
service:
77+
allocateLoadBalancerNodePorts: true
78+
annotations: {}
79+
ports:
80+
- name: http
81+
port: 80
82+
protocol: TCP
83+
targetPort: 9000
7084
type: NodePort
71-
port: 80
7285

7386
# Deployment configuration
7487
deploy:
75-
replicaCount: 1
88+
containerSecurityContext: {}
7689
image:
7790
repository: ghcr.io/cncf/gitvote/server
91+
podSecurityContext: {}
92+
readinessProbe:
93+
httpGet:
94+
path: /
95+
port: 9000
96+
replicaCount: 1
7897
resources: {}
7998

8099
# PostgreSQL configuration
81100
postgresql:
82101
enabled: true
102+
auth:
103+
database: gitvote
104+
password: gitvote
105+
username: gitvote
106+
global:
107+
security:
108+
allowInsecureImages: true
83109
image:
110+
registry: docker.io
84111
repository: artifacthub/postgres
85112
tag: latest
86113
persistence:
87114
mountPath: /data
88-
postgresqlUsername: postgres
89-
postgresqlPassword: postgres
90-
postgresqlDatabase: gitvote
91-
postgresqlDataDir: /data/pgdata
115+
primary:
116+
extraVolumes:
117+
- name: run
118+
emptyDir: {}
119+
extraVolumeMounts:
120+
- name: run
121+
mountPath: /var/run/postgresql

0 commit comments

Comments
 (0)