Skip to content

Commit 2cc5638

Browse files
authored
Update to Helm and Tofu (#325)
1 parent 60600c6 commit 2cc5638

File tree

20 files changed

+238
-117
lines changed

20 files changed

+238
-117
lines changed

.github/workflows/pytest.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ jobs:
4343
python -m pip install --upgrade pip wheel setuptools uv
4444
uv pip install torch==2.9.0+cpu -f https://download.pytorch.org/whl/cpu/torch --system
4545
uv pip install -e ".[all-test]" --system
46+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
47+
48+
- name: Run yamllint on Code
49+
run: yamllint .
50+
51+
- name: Run Helm Lint (basic structure)
52+
run: helm lint helm/
53+
54+
- name: Run Helm Lint (with required values)
55+
run: helm lint helm/ --set global.api.apiKey=test-api-key
4656

4757
- name: Run Pylint on IaC Code
4858
run: pylint opentofu

.yamllint

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
extends: default
2+
3+
ignore: |
4+
.venv/
5+
docs/themes/
6+
.github/
7+
helm/templates/
8+
opentofu/modules/*/templates/
9+
src/client/spring_ai/templates/
10+
11+
rules:
12+
line-length:
13+
max: 120
14+
level: warning
15+
16+
indentation:
17+
spaces: 2
18+
indent-sequences: true
19+
20+
# Helm templates often use truthy values like yes/no, on/off
21+
truthy:
22+
allowed-values: ['true', 'false', 'yes', 'no', 'on', 'off']
23+
check-keys: false
24+
25+
# Allow both quoted and unquoted strings
26+
quoted-strings:
27+
quote-type: any
28+
required: false
29+
30+
# Don't require document start marker (---)
31+
document-start: disable
32+
33+
# More lenient on comments
34+
comments:
35+
min-spaces-from-content: 1
36+
37+
# Disable for commented-out examples in Helm values
38+
comments-indentation: disable
39+
40+
# Allow empty values (common in Helm templates)
41+
empty-values:
42+
forbid-in-block-mappings: false
43+
forbid-in-flow-mappings: false
44+
45+
# Brackets and braces (lenient for Helm)
46+
brackets:
47+
min-spaces-inside: 0
48+
max-spaces-inside: 1
49+
50+
braces:
51+
min-spaces-inside: 0
52+
max-spaces-inside: 1

helm/examples/values-kind-other.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server:
1919
# service_name: "MYSERVICE"
2020
privAuthN:
2121
secretName: "db-priv-authn"
22-
passwordKey: "password"
22+
passwordKey: "password"
2323
client:
2424
replicaCount: 1
2525
image:

helm/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ These helpers provide consistent database type checking across templates.
286286
Database Service Name Helper
287287
Returns the short database type prefix (sidb or adb) for service naming.
288288
*********************************************** */}}
289-
{{- define "server.database.shortType" -}}
289+
{{- define "server.database.dbName" -}}
290290
{{- $dbType := include "server.database.type" . -}}
291291
{{- if $dbType -}}
292292
{{- lower (split "-" $dbType)._0 -}}

helm/templates/server/database.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
# spell-checker: ignore nindent freepdb1 oserror selectai sidb spfile sqlplus
44
# spell-checker: ignore sqlcode sqlerror varchar nolog ptype sysdba tablespace tblspace
55

6-
# This file consolidates database-related Kubernetes resources:
7-
# - Secrets (auth, priv, wallet)
8-
# - Deployment (SIDB-FREE, ADB-FREE)
9-
# - Job (database initialization)
10-
# - AutonomousDatabase (ADB-S operator)
11-
#
12-
# Note: ConfigMap (initialization scripts) is now in db-configmap.yaml
6+
# This file consolidates database-related Kubernetes resources
137

148
{{- if .Values.server.database }}
159

@@ -30,17 +24,17 @@ metadata:
3024
helm.sh/resource-policy: keep
3125
type: Opaque
3226
stringData:
33-
username: "AI_OPTIMIZER"
34-
password: {{ include "server.randomPassword" . | quote }}
27+
{{ default "username" .Values.server.database.authN.usernameKey }}: "AI_OPTIMIZER"
28+
{{ default "password" .Values.server.database.authN.passwordKey }}: {{ include "server.randomPassword" . | quote }}
3529
{{- if eq (include "server.database.isSIDB" .) "true" }}
36-
service: "{{ .Release.Name }}-{{ include "server.database.shortType" . }}-1521:1521/FREEPDB1"
30+
{{ default "service" .Values.server.database.authN.serviceKey }}: "{{ .Release.Name }}-{{ include "server.database.dbName" . }}-1521:1521/FREEPDB1"
3731
{{- else if eq (include "server.database.isADBFree" .) "true" }}
38-
service: "{{ .Release.Name }}-{{ include "server.database.shortType" . }}-1521:1521/FREEPDB1"
32+
{{ default "service" .Values.server.database.authN.serviceKey }}: "{{ .Release.Name }}-{{ include "server.database.dbName" . }}-1521:1521/FREEPDB1"
3933
{{- else if eq (include "server.database.isOther" .) "true" }}
4034
{{- if and .Values.server.database.other.dsn (ne (.Values.server.database.other.dsn | trim) "") }}
41-
service: "{{ .Values.server.database.other.dsn }}"
35+
{{ default "service" .Values.server.database.authN.serviceKey }}: "{{ .Values.server.database.other.dsn }}"
4236
{{- else }}
43-
service: "{{ .Values.server.database.other.host }}:{{ .Values.server.database.other.port }}/{{ .Values.server.database.other.service_name }}"
37+
{{ default "service" .Values.server.database.authN.serviceKey }}: "{{ .Values.server.database.other.host }}:{{ .Values.server.database.other.port }}/{{ .Values.server.database.other.service_name }}"
4438
{{- end }}
4539
{{- end }}
4640
{{- end }}
@@ -85,7 +79,7 @@ stringData:
8579
apiVersion: apps/v1
8680
kind: Deployment
8781
metadata:
88-
name: {{ include "global.fullname" . }}-{{ include "server.database.shortType" . }}
82+
name: {{ include "global.fullname" . }}-{{ include "server.database.dbName" . }}
8983
labels:
9084
app.kubernetes.io/component: database
9185
{{- include "global.labels" . | nindent 4}}
@@ -238,10 +232,6 @@ metadata:
238232
labels:
239233
app.kubernetes.io/component: database
240234
{{- include "global.labels" . | nindent 4 }}
241-
annotations:
242-
"helm.sh/hook": pre-install,pre-upgrade
243-
"helm.sh/hook-weight": "-5"
244-
"helm.sh/hook-delete-policy": before-hook-creation
245235
spec:
246236
action: "Sync"
247237
details:
@@ -253,7 +243,7 @@ spec:
253243
name: {{ .Release.Name }}-adb-wallet-pass-{{ .Release.Revision }}
254244
{{- if .Values.server.oci_config }}
255245
ociConfig:
256-
configMapName: {{ .Release.Name }}-oci-config
246+
configMapName: {{ .Values.server.oci_config.configMapName | default (printf "%s-oci-config" .Release.Name) }}
257247
{{- if .Values.server.oci_config.keySecretName }}
258248
secretName: {{ .Values.server.oci_config.keySecretName }}
259249
{{- end }}

helm/templates/server/oci-configmap.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
# spell-checker: ignore nindent
44

55
{{- if .Values.server.oci_config }}
6+
{{- /* Determine the ConfigMap name to use or create */ -}}
7+
{{- $configMapName := .Values.server.oci_config.configMapName | default (printf "%s-oci-config" .Release.Name) }}
8+
9+
{{- /* Check if the ConfigMap already exists */ -}}
10+
{{- $configMapExists := lookup "v1" "ConfigMap" .Release.Namespace $configMapName }}
11+
12+
{{- /* Only create ConfigMap if it doesn't exist */ -}}
13+
{{- if not $configMapExists }}
614
apiVersion: v1
715
kind: ConfigMap
816
metadata:
9-
name: {{ .Release.Name }}-oci-config
17+
name: {{ $configMapName }}
1018
labels:
1119
app.kubernetes.io/component: server
1220
{{- include "global.labels" . | nindent 4 }}
@@ -25,4 +33,5 @@ data:
2533
region: {{ .region | quote }}
2634
{{- end }}
2735
{{- end }}
36+
{{- end }}
2837
{{- end -}}

helm/templates/server/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
apiVersion: v1
2626
kind: Service
2727
metadata:
28-
name: {{ .Release.Name }}-{{ include "server.database.shortType" . }}-1521
28+
name: {{ .Release.Name }}-{{ include "server.database.dbName" . }}-1521
2929
labels:
3030
app.kubernetes.io/component: database
3131
{{- include "global.labels" . | nindent 4 }}

helm/values.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ nameOverride: ""
1212
# -----------------------
1313
# -- Global Configuration
1414
global:
15-
# -- Either provide the 'apiKey' directly or provide a secretName referring to an existing Secret containing the API key.
15+
# -- Either:
16+
# 1) Provide the 'apiKey' directly
17+
# 2) Provide a secretName referring to an existing Secret containing the API key.
1618
api:
1719
# -- Key for making API calls to the server.
1820
# Recommended to supply at command line or use the secretName to avoid storing in the values file.
@@ -129,8 +131,10 @@ server:
129131

130132
# -- Oracle Cloud Infrastructure Configuration
131133
oci_config:
132-
# -- Enable Workload Identity Principals (WIP) (must be implemented)
134+
# -- Enable Workload Identity Principals (IAM policies must exist)
133135
oke: false
136+
# -- (Optional) Name of Pre-created configMap storing OCI API AuthN
137+
configMapName: ""
134138
# -- Tenancy OCID. Required when specifying keySecretName.
135139
tenancy: ""
136140
# -- User OCID. Required when specifying keySecretName.
@@ -469,4 +473,4 @@ ollama:
469473
tolerations: []
470474
# - key: "key1"
471475
# operator: "Exists"
472-
# effect: "NoSchedule"
476+
# effect: "NoSchedule"

0 commit comments

Comments
 (0)