Skip to content

Commit b3d8bcd

Browse files
committed
add certmanager support
1 parent 2be1fad commit b3d8bcd

File tree

4 files changed

+101
-2
lines changed

4 files changed

+101
-2
lines changed

Diff for: helm/postgres/templates/_helpers.tpl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- define "certmanager.prefix" -}}
2+
{{- default .Release.Name .Values.name -}}
3+
{{- end -}}

Diff for: helm/postgres/templates/certs.yaml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{- if .Values.certmanager }}
2+
{{- $prefix := (include "certmanager.prefix" .) -}}
3+
{{ $organisation := printf "%s-org" $prefix -}}
4+
apiVersion: cert-manager.io/v1
5+
kind: Certificate
6+
metadata:
7+
name: {{ $prefix -}}-certmanager
8+
spec:
9+
# Secret names are always required.
10+
secretName: "{{- $prefix -}}-tls"
11+
duration: 2160h # 90d
12+
renewBefore: 360h # 15d
13+
subject:
14+
organizations:
15+
- "{{ .Values.certmanager.org | default $organisation -}}"
16+
# The use of the common name field has been deprecated since 2000 and is
17+
# discouraged from being used.
18+
commonName: {{ $prefix }}-primary
19+
isCA: false
20+
privateKey:
21+
algorithm: ECDSA
22+
size: 256
23+
usages:
24+
- digital signature
25+
- key encipherment
26+
# At least one of a DNS Name, URI, or IP address is required.
27+
dnsNames:
28+
- {{ $prefix }}-primary
29+
- {{ $prefix }}-primary.postgres-operator
30+
- {{ $prefix }}-primary.postgres-operator.svc
31+
- {{ $prefix }}-primary.postgres-operator.svc.cluster.local
32+
issuerRef:
33+
name: {{ required ".certmanager.issuerName reqired" .Values.certmanager.issuerName }}
34+
{{ if .Values.certmanager.issuerKind -}} kind: {{ .Values.certmanager.issuerKind }}
35+
{{ end -}}
36+
{{ if .Values.certmanager.issuerGroup -}} group: {{ .Values.certmanager.issuerGroup }}
37+
{{- end }}
38+
---
39+
apiVersion: cert-manager.io/v1
40+
kind: Certificate
41+
metadata:
42+
name: {{ $prefix }}-repl-certmanager
43+
spec:
44+
# Secret names are always required.
45+
secretName: {{ $prefix }}-repl-tls
46+
duration: 2160h # 90d
47+
renewBefore: 360h # 15d
48+
subject:
49+
organizations:
50+
- "{{ .Values.certmanager.org | default $organisation -}}"
51+
# The use of the common name field has been deprecated since 2000 and is
52+
# discouraged from being used.
53+
commonName: _crunchyrepl
54+
isCA: false
55+
privateKey:
56+
algorithm: ECDSA
57+
size: 256
58+
usages:
59+
- digital signature
60+
- key encipherment
61+
# At least one of a DNS Name, URI, or IP address is required.
62+
dnsNames:
63+
- _crunchyrepl
64+
issuerRef:
65+
name: {{ required ".certmanager.issuerName reqired" .Values.certmanager.issuerName }}
66+
{{ if .Values.certmanager.issuerKind -}} kind: {{ .Values.certmanager.issuerKind }}
67+
{{ end -}}
68+
{{ if .Values.certmanager.issuerGroup -}} group: {{ .Values.certmanager.issuerGroup }}
69+
{{- end }}
70+
{{- end }}

Diff for: helm/postgres/templates/postgres.yaml

+15-2
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,24 @@ spec:
204204
{{- else if eq .Values.openshift false }}
205205
openshift: false
206206
{{- end }}
207-
{{- if .Values.customTLSSecret }}
207+
{{- $certmanagerEnable := default false .Values.certmanager -}}
208+
{{- if or .Values.customTLSSecret .Values.certmanager }}
208209
customTLSSecret:
210+
{{- if .Values.customTLSSecret }}
209211
{{ toYaml .Values.customTLSSecret | indent 4 }}
212+
{{- else }}
213+
{{- $prefix := (include "certmanager.prefix" .) }}
214+
{{- $tlsSecret := printf "%s-tls" $prefix }}
215+
name: {{ $tlsSecret }}
210216
{{- end }}
211-
{{- if .Values.customReplicationTLSSecret }}
217+
{{- end }}
218+
{{- if or .Values.customTLSSecret .Values.certmanager }}
212219
customReplicationTLSSecret:
220+
{{- if .Values.customReplicationTLSSecret }}
213221
{{ toYaml .Values.customReplicationTLSSecret | indent 4 }}
222+
{{- else }}
223+
{{- $prefix := (include "certmanager.prefix" .) }}
224+
{{- $tlsSecret := printf "%s-repl-tls" $prefix }}
225+
name: {{ $tlsSecret }}
226+
{{- end }}
214227
{{- end }}

Diff for: helm/postgres/values.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ postgresVersion: 16
149149
# provides the information for the replication user.
150150
# customReplicationTLSSecret: {}
151151

152+
# certmanagerto generate required certificates
153+
# issuerName according to your certmanager setup must be set
154+
# customTLSSecret and customReplicationTLSSecret will overwrite certmanager certificates
155+
# Optional:
156+
# set org otherwise it default to "<.resource.name>-org"
157+
# overwrite issuerKind e.g. to ClusterIssuer if not using the Issuer in the namespace
158+
# overwrite issuerGroup if needed by you issuer
159+
# certmanager:
160+
# issuerName: <must be configured>
161+
# org: "hippo-org"
162+
# issuerKind: ClusterIssuer
163+
# issuerGroup: cert-manager.io
164+
152165
# databaseInitSQL references a ConfigMap that contains a SQL file that should be
153166
# run a cluster bootstrap.
154167
# databaseInitSQL:

0 commit comments

Comments
 (0)