Skip to content

Commit fbcc71d

Browse files
committed
chore(helm): enhance chart and deployment guide
1 parent 3406ce1 commit fbcc71d

File tree

11 files changed

+378
-58
lines changed

11 files changed

+378
-58
lines changed

charts/provenance/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: provenance
3-
version: 0.1.0
3+
version: 0.2.0
44
appVersion: "0.1.0"
55
description: Helm chart for Provenance & Risk Analytics service
66
type: application

charts/provenance/README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
# Provenance Helm Chart
22

3-
Deploys the Provenance & Risk Analytics service and an optional Redis instance.
3+
Deploys the Provenance & Risk Analytics API with optional managed Redis, ingress, autoscaling, and tunable environment settings.
44

55
## Prerequisites
66

77
- Kubernetes 1.23+
8-
- Helm 3+
8+
- Helm 3.8+
99

10-
## Getting Started
10+
## Installing
1111

1212
```bash
13-
helm install provenance charts/provenance \
13+
helm install provenance charts/provenance \
1414
--set image.repository=ghcr.io/your-org/provenance \
1515
--set image.tag=latest
1616
```
1717

18-
To enable the bundled Redis dependency, leave `redis.enabled=true` (default). Provide external Redis by setting `redis.enabled=false` and overriding `PROVENANCE_REDIS_URL` via `values.yaml` or `--set`.
18+
Common overrides:
1919

20-
Expose the service via Ingress:
20+
- `--set env.PROVENANCE_SERVICE_BASE_URL=https://provenance.example.com` to align generated links with your ingress.
21+
- `--set redis.enabled=false --set env.PROVENANCE_REDIS_URL=redis://redis.example.com:6379/0` to reuse an external Redis cluster.
22+
- `--set ingress.enabled=true --set ingress.hosts[0].host=provenance.example.com` to expose the service publicly.
2123

22-
```bash
23-
helm install provenance charts/provenance \
24-
--set ingress.enabled=true \
25-
--set ingress.hosts[0].host=provenance.example.com \
26-
--set ingress.hosts[0].paths[0].path=/ \
27-
--set ingress.hosts[0].paths[0].pathType=Prefix
28-
```
24+
## Values
25+
26+
| Key | Description | Default |
27+
| --- | --- | --- |
28+
| `replicaCount` | API replicas (ignored when `autoscaling.enabled=true`) | `2` |
29+
| `image.repository` | Container image repository | `evalops/provenance` |
30+
| `serviceAccount.create` | Create a service account automatically | `true` |
31+
| `env` | Base environment variables for the API container | `{ PROVENANCE_SERVICE_BASE_URL: http://provenance:8000 }` |
32+
| `extraEnv` / `extraEnvFrom` | Additional env pairs or references (ConfigMap/Secret) | `[]` |
33+
| `resources` | CPU/memory requests & limits | `{}` |
34+
| `livenessProbe` & `readinessProbe` | HTTP probes served from `/healthz` | Enabled |
35+
| `autoscaling.enabled` | HorizontalPodAutoscaler toggle | `false` |
36+
| `ingress.*` | Ingress configuration (class, hosts, TLS) | Disabled |
37+
| `redis.enabled` | Deploy bundled Redis | `true` |
38+
| `redis.persistence.enabled` | Provision PVC for Redis data | `false` |
39+
40+
See [`values.yaml`](values.yaml) for the full catalog (node selectors, tolerations, OTEL knobs, extra volumes, etc.).
2941

30-
## Configuration
42+
## Upgrade Notes
3143

32-
See `values.yaml` for configurable options including environment variables, resources, and OTEL settings.
44+
- When enabling Redis persistence, ensure an appropriate storage class exists.
45+
- Provide signing keys and API tokens via `extraEnvFrom` referencing Kubernetes Secrets.
46+
- Enable autoscaling by toggling `autoscaling.enabled` and configuring min/max replicas and CPU utilization targets.

charts/provenance/templates/_helpers.tpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,30 @@
1414
{{- define "provenance.chart" -}}
1515
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" -}}
1616
{{- end -}}
17+
18+
{{- define "provenance.labels" -}}
19+
app.kubernetes.io/name: {{ include "provenance.name" . }}
20+
helm.sh/chart: {{ include "provenance.chart" . }}
21+
app.kubernetes.io/instance: {{ .Release.Name }}
22+
app.kubernetes.io/managed-by: {{ .Release.Service }}
23+
{{- with .Values.commonLabels }}
24+
{{ toYaml . }}
25+
{{- end }}
26+
{{- end -}}
27+
28+
{{- define "provenance.selectorLabels" -}}
29+
app.kubernetes.io/name: {{ include "provenance.name" . }}
30+
app.kubernetes.io/instance: {{ .Release.Name }}
31+
{{- end -}}
32+
33+
{{- define "provenance.serviceAccountName" -}}
34+
{{- if .Values.serviceAccount.create -}}
35+
{{- default (include "provenance.fullname" .) .Values.serviceAccount.name -}}
36+
{{- else -}}
37+
{{- default "default" .Values.serviceAccount.name -}}
38+
{{- end -}}
39+
{{- end -}}
40+
41+
{{- define "provenance.redisFullname" -}}
42+
{{ printf "%s-redis" (include "provenance.fullname" .) | trunc 63 | trimSuffix "-" }}
43+
{{- end -}}

charts/provenance/templates/deployment.yaml

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,123 @@ kind: Deployment
33
metadata:
44
name: {{ include "provenance.fullname" . }}
55
labels:
6-
app.kubernetes.io/name: {{ include "provenance.name" . }}
7-
helm.sh/chart: {{ include "provenance.chart" . }}
8-
app.kubernetes.io/instance: {{ .Release.Name }}
9-
app.kubernetes.io/managed-by: {{ .Release.Service }}
6+
{{- include "provenance.labels" . | nindent 4 }}
107
spec:
11-
replicas: {{ .Values.replicas | default 1 }}
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
1211
selector:
1312
matchLabels:
14-
app.kubernetes.io/name: {{ include "provenance.name" . }}
15-
app.kubernetes.io/instance: {{ .Release.Name }}
13+
{{- include "provenance.selectorLabels" . | nindent 6 }}
1614
template:
1715
metadata:
1816
labels:
19-
app.kubernetes.io/name: {{ include "provenance.name" . }}
20-
app.kubernetes.io/instance: {{ .Release.Name }}
17+
{{- include "provenance.selectorLabels" . | nindent 8 }}
18+
{{- with .Values.podLabels }}
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
{{- with .Values.podAnnotations }}
22+
annotations:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
2125
spec:
26+
serviceAccountName: {{ include "provenance.serviceAccountName" . }}
27+
{{- with .Values.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
{{- with .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
{{- if .Values.redis.enabled }}
36+
initContainers:
37+
- name: wait-for-redis
38+
image: busybox:1.36
39+
command:
40+
- sh
41+
- -c
42+
- >
43+
until nc -z {{ include "provenance.redisFullname" . }} {{ .Values.redis.service.port }};
44+
do echo "waiting for redis";
45+
sleep 2;
46+
done
47+
{{- end }}
2248
containers:
2349
- name: provenance
2450
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
2551
imagePullPolicy: {{ .Values.image.pullPolicy }}
52+
{{- with .Values.securityContext }}
53+
securityContext:
54+
{{- toYaml . | nindent 12 }}
55+
{{- end }}
2656
ports:
2757
- name: http
2858
containerPort: 8000
59+
{{- $envMap := .Values.env | default dict }}
60+
{{- $extraEnvList := .Values.extraEnv | default (list) }}
61+
{{- $hasExtraEnv := gt (len $extraEnvList) 0 }}
62+
{{- $needsRedisEnv := and .Values.redis.enabled (not (hasKey $envMap "PROVENANCE_REDIS_URL")) }}
63+
{{- if or (gt (len $envMap) 0) $hasExtraEnv $needsRedisEnv }}
2964
env:
30-
{{- range $key, $value := .Values.env }}
65+
{{- range $key, $value := $envMap }}
3166
- name: {{ $key }}
3267
value: "{{ $value }}"
3368
{{- end }}
34-
resources: {{ toYaml .Values.resources | nindent 12 }}
35-
{{- if .Values.redis.enabled }}
36-
initContainers:
37-
- name: wait-for-redis
38-
image: busybox
39-
command: ['sh', '-c', 'until nc -z redis 6379; do sleep 1; done']
69+
{{- if $needsRedisEnv }}
70+
- name: PROVENANCE_REDIS_URL
71+
value: "redis://{{ include "provenance.redisFullname" . }}:{{ .Values.redis.service.port }}/0"
72+
{{- end }}
73+
{{- range $extraEnvList }}
74+
- name: {{ .name }}
75+
value: "{{ .value }}"
76+
{{- end }}
77+
{{- end }}
78+
{{- with .Values.extraEnvFrom }}
79+
envFrom:
80+
{{- toYaml . | nindent 12 }}
81+
{{- end }}
82+
{{- if .Values.livenessProbe.enabled }}
83+
livenessProbe:
84+
httpGet:
85+
path: {{ .Values.livenessProbe.path }}
86+
port: http
87+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
88+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
89+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
90+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
91+
{{- end }}
92+
{{- if .Values.readinessProbe.enabled }}
93+
readinessProbe:
94+
httpGet:
95+
path: {{ .Values.readinessProbe.path }}
96+
port: http
97+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
98+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
99+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
100+
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
101+
{{- end }}
102+
{{- with .Values.extraVolumeMounts }}
103+
volumeMounts:
104+
{{- toYaml . | nindent 12 }}
105+
{{- end }}
106+
{{- with .Values.resources }}
107+
resources:
108+
{{- toYaml . | nindent 12 }}
109+
{{- end }}
110+
{{- with .Values.extraVolumes }}
111+
volumes:
112+
{{- toYaml . | nindent 8 }}
113+
{{- end }}
114+
{{- with .Values.nodeSelector }}
115+
nodeSelector:
116+
{{- toYaml . | nindent 8 }}
117+
{{- end }}
118+
{{- with .Values.affinity }}
119+
affinity:
120+
{{- toYaml . | nindent 8 }}
121+
{{- end }}
122+
{{- with .Values.tolerations }}
123+
tolerations:
124+
{{- toYaml . | nindent 8 }}
40125
{{- end }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "provenance.fullname" . }}
6+
labels:
7+
{{- include "provenance.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "provenance.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
- type: Resource
17+
resource:
18+
name: cpu
19+
target:
20+
type: Utilization
21+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
22+
{{- end }}

charts/provenance/templates/ingress.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:
55
name: {{ include "provenance.fullname" . }}
6+
labels:
7+
{{- include "provenance.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
69
annotations:
7-
{{- range $key, $value := .Values.ingress.annotations }}
8-
{{ $key }}: {{ $value | quote }}
9-
{{- end }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
1012
spec:
13+
{{- if .Values.ingress.className }}
14+
ingressClassName: {{ .Values.ingress.className }}
15+
{{- end }}
1116
rules:
1217
{{- range .Values.ingress.hosts }}
1318
- host: {{ .host }}
@@ -26,7 +31,10 @@ spec:
2631
{{- if .Values.ingress.tls }}
2732
tls:
2833
{{- range .Values.ingress.tls }}
29-
- hosts: {{ toYaml .hosts | nindent 6 }}
34+
- hosts:
35+
{{- range .hosts }}
36+
- {{ . }}
37+
{{- end }}
3038
secretName: {{ .secretName }}
3139
{{- end }}
3240
{{- end }}

0 commit comments

Comments
 (0)