Skip to content

Commit e7deb2a

Browse files
committed
refactor: simplify k8s secret management
1 parent 58b5a4e commit e7deb2a

25 files changed

Lines changed: 169 additions & 209 deletions

.env.dev.example

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ PINT_IPA_SKIP_TLS_VERIFY=true
1515
#PINT_IPA_RADSEC_CLIENT_CERT_PROFILE=pint_radsec_client
1616
#PINT_IPA_RADSEC_SERVER_CERT_PROFILE=pint_radsec_server
1717
PINT_WIFI_SSID=CSH
18-
#PINT_NAMESPACE=pint
19-
#PINT_RADIUS_CLIENTS_SECRET=pint-radius-clients
20-
#PINT_RADIUS_CONFIG_SECRET=pint-radius-config
21-
#PINT_RADSEC_CERT_SECRET=pint-radsec-server
22-
#PINT_FREERADIUS_DEPLOYMENT=pint-freeradius
18+
PINT_NAMESPACE=pint
19+
PINT_CONFIG_SECRET=pint-config
20+
PINT_RADSEC_CERT_SECRET=pint-radsec-server-certificates
21+
PINT_FREERADIUS_DEPLOYMENT=pint-freeradius
2322
PINT_RADIUS_SERVER=radius.csh.rit.edu:2083
2423
# FreeRADIUS status server queries (per-pod auth stats).
2524
# In dev, pod IPs are unreachable from macOS — use the NodePort exposed on localhost instead.

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ dev-freeradius:
6262
kind load docker-image $(FR_IMAGE) --name $(CLUSTER)
6363
kubectl rollout restart deployment/pint-freeradius -n $(NAMESPACE) 2>/dev/null || true
6464

65-
# Create the pint-env K8s Secret from .env.dev so PINT can run in-cluster.
65+
# Create the envSecret K8s Secret from .env.dev so PINT can run in-cluster.
66+
# The release name is "pint" so the secret name matches the chart default (envSecret=<fullname>="pint").
6667
# Only needed if you want to run PINT in kind (pint.enabled=true) rather than locally.
6768
dev-secret:
68-
kubectl create secret generic pint-env \
69+
kubectl create secret generic pint \
6970
--namespace $(NAMESPACE) \
7071
--from-env-file=.env.dev \
7172
--dry-run=client -o yaml | kubectl apply -f -
-12 KB
Binary file not shown.

chart/templates/_helpers.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ app.kubernetes.io/name: {{ include "pint.name" . }}
4141
app.kubernetes.io/instance: {{ .Release.Name }}
4242
{{- end }}
4343

44+
{{/*
45+
Runtime-managed secret names.
46+
These default to "<fullname>-<suffix>" so multiple releases in the same namespace
47+
never collide. Each can be overridden via the corresponding values key.
48+
*/}}
49+
{{- define "pint.secretName.config" -}}
50+
{{- .Values.secrets.config | default (printf "%s-config" (include "pint.fullname" .)) }}
51+
{{- end }}
52+
53+
{{- define "pint.secretName.radSecCert" -}}
54+
{{- .Values.secrets.radSecCert | default (printf "%s-radsec-server-certificates" (include "pint.fullname" .)) }}
55+
{{- end }}
56+
57+
{{- define "pint.envSecret" -}}
58+
{{- .Values.envSecret | default (include "pint.fullname" .) }}
59+
{{- end }}
60+
4461
{{/*
4562
FreeRADIUS labels / selector labels.
4663
The selector string is also injected into PINT as PINT_FREERADIUS_POD_SELECTOR

chart/templates/deployment.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@ spec:
2828
- configMapRef:
2929
name: {{ include "pint.fullname" . }}
3030
- secretRef:
31-
name: {{ .Values.envSecret }}
31+
name: {{ include "pint.envSecret" . }}
3232
env:
3333
# Non-sensitive deployment config injected by the chart so it stays
3434
# consistent with the Role resourceNames and FreeRADIUS volume mounts.
3535
- name: PINT_NAMESPACE
3636
valueFrom:
3737
fieldRef:
3838
fieldPath: metadata.namespace
39-
- name: PINT_RADIUS_CLIENTS_SECRET
40-
value: {{ .Values.secrets.radiusClients | quote }}
41-
- name: PINT_RADIUS_CONFIG_SECRET
42-
value: {{ .Values.secrets.radiusConfig | quote }}
39+
- name: PINT_CONFIG_SECRET
40+
value: {{ include "pint.secretName.config" . | quote }}
4341
- name: PINT_RADSEC_CERT_SECRET
44-
value: {{ .Values.secrets.radSecCert | quote }}
42+
value: {{ include "pint.secretName.radSecCert" . | quote }}
4543
{{- if .Values.freeradius.enabled }}
4644
- name: PINT_FREERADIUS_DEPLOYMENT
4745
value: {{ include "pint.freeradiusFullname" . | quote }}

chart/templates/freeradius-deployment.yaml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,19 @@ spec:
3131
securityContext:
3232
{{- toYaml .Values.freeradius.securityContext | nindent 12 }}
3333
volumeMounts:
34-
# Full-directory mount (not subPath) so K8s auto-syncs clients.conf
35-
# when the Secret changes; FreeRADIUS picks it up on the next SIGHUP.
36-
- name: dynamic-clients
37-
mountPath: /etc/freeradius/dynamic
34+
- name: pint-config
35+
mountPath: /etc/pint/config
3836
readOnly: true
39-
# All TLS material written by PINT: server cert+key, RadSec CA,
40-
# WiFi CA. 0444 so the freerad user can read without root.
41-
- name: radsec-certs
42-
mountPath: /run/secrets/radsec-server
43-
readOnly: true
44-
- name: radius-status-config
45-
mountPath: /run/secrets/radius-status
37+
- name: pint-radsec
38+
mountPath: /etc/pint/radsec
4639
readOnly: true
4740
volumes:
48-
- name: dynamic-clients
41+
- name: pint-config
4942
secret:
50-
secretName: {{ .Values.secrets.radiusConfig }}
43+
secretName: {{ include "pint.secretName.config" . }}
5144
optional: true
52-
- name: radsec-certs
45+
- name: pint-radsec
5346
secret:
54-
secretName: {{ .Values.secrets.radSecCert }}
55-
optional: true
47+
secretName: {{ include "pint.secretName.radSecCert" . }}
5648
defaultMode: 0444
57-
- name: radius-status-config
58-
secret:
59-
secretName: {{ include "pint.freeradiusFullname" . }}-status-config
60-
optional: true
6149
{{- end }}

chart/templates/freeradius-status-secret.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

chart/templates/role.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ rules:
1212
- apiGroups: [""]
1313
resources: ["secrets"]
1414
resourceNames:
15-
- {{ .Values.secrets.radiusClients | quote }}
16-
- {{ .Values.secrets.radiusConfig | quote }}
17-
- {{ .Values.secrets.radSecCert | quote }}
18-
verbs: ["get", "update"]
15+
- {{ include "pint.secretName.config" . | quote }}
16+
- {{ include "pint.secretName.radSecCert" . | quote }}
17+
verbs: ["get", "patch"]
1918
- apiGroups: [""]
2019
resources: ["pods"]
2120
verbs: ["list"]

chart/values.schema.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
},
2525
"envSecret": {
2626
"type": "string",
27-
"description": "Name of the pre-existing Secret containing PINT_CLIENT_SECRET and PINT_IPA_PASSWORD.",
28-
"default": "pint-env"
27+
"description": "Name of the pre-existing Secret containing PINT_CLIENT_SECRET and PINT_IPA_PASSWORD. Defaults to the full release name."
2928
},
3029
"config": {
3130
"type": "object",
@@ -96,22 +95,15 @@
9695
},
9796
"secrets": {
9897
"type": "object",
99-
"description": "Names of the Kubernetes Secrets PINT creates and manages at runtime.",
98+
"description": "Names of the Kubernetes Secrets PINT creates and manages at runtime. All names default to '<fullname>-<suffix>' so multiple releases in the same namespace never collide.",
10099
"properties": {
101-
"radiusClients": {
100+
"config": {
102101
"type": "string",
103-
"description": "Secret storing the RADIUS client list (clients.json).",
104-
"default": "pint-radius-clients"
105-
},
106-
"radiusConfig": {
107-
"type": "string",
108-
"description": "Secret storing the rendered FreeRADIUS clients.conf.",
109-
"default": "pint-radius-config"
102+
"description": "Combined config secret (clients.json, clients.conf, status-secret, status). Defaults to '<fullname>-config'."
110103
},
111104
"radSecCert": {
112105
"type": "string",
113-
"description": "Secret storing the FreeRADIUS TLS certificate and key.",
114-
"default": "pint-radsec-server"
106+
"description": "Secret storing the FreeRADIUS TLS certificate and key. Defaults to '<fullname>-radsec-server-certificates'."
115107
}
116108
}
117109
},

chart/values.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ config:
4343
# PINT_CLIENT_SECRET - OIDC client secret
4444
# PINT_IPA_PASSWORD - FreeIPA service account password
4545
# All other config is rendered into a ConfigMap from the config block above.
46-
envSecret: pint-env
46+
# Defaults to "<fullname>" (i.e. the Helm release name) when left empty.
47+
envSecret: ""
4748

4849
# Names of the K8s Secrets PINT creates and manages at runtime.
4950
# These are referenced consistently across the Role, PINT env vars, and
50-
# FreeRADIUS volume mounts - change all three if you rename them.
51+
# FreeRADIUS volume mounts. All names default to "<fullname>-<suffix>" so
52+
# multiple releases in the same namespace never collide. Override only when
53+
# you need to share a secret between releases.
5154
secrets:
52-
radiusClients: pint-radius-clients
53-
radiusConfig: pint-radius-config
54-
radSecCert: pint-radsec-server
55+
config: "" # default: <fullname>-config (clients.json, clients.conf, status-secret, status)
56+
radSecCert: "" # default: <fullname>-radsec-server-certificates (tls.crt, tls.key, ca.pem, wifi-ca.pem)
5557

5658
service:
5759
type: ClusterIP

0 commit comments

Comments
 (0)