Skip to content

Commit a45ffc1

Browse files
committed
fix(helm): address PR #54 review comments + sync docs (SPEC-008)
Review by @senolcolak: - _helpers.tpl: drop the dead "REPLACE_ME" database.url placeholder; renders "" when unset (#1). - deployment.yaml + daemonset.yaml: gate the whole `annotations:` block (the checksum/config hash) on `not secrets.existingSecret` — the chart can't hash a Secret it doesn't render, and an empty annotations key is invalid (#2, #3). - _helpers.tpl + values.yaml: wire `database.existingSecret` — inject O3K_DB_URL via secretKeyRef (+ `database.existingSecretKey`, default "url"); fix the misleading value comment. Add `automountServiceAccountToken: false` (O3K never calls the k8s API) (#4). - ingress.yaml + values: never render an empty `tls` secretName — derive `<release>-o3k-tls` when unset — and emit a kind-aware cert-manager annotation via new `tls.certManagerKind` (ClusterIssuer|Issuer); schema + ingress_test.yaml added (#5). - NOTES.txt: `kubectl rollout status` targets ds/ in multi-node, deploy/ in single-node (#6). - README.md: sync docs to the above — document database.existingSecretKey and tls.certManagerKind, the derived tls secret name + cert-manager annotation, the existing-Secret checksum caveat, automountServiceAccountToken, and that dataRetentionPolicy=delete is deferred to #53. helm lint clean; helm unittest 7 suites / 28 tests green. Signed-off-by: Uwe Schwaeke <uwe.schwaeke@clyso.com>
1 parent 9c16542 commit a45ffc1

9 files changed

Lines changed: 115 additions & 19 deletions

File tree

‎charts/o3k/README.md‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ Defaults target the single-node stub MVP. "Mode" = where the value applies.
5252
| Key | Default | Mode | Purpose |
5353
|-----|---------|------|---------|
5454
| `database.url` | `""` **(required)** | all | external PostgreSQL URL |
55-
| `database.existingSecret` | `""` | all | Secret providing the DB URL instead |
55+
| `database.existingSecret` | `""` | all | Secret holding the DB URL (alternative to `database.url`); injected as `O3K_DB_URL` |
56+
| `database.existingSecretKey` | `url` | all | key within `database.existingSecret` that holds the URL |
5657
| `secrets.jwtSecret` | `""` **(required)** | all | token signing secret |
5758
| `secrets.adminUser` | `admin` | all | admin account name |
5859
| `secrets.adminPassword` | `""` **(required)** | all | admin password (no `admin/secret`) |
5960
| `secrets.existingSecret` | `""` | all | pre-rendered Secret with an `o3k.yaml` key (GitOps) |
6061

6162
> Config (including credentials) is rendered into a **Secret** mounted at the binary's
6263
> `--config` path — the binary has no per-key env override for most settings, so they are
63-
> not injectable via individual env vars.
64+
> not injectable via individual env vars. The pod also sets
65+
> `automountServiceAccountToken: false` (O3K never calls the Kubernetes API).
6466
6567
### Exposure & TLS
6668
| Key | Default | Mode | Purpose |
@@ -70,7 +72,9 @@ Defaults target the single-node stub MVP. "Mode" = where the value applies.
7072
| `service.annotations` | `{}` | all | e.g. LoadBalancer annotations |
7173
| `ingress.enabled` / `className` / `annotations` / `hosts` | `false` / … | all | external Ingress |
7274
| `tls.enabled` | `false` | all | per-service-port TLS; sets the `https` catalog scheme |
73-
| `tls.secretName` / `tls.certManagerIssuer` | `""` | all | operator/cert-manager cert (chart generates none) |
75+
| `tls.secretName` | `""` → `<release>-o3k-tls` | all | cert Secret; defaults to `<release>-o3k-tls` when unset |
76+
| `tls.certManagerIssuer` | `""` | all | cert-manager (Cluster)Issuer name; chart emits the annotation so the cert is provisioned |
77+
| `tls.certManagerKind` | `ClusterIssuer` | all | which cert-manager annotation: `ClusterIssuer` or `Issuer` |
7478

7579
### Service modes
7680
| Key | Default | Mode | Purpose |
@@ -104,7 +108,7 @@ Defaults target the single-node stub MVP. "Mode" = where the value applies.
104108
|-----|---------|------|---------|
105109
| `cache.enabled` | `false` | all | opt-in Redis cache |
106110
| `cache.redisUrl` | `""` | all | **single shared** Redis in multi-node (FR-006a) |
107-
| `dataRetentionPolicy` | `retain` | all | `retain`/`delete` node-local data on uninstall |
111+
| `dataRetentionPolicy` | `retain` | all | only `retain` is active; the `delete` purge is deferred to issue #53 |
108112
| `logging.level` / `logging.format` | `info` / `json` | all | structured logs (FR-013a) |
109113
| `resources` / `nodeSelector` / `tolerations` / `affinity` | `{}`/… | all | pod scheduling |
110114

@@ -119,17 +123,23 @@ Defaults target the single-node stub MVP. "Mode" = where the value applies.
119123

120124
## TLS
121125

122-
Set `tls.enabled=true` with `ingress.enabled=true` and a cert (`tls.secretName` or
123-
`tls.certManagerIssuer`). The chart advertises `https://` catalog/self-link URLs
124-
(`O3K_ENDPOINT_SCHEME=https`). TLS terminates per service port; the chart generates no certs.
126+
Set `tls.enabled=true` with `ingress.enabled=true`, then either supply your own cert Secret
127+
(`tls.secretName`) or name a cert-manager issuer (`tls.certManagerIssuer`). With an issuer,
128+
the chart emits the matching annotation — `cert-manager.io/cluster-issuer` by default, or
129+
`cert-manager.io/issuer` when `tls.certManagerKind: Issuer` — and points it at `tls.secretName`
130+
(defaulting to `<release>-o3k-tls`), so cert-manager provisions the cert. The chart never
131+
generates certs itself. Either way it advertises `https://` catalog/self-link URLs
132+
(`O3K_ENDPOINT_SCHEME=https`); TLS terminates per service port.
125133

126134
## Upgrade
127135

128136
```bash
129137
helm upgrade o3k ./charts/o3k --reuse-values --set logging.level=debug
130138
```
131-
Config changes roll the pod (a config checksum annotation). Single-node real upgrades use
132-
`Recreate` (brief downtime); multi-node uses a DaemonSet rolling update. The external
139+
Config changes roll the pod (a config checksum annotation) — except with
140+
`secrets.existingSecret`, where the chart can't hash a Secret it doesn't render, so roll the
141+
pod yourself (`kubectl rollout restart`, or a tool like Reloader). Single-node real upgrades
142+
use `Recreate` (brief downtime); multi-node uses a DaemonSet rolling update. The external
133143
database and any networked/host storage are untouched — **no data loss** (FR-014, SC-005).
134144

135145
## Uninstall & data retention
@@ -139,8 +149,10 @@ helm uninstall o3k
139149
```
140150
Removes all release-owned resources (Deployment/DaemonSet, Service, Secret, Ingress) — no
141151
orphans (SC-006). **Not** removed: the external database, networked backends (RBD/S3), and
142-
**node-local `hostPath` data** on each node (not Helm-managed). `dataRetentionPolicy`
143-
documents intent; clean node-local data manually when `delete`.
152+
**node-local `hostPath` data** on each node (not Helm-managed). Today only
153+
`dataRetentionPolicy: retain` is active; the active `delete` purge (DB reset, namespaces,
154+
libvirt domains, node-local data) is deferred to [issue #53](https://github.com/cobaltcore-dev/o3k/issues/53).
155+
Until then, clean node-local data manually.
144156

145157
## Multiple releases
146158

‎charts/o3k/templates/NOTES.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Advertised catalog host: {{ if .Values.tls.enabled }}https{{ else }}http{{ end }
1010
{{- end }}
1111

1212
Verify the deployment:
13+
{{- if eq .Values.deploymentMode "multi-node" }}
14+
kubectl rollout status ds/{{ include "o3k.fullname" . }}
15+
{{- else }}
1316
kubectl rollout status deploy/{{ include "o3k.fullname" . }}
17+
{{- end }}
1418
helm test {{ .Release.Name }}
1519

1620
Authenticate (port-forward example):

‎charts/o3k/templates/_helpers.tpl‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ admin password — is carried in the --config file, kept out of plaintext via a
8181
*/}}
8282
{{- define "o3k.config" -}}
8383
database:
84-
url: {{ .Values.database.url | default "postgres://o3k@REPLACE_ME/o3k" | quote }}
84+
url: {{ .Values.database.url | quote }}
8585
max_connections: 50
8686
keystone:
8787
port: 35357
@@ -124,6 +124,8 @@ access stay identical across modes. Include with: {{- include "o3k.podSpec" . |
124124
*/}}
125125
{{- define "o3k.podSpec" -}}
126126
{{- $kv := splitn "=" 2 .Values.multiNode.nodeSelectorLabel -}}
127+
# O3K never calls the Kubernetes API — don't mount a ServiceAccount token (FR-009c; reduces attack surface).
128+
automountServiceAccountToken: false
127129
{{- with .Values.image.pullSecrets }}
128130
imagePullSecrets:
129131
{{- toYaml . | nindent 2 }}
@@ -153,8 +155,15 @@ containers:
153155
securityContext:
154156
privileged: {{ .Values.realMode.privileged }}
155157
{{- end }}
156-
{{- if or .Values.endpointHost .Values.tls.enabled }}
158+
{{- if or .Values.endpointHost .Values.tls.enabled .Values.database.existingSecret }}
157159
env:
160+
{{- if .Values.database.existingSecret }}
161+
- name: O3K_DB_URL
162+
valueFrom:
163+
secretKeyRef:
164+
name: {{ .Values.database.existingSecret }}
165+
key: {{ .Values.database.existingSecretKey | default "url" }}
166+
{{- end }}
158167
{{- if .Values.endpointHost }}
159168
- name: O3K_ENDPOINT_HOST
160169
value: {{ .Values.endpointHost | quote }}

‎charts/o3k/templates/daemonset.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ spec:
2222
metadata:
2323
labels:
2424
{{- include "o3k.selectorLabels" . | nindent 8 }}
25+
{{- if not .Values.secrets.existingSecret }}
2526
annotations:
27+
# Roll the pod when the chart-rendered config changes. Omitted when an
28+
# external Secret is used — the chart can't hash a Secret it doesn't render,
29+
# so rollout on change is the operator's responsibility there.
2630
checksum/config: {{ include "o3k.config" . | sha256sum }}
31+
{{- end }}
2732
spec:
2833
{{- include "o3k.podSpec" . | nindent 6 }}
2934
{{- end }}

‎charts/o3k/templates/deployment.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ spec:
2020
metadata:
2121
labels:
2222
{{- include "o3k.selectorLabels" . | nindent 8 }}
23+
{{- if not .Values.secrets.existingSecret }}
2324
annotations:
25+
# Roll the pod when the chart-rendered config changes. Omitted when an
26+
# external Secret is used — the chart can't hash a Secret it doesn't render,
27+
# so rollout on change is the operator's responsibility there.
2428
checksum/config: {{ include "o3k.config" . | sha256sum }}
29+
{{- end }}
2530
spec:
2631
{{- include "o3k.podSpec" . | nindent 6 }}
2732
{{- end }}

‎charts/o3k/templates/ingress.yaml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ metadata:
1313
name: {{ include "o3k.fullname" . }}
1414
labels:
1515
{{- include "o3k.labels" . | nindent 4 }}
16-
{{- with .Values.ingress.annotations }}
16+
{{- if or .Values.ingress.annotations (and .Values.tls.enabled .Values.tls.certManagerIssuer) }}
1717
annotations:
18+
{{- with .Values.ingress.annotations }}
1819
{{- toYaml . | nindent 4 }}
20+
{{- end }}
21+
{{- if and .Values.tls.enabled .Values.tls.certManagerIssuer }}
22+
{{- if eq .Values.tls.certManagerKind "Issuer" }}
23+
cert-manager.io/issuer: {{ .Values.tls.certManagerIssuer | quote }}
24+
{{- else }}
25+
cert-manager.io/cluster-issuer: {{ .Values.tls.certManagerIssuer | quote }}
26+
{{- end }}
27+
{{- end }}
1928
{{- end }}
2029
spec:
2130
{{- with .Values.ingress.className }}
@@ -27,7 +36,7 @@ spec:
2736
{{- if .Values.endpointHost }}
2837
- {{ .Values.endpointHost | quote }}
2938
{{- end }}
30-
secretName: {{ .Values.tls.secretName | quote }}
39+
secretName: {{ .Values.tls.secretName | default (printf "%s-tls" (include "o3k.fullname" .)) | quote }}
3140
{{- end }}
3241
rules:
3342
{{- range .Values.ingress.hosts }}

‎charts/o3k/tests/ingress_test.yaml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# helm-unittest specs for the Ingress + cert-manager TLS wiring (review comment #5, FR-008b).
2+
suite: ingress / tls cert-manager
3+
templates:
4+
- templates/ingress.yaml
5+
set:
6+
image.repository: ghcr.io/o3k/o3k
7+
secrets.jwtSecret: jwt
8+
secrets.adminPassword: pw
9+
database.url: postgres://o3k@db/o3k
10+
ingress.enabled: true
11+
tls.enabled: true
12+
tests:
13+
- it: ClusterIssuer (default) — emits the cluster-issuer annotation and derives the secret name
14+
set:
15+
tls.certManagerIssuer: letsencrypt
16+
endpointHost: o3k.example.com
17+
asserts:
18+
- equal:
19+
path: metadata.annotations["cert-manager.io/cluster-issuer"]
20+
value: letsencrypt
21+
- equal:
22+
path: spec.tls[0].secretName
23+
value: RELEASE-NAME-o3k-tls
24+
- it: Issuer kind — emits the namespaced issuer annotation and honors an explicit secretName
25+
set:
26+
tls.certManagerIssuer: my-issuer
27+
tls.certManagerKind: Issuer
28+
tls.secretName: my-cert
29+
asserts:
30+
- equal:
31+
path: metadata.annotations["cert-manager.io/issuer"]
32+
value: my-issuer
33+
- notExists:
34+
path: metadata.annotations["cert-manager.io/cluster-issuer"]
35+
- equal:
36+
path: spec.tls[0].secretName
37+
value: my-cert
38+
- it: operator-supplied secretName without cert-manager — no cert-manager annotation, never an empty name
39+
set:
40+
tls.secretName: o3k-cert
41+
asserts:
42+
- equal:
43+
path: spec.tls[0].secretName
44+
value: o3k-cert
45+
- notExists:
46+
path: metadata.annotations["cert-manager.io/cluster-issuer"]

‎charts/o3k/values.schema.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
"ingress": { "type": "object" },
3232
"tls": {
3333
"type": "object",
34-
"properties": { "enabled": { "type": "boolean" } }
34+
"properties": {
35+
"enabled": { "type": "boolean" },
36+
"certManagerKind": { "type": "string", "enum": ["ClusterIssuer", "Issuer"] }
37+
}
3538
},
3639
"nova": {
3740
"type": "object",

‎charts/o3k/values.yaml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ replicaCount: 1
1919
# -- External database (REQUIRED — the chart deploys no DB). FR-006.
2020
database:
2121
url: "" # postgres://user:pass@host:5432/o3k?sslmode=disable
22-
existingSecret: "" # name of a Secret holding the full o3k.yaml (alternative to inline secrets)
22+
existingSecret: "" # name of a Secret holding the DB URL (alternative to database.url);
23+
# injected as the O3K_DB_URL env var, which overrides the config file
24+
existingSecretKey: url # key within database.existingSecret that holds the URL
2325

2426
# -- Sensitive values. Required unless secrets.existingSecret is supplied. FR-007/007a/007b.
2527
secrets:
@@ -46,8 +48,9 @@ ingress:
4648
# -- Optional TLS at the exposure layer (FR-008b). Sets the catalog scheme to https.
4749
tls:
4850
enabled: false
49-
secretName: "" # operator-supplied cert Secret
50-
certManagerIssuer: "" # OR a cert-manager issuer name
51+
secretName: "" # operator-supplied cert Secret (default: <release>-o3k-tls)
52+
certManagerIssuer: "" # OR a cert-manager (Cluster)Issuer name to auto-provision the cert
53+
certManagerKind: ClusterIssuer # which cert-manager annotation to emit: ClusterIssuer | Issuer
5154

5255
# -- Per-service modes (FR-011/012). All set in the rendered o3k.yaml.
5356
nova:

0 commit comments

Comments
 (0)