Skip to content

Commit e258810

Browse files
authored
Prepare chart for migration to OCI (#372)
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
1 parent a946971 commit e258810

File tree

9 files changed

+91
-22
lines changed

9 files changed

+91
-22
lines changed

.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/clowarden/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: clowarden
33
description: CLOWarden is a tool that manages access to resources across multiple services
44
type: application
5-
version: 0.2.2
5+
version: 0.2.3-0
66
appVersion: 0.2.2
77
kubeVersion: ">= 1.19.0-0"
88
home: https://clowarden.io
@@ -16,8 +16,8 @@ maintainers:
1616
1717
dependencies:
1818
- name: postgresql
19-
version: 8.2.1
20-
repository: https://charts.helm.sh/stable
19+
version: 18.0.15
20+
repository: https://charts.bitnami.com/bitnami
2121
condition: postgresql.enabled
2222
annotations:
2323
artifacthub.io/category: skip-prediction

charts/clowarden/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/clowarden/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/clowarden/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/clowarden/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: ['clowarden-server', '-c', '{{ .Values.configDir }}/clowarden.yml']

charts/clowarden/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/clowarden/templates/server_service.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ 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+
{{- if eq (default "ClusterIP" .Values.server.service.type) "LoadBalancer" }}
14+
allocateLoadBalancerNodePorts: {{ .Values.server.service.allocateLoadBalancerNodePorts }}
15+
{{- end }}
16+
type: {{ default "ClusterIP" .Values.server.service.type }}
1017
ports:
11-
- port: {{ .Values.server.service.port }}
12-
targetPort: http
13-
protocol: TCP
14-
name: http
18+
{{- toYaml .Values.server.service.ports | nindent 4 }}
1519
selector:
1620
app.kubernetes.io/component: server
1721
{{- include "chart.selectorLabels" . | nindent 4 }}

charts/clowarden/values.yaml

Lines changed: 41 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/clowarden/.config/clowarden"
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: clowarden
26-
user: postgres
27-
password: postgres
30+
user: clowarden
31+
password: clowarden
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/clowarden/dbmigrator
45+
podSecurityContext: {}
4046

4147
# CLOWarden server configuration
4248
server:
@@ -66,24 +72,37 @@ server:
6672
# GitHub application webhook secret fallback (handy for webhook secret rotation)
6773
webhookSecretFallback: null
6874

75+
# Service configuration
76+
service:
77+
allocateLoadBalancerNodePorts: true
78+
annotations: {}
79+
ports:
80+
- name: http
81+
port: 80
82+
protocol: TCP
83+
targetPort: 9000
84+
type: NodePort
85+
6986
# Ingress configuration
7087
ingress:
7188
enabled: true
7289
annotations:
7390
kubernetes.io/ingress.class: nginx
91+
backendServicePort: 80
7492
rules: []
7593
tls: []
7694

77-
# Service configuration
78-
service:
79-
type: NodePort
80-
port: 80
81-
8295
# Deployment configuration
8396
deploy:
84-
replicaCount: 1 # Do not increase
97+
containerSecurityContext: {}
8598
image:
8699
repository: ghcr.io/cncf/clowarden/server
100+
podSecurityContext: {}
101+
readinessProbe:
102+
httpGet:
103+
path: /health-check
104+
port: 9000
105+
replicaCount: 1 # Do not increase
87106
resources: {}
88107

89108
# Services CLOWarden will manage
@@ -112,12 +131,22 @@ organizations:
112131
# PostgreSQL configuration
113132
postgresql:
114133
enabled: true
134+
auth:
135+
database: clowarden
136+
password: clowarden
137+
username: clowarden
138+
global:
139+
security:
140+
allowInsecureImages: true
115141
image:
116142
repository: artifacthub/postgres
117143
tag: latest
118144
persistence:
119145
mountPath: /data
120-
postgresqlUsername: postgres
121-
postgresqlPassword: postgres
122-
postgresqlDatabase: clowarden
123-
postgresqlDataDir: /data/pgdata
146+
primary:
147+
extraVolumes:
148+
- name: run
149+
emptyDir: {}
150+
extraVolumeMounts:
151+
- name: run
152+
mountPath: /var/run/postgresql

0 commit comments

Comments
 (0)