Skip to content

Commit c557002

Browse files
authored
feat(chart): add ability to mount custom certs (#395)
* feat(chart): add ability to mount custom certs * quote volume mount variables * add configmap with embedded cert * fix(templates): validate certificate fields and ensure accurate ConfigMap creation logic * refactor(helm): simplify certificate configuration and clean up unused fields in values and templates * fix: update configMap naming to include deployment-operator fullname prefix
1 parent 47f8a21 commit c557002

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine3.20 AS builder
1+
FROM golang:1.23-alpine3.21 AS builder
22

33
ARG TARGETARCH
44

@@ -19,7 +19,7 @@ COPY /internal internal/
1919
# Build
2020
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o deployment-agent cmd/agent/*.go
2121

22-
FROM alpine:3.20
22+
FROM alpine:3.21
2323
WORKDIR /workspace
2424

2525
RUN mkdir /.kube && chown 65532:65532 /.kube

charts/deployment-operator/templates/configmap.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@ metadata:
88
data:
99
ca.crt: {{ .Values.agentk.config.caCert | quote }}
1010
{{- end }}
11+
12+
13+
{{- range $cert := .Values.certs }}
14+
---
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: {{ include "deployment-operator.fullname" $ }}-{{ $cert.name }}
19+
labels:
20+
{{- include "deployment-operator.labels" $ | nindent 4 }}
21+
data:
22+
{{ $cert.file }}: {{ $cert.data | quote }}
23+
{{- end }}

charts/deployment-operator/templates/deployment.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ spec:
6363
volumeMounts:
6464
- name: temp
6565
mountPath: /tmp
66+
{{- range $cert := .Values.certs }}
67+
- name: {{ $cert.name }}
68+
mountPath: "/etc/ssl/certs/{{ $cert.file }}"
69+
subPath: "{{ $cert.file }}"
70+
{{- end }}
6671
{{ if .Values.additionalVolumeMounts }}
6772
{{ toYaml .Values.additionalVolumeMounts | nindent 12 }}
6873
{{ end }}
@@ -171,6 +176,11 @@ spec:
171176
defaultMode: 0444
172177
name: {{ include "deployment-operator.fullname" . }}
173178
{{- end }}
179+
{{- range $cert := .Values.certs }}
180+
- name: {{ $cert.name }}
181+
configMap:
182+
name: {{ include "deployment-operator.fullname" $ }}-{{ $cert.name }}
183+
{{- end }}
174184
{{ if .Values.additionalVolumes }}
175185
{{ toYaml .Values.additionalVolumes | nindent 8 }}
176186
{{ end }}

charts/deployment-operator/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
additionalVolumes: ~
66
additionalVolumeMounts: ~
77

8+
# Allows mounting custom certs to deployment operator.
9+
# Certificates are mounted to the "/etc/ssl/certs" directory.
10+
# An array of files can be provided. Every file will be mounted
11+
# on a specific subpath to ensure that multiple files can be mounted
12+
# without overriding each other.
13+
#
14+
# In order to override default "ca-certificates.crt" simply
15+
# provide a "file: ca-certificates.crt" when providing custom certs.
16+
# It will be mounted on a subpath to override only this single file.
17+
#
18+
# Example usage:
19+
# - name: ca-pemstore
20+
# data: xyz
21+
# file: my-cert.pem
22+
certs: []
23+
824
replicaCount: 1
925

1026
livenessProbe:

0 commit comments

Comments
 (0)