Skip to content

Commit 6befdc9

Browse files
committed
feat: manage BuildConfigs and ImageStreams via chart, wire deployment image triggers
- Add openshift.build values block to configure BuildConfig source, branch, webhook secret, and ImageStream ownership - New buildconfig.yaml template renders pint and freeradius BuildConfigs; output tag tracks pint/freeradius image.tag - New imagestream.yaml template creates the shared pint and freeradius ImageStreams when openshift.build.manageImageStream=true (prod only) - Add image.openshift.io/triggers annotation to both Deployments so OpenShift rolls them out automatically on each completed build - Default image tag to "latest" (was Chart.appVersion); dev overrides to "dev" - Bump chart version to 0.3.0
1 parent 6c645d7 commit 6befdc9

8 files changed

Lines changed: 174 additions & 9 deletions

File tree

chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: pint
33
description: Pouring IPA for Network Trust - CSH WiFi EAP-TLS enrollment and home RadSec management
44
type: application
5-
version: 0.2.0
5+
version: 0.3.0
66
appVersion: "0.1.0"

chart/templates/_helpers.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Standard Helm labels / selector labels for the PINT pod.
3232
{{- define "pint.labels" -}}
3333
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
3434
{{ include "pint.selectorLabels" . }}
35-
app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.pint.image.tag | quote }}
35+
app.kubernetes.io/version: {{ .Values.pint.image.tag | quote }}
3636
app.kubernetes.io/managed-by: {{ .Release.Service }}
3737
{{- end }}
3838

@@ -86,7 +86,7 @@ so it always matches these labels exactly.
8686
{{- define "pint.freeradiusLabels" -}}
8787
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
8888
{{ include "pint.freeradiusSelectorLabels" . }}
89-
app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.freeradius.image.tag | quote }}
89+
app.kubernetes.io/version: {{ .Values.freeradius.image.tag | quote }}
9090
app.kubernetes.io/managed-by: {{ .Release.Service }}
9191
{{- end }}
9292

@@ -103,9 +103,9 @@ app.kubernetes.io/name={{ include "pint.freeradiusFullname" . }},app.kubernetes.
103103
Container image references: tag falls back to Chart.appVersion.
104104
*/}}
105105
{{- define "pint.image" -}}
106-
{{ .Values.pint.image.repository }}:{{ default .Chart.AppVersion .Values.pint.image.tag }}
106+
{{ .Values.pint.image.repository }}:{{ .Values.pint.image.tag }}
107107
{{- end }}
108108

109109
{{- define "pint.freeradiusImage" -}}
110-
{{ .Values.freeradius.image.repository }}:{{ default .Chart.AppVersion .Values.freeradius.image.tag }}
110+
{{ .Values.freeradius.image.repository }}:{{ .Values.freeradius.image.tag }}
111111
{{- end }}

chart/templates/buildconfig.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{- if .Values.openshift.build.enabled }}
2+
apiVersion: build.openshift.io/v1
3+
kind: BuildConfig
4+
metadata:
5+
name: {{ include "pint.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "pint.labels" . | nindent 4 }}
9+
annotations:
10+
app.openshift.io/vcs-ref: {{ .Values.openshift.build.gitRef | quote }}
11+
app.openshift.io/vcs-uri: {{ .Values.openshift.build.gitRepo | quote }}
12+
spec:
13+
output:
14+
to:
15+
kind: ImageStreamTag
16+
name: {{ printf "%s:%s" .Values.openshift.build.imageStreamName .Values.pint.image.tag | quote }}
17+
successfulBuildsHistoryLimit: 3
18+
failedBuildsHistoryLimit: 2
19+
strategy:
20+
type: Docker
21+
dockerStrategy:
22+
dockerfilePath: Dockerfile
23+
source:
24+
type: Git
25+
git:
26+
uri: {{ .Values.openshift.build.gitRepo | quote }}
27+
ref: {{ .Values.openshift.build.gitRef | quote }}
28+
contextDir: /
29+
triggers:
30+
- type: ConfigChange
31+
- type: GitHub
32+
github:
33+
secretReference:
34+
name: {{ .Values.openshift.build.webhookSecret | quote }}
35+
runPolicy: Serial
36+
{{- if .Values.freeradius.enabled }}
37+
---
38+
apiVersion: build.openshift.io/v1
39+
kind: BuildConfig
40+
metadata:
41+
name: {{ include "pint.freeradiusFullname" . }}
42+
namespace: {{ .Release.Namespace }}
43+
labels:
44+
{{- include "pint.freeradiusLabels" . | nindent 4 }}
45+
annotations:
46+
app.openshift.io/vcs-ref: {{ .Values.openshift.build.gitRef | quote }}
47+
app.openshift.io/vcs-uri: {{ .Values.openshift.build.gitRepo | quote }}
48+
spec:
49+
output:
50+
to:
51+
kind: ImageStreamTag
52+
name: {{ printf "%s:%s" .Values.openshift.build.freeradiusImageStreamName .Values.freeradius.image.tag | quote }}
53+
successfulBuildsHistoryLimit: 3
54+
failedBuildsHistoryLimit: 2
55+
strategy:
56+
type: Docker
57+
dockerStrategy:
58+
dockerfilePath: Dockerfile
59+
source:
60+
type: Git
61+
git:
62+
uri: {{ .Values.openshift.build.gitRepo | quote }}
63+
ref: {{ .Values.openshift.build.gitRef | quote }}
64+
contextDir: /dev/freeradius
65+
triggers:
66+
- type: ConfigChange
67+
- type: GitHub
68+
github:
69+
secretReference:
70+
name: {{ .Values.openshift.build.webhookSecret | quote }}
71+
runPolicy: Serial
72+
{{- end }}
73+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ metadata:
66
namespace: {{ .Release.Namespace }}
77
labels:
88
{{- include "pint.labels" . | nindent 4 }}
9+
{{- if .Values.openshift.build.enabled }}
10+
annotations:
11+
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"{{ .Values.openshift.build.imageStreamName }}:{{ .Values.pint.image.tag }}","namespace":"{{ .Release.Namespace }}"},"fieldPath":"spec.template.spec.containers[?(@.name==\"pint\")].image","paused":"false"}]'
12+
{{- end }}
913
spec:
1014
replicas: 1
1115
selector:

chart/templates/freeradius-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ metadata:
66
namespace: {{ .Release.Namespace }}
77
labels:
88
{{- include "pint.freeradiusLabels" . | nindent 4 }}
9+
{{- if .Values.openshift.build.enabled }}
10+
annotations:
11+
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"{{ .Values.openshift.build.freeradiusImageStreamName }}:{{ .Values.freeradius.image.tag }}","namespace":"{{ .Release.Namespace }}"},"fieldPath":"spec.template.spec.containers[?(@.name==\"freeradius\")].image","paused":"false"}]'
12+
{{- end }}
913
spec:
1014
replicas: 1
1115
selector:

chart/templates/imagestream.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if and .Values.openshift.build.enabled .Values.openshift.build.manageImageStream }}
2+
apiVersion: image.openshift.io/v1
3+
kind: ImageStream
4+
metadata:
5+
name: {{ .Values.openshift.build.imageStreamName }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "pint.labels" . | nindent 4 }}
9+
spec:
10+
lookupPolicy:
11+
local: false
12+
{{- if .Values.freeradius.enabled }}
13+
---
14+
apiVersion: image.openshift.io/v1
15+
kind: ImageStream
16+
metadata:
17+
name: {{ .Values.openshift.build.freeradiusImageStreamName }}
18+
namespace: {{ .Release.Namespace }}
19+
labels:
20+
{{- include "pint.freeradiusLabels" . | nindent 4 }}
21+
spec:
22+
lookupPolicy:
23+
local: false
24+
{{- end }}
25+
{{- end }}

chart/values.schema.json

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@
174174
},
175175
"tag": {
176176
"type": "string",
177-
"description": "Image tag. Defaults to the chart appVersion."
177+
"description": "Image tag.",
178+
"default": "latest"
178179
},
179180
"pullPolicy": {
180181
"type": "string",
@@ -218,7 +219,8 @@
218219
},
219220
"tag": {
220221
"type": "string",
221-
"description": "Image tag. Defaults to the chart appVersion."
222+
"description": "Image tag.",
223+
"default": "latest"
222224
},
223225
"pullPolicy": {
224226
"type": "string",
@@ -286,6 +288,46 @@
286288
"description": "Route hostname. Omit for an auto-assigned hostname."
287289
}
288290
}
291+
},
292+
"build": {
293+
"type": "object",
294+
"description": "OpenShift BuildConfig and ImageStream management.",
295+
"properties": {
296+
"enabled": {
297+
"type": "boolean",
298+
"description": "Create BuildConfigs and wire image-change triggers on the Deployments.",
299+
"default": false
300+
},
301+
"gitRepo": {
302+
"type": "string",
303+
"description": "Git repository URL for source builds.",
304+
"default": "https://github.com/ComputerScienceHouse/pint.git"
305+
},
306+
"gitRef": {
307+
"type": "string",
308+
"description": "Git branch or tag to build from (e.g. 'dev' or 'main')."
309+
},
310+
"webhookSecret": {
311+
"type": "string",
312+
"description": "Name of the Secret containing the GitHub webhook secret.",
313+
"default": "github-webhook-secret"
314+
},
315+
"manageImageStream": {
316+
"type": "boolean",
317+
"description": "Create/own the shared ImageStream objects. Set true in exactly one release (typically prod).",
318+
"default": false
319+
},
320+
"imageStreamName": {
321+
"type": "string",
322+
"description": "Name of the ImageStream for the pint application image.",
323+
"default": "pint"
324+
},
325+
"freeradiusImageStreamName": {
326+
"type": "string",
327+
"description": "Name of the ImageStream for the freeradius image.",
328+
"default": "freeradius"
329+
}
330+
}
289331
}
290332
}
291333
}

chart/values.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pint:
1010
enabled: true
1111
image:
1212
repository: pint
13-
tag: "" # defaults to Chart.appVersion
13+
tag: "latest"
1414
pullPolicy: IfNotPresent
1515

1616
# Non-sensitive PINT application configuration rendered into a ConfigMap.
@@ -79,7 +79,7 @@ freeradius:
7979
enabled: true
8080
image:
8181
repository: pint-freeradius
82-
tag: "" # defaults to Chart.appVersion
82+
tag: "latest"
8383
pullPolicy: IfNotPresent
8484
service:
8585
type: NodePort
@@ -109,3 +109,20 @@ openshift:
109109
enabled: false
110110
route:
111111
host: ""
112+
113+
# OpenShift BuildConfig and ImageStream management.
114+
# When enabled, the chart creates BuildConfigs that build pint and freeradius
115+
# images from source and push them to internal ImageStreamTags. The Deployments
116+
# are annotated so OpenShift rolls them out automatically when a new image lands.
117+
build:
118+
enabled: false
119+
gitRepo: "https://github.com/ComputerScienceHouse/pint.git"
120+
gitRef: "" # branch/tag to build from (e.g. "dev" or "main")
121+
webhookSecret: "github-webhook-secret" # Secret name containing the GitHub webhook secret
122+
123+
# Set true in exactly one release to own the shared ImageStream objects.
124+
# Both dev and prod BuildConfigs push to the same ImageStreams (different tags),
125+
# so only one release should create/delete them.
126+
manageImageStream: false
127+
imageStreamName: "pint"
128+
freeradiusImageStreamName: "freeradius"

0 commit comments

Comments
 (0)