Skip to content

Commit f72ff6c

Browse files
merllj-zimnowoda
andauthored
feat: added support for externally-managed-tls-secret (#1746)
Co-authored-by: Jehoszafat Zimnowoda <[email protected]>
1 parent 6dd3ad7 commit f72ff6c

File tree

8 files changed

+33
-17
lines changed

8 files changed

+33
-17
lines changed

bin/compare.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ helmfile template $templateArgs --output-dir-template="../$targetDirA/{{.Release
2323
git checkout $branchB
2424

2525
# order of arguments matters so new chanages are green color
26-
bin/dyff.sh $targetDirA $targetDirB
26+
echo "Comparing $targetDirB with $targetDirA"
27+
bin/dyff.sh $targetDirB $targetDirA
2728

2829
echo "#########################################################"
2930
echo "#"

charts/team-ns/templates/_ingress.tpl

+2-6
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,11 @@ spec:
125125
- {{ $domain }}
126126
{{- if hasKey $secrets $domain }}
127127
{{- if ne (index $secrets $domain) "" }}
128-
{{/*If a team provides its own certificate in the team namespace then Otomi cornjob makes a copy of it*/}}
128+
{{/*If a team provides its own certificate in the team namespace then Otomi cronjob makes a copy of it*/}}
129129
secretName: copy-team-{{ $v.teamId }}-{{ index $secrets $domain }}
130130
{{- end }}
131131
{{- else }}
132-
{{- if eq $cm.issuer "byo-wildcard-cert" }}
133-
secretName: otomi-byo-wildcard-cert
134-
{{- else }}
135-
secretName: otomi-cert-manager-wildcard-cert
136-
{{- end}}
132+
secretName: {{ $v._derived.tlsSecretName }}
137133
{{- end }}
138134
{{- end }}
139135
{{- end }}

charts/team-ns/templates/ingress/harbor-public.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{{- $cm := index $v.apps "cert-manager" }}
66
{{- $ingress := $v.ingress.platformClass }}
77
{{- $name := printf "nginx-team-%s-platform-public-open-forward-harbor" $v.teamId }}
8-
{{- $secretName := ternary "otomi-byo-wildcard-cert" "otomi-cert-manager-wildcard-cert" (eq $cm.issuer "byo-wildcard-cert") }}
98
---
109
apiVersion: networking.k8s.io/v1
1110
kind: Ingress
@@ -68,6 +67,6 @@ spec:
6867
tls:
6968
- hosts:
7069
- {{ $domain }}
71-
secretName: {{ $secretName }}
70+
secretName: {{ $v._derived.tlsSecretName }}
7271
{{- end }}
7372
{{- end }}

helmfile.d/helmfile-60.teams.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ releases:
231231
domain: {{ $domain }}
232232
ingress: {{- $v.ingress | toYaml | nindent 10 }}
233233
dns: {{- $v.dns | toYaml | nindent 10 }}
234+
_derived:
235+
tlsSecretName: {{ $v._derived.tlsSecretName }}
234236
- {{- omit $team "apps" | toYaml | nindent 8 }}
235237
teamId: {{ $teamId }}
236238
teamIds: {{- toYaml (keys $v.teamConfig) | nindent 10 }}

helmfile.d/snippets/derived.gotmpl

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
{{- $oidcWellKnownUrl := printf "%s/.well-known/openid-configuration" $oidcBaseUrl }}
3030
{{- $oidcBaseUrlBackchannel := "http://keycloak-http.keycloak/realms/otomi" }}
3131
{{- $oidcWellKnownBackchannel := printf "%s/.well-known/openid-configuration" $oidcBaseUrlBackchannel }}
32+
{{- $tlsSecretName := "otomi-cert-manager-wildcard-cert" }}
33+
{{- if eq $cm.issuer "externally-managed-tls-secret" }}
34+
{{- $tlsSecretName = $cm.externallyManagedTlsSecretName }}
35+
{{- else if eq $cm.issuer "byo-wildcard-cert" }}
36+
{{- $tlsSecretName = "byo-wildcard-cert" }}
37+
{{- end -}}
3238

3339
{{- if and (not (env "CI")) (not (env "VALUES_INPUT")) (hasKey $v.cluster "k8sContext") }}
3440
helmDefaults:
@@ -150,6 +156,7 @@ environments:
150156
oidcWellKnownUrlBackchannel: {{ $oidcWellKnownBackchannel}}
151157
giteaDomain: {{ printf "gitea.%s" $domainSuffix }}
152158
keycloakDomain: {{ printf "keycloak.%s" $domainSuffix }}
159+
tlsSecretName: {{ $tlsSecretName }}
153160
apps:
154161
argocd:
155162
enabled: true
+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
apps:
22
cert-manager:
3-
issuer: letsencrypt
4-
5-
stage: staging
3+
# issuer: letsencrypt
4+
5+
# stage: staging
6+
# issuer: custom-ca
7+
issuer: externally-managed-tls-secret
8+
externallyManagedTlsSecretName: mysecret
9+
# issuer: byo-wildcard-cert
10+
# byoWildcardCert: byoCert
11+
# byoWildcardCertKey: byoCertKey

values-schema.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,11 @@ properties:
15291529
description: 'A certificate key corresponding to the byoWildcardCert.'
15301530
type: string
15311531
x-secret: ''
1532+
externallyManagedTlsSecretName:
1533+
description: |
1534+
The name of a custom secret in the istio-system namespace that contains a trusted certificate and private key.
1535+
To be used with issuer externally-managed-tls-secret.
1536+
type: string
15321537
customRootCA:
15331538
x-secret: ''
15341539
type: string
@@ -1545,11 +1550,15 @@ properties:
15451550
The custom-ca - cert-manager uses the customRootCA to generate wildcard certificate.
15461551
The letsencrypt - cert-manager requests certificate from letsencrypt endpoint.
15471552
The byo-wildcard-cert allows users to bring their own trusted wildcard certificate (cert-manager not involved)
1553+
through the values byoWildcardCert and byoWildcardCertKey.
1554+
The externally-managed-tls-secret is similar to byo-wildcard-cert, but assumes the certificate is already stored
1555+
in a secret (referenced by externallyManagedTlsSecretName) and not provided through the values.
15481556
type: string
15491557
enum:
15501558
- custom-ca
15511559
- letsencrypt
15521560
- byo-wildcard-cert
1561+
- externally-managed-tls-secret
15531562
default: custom-ca
15541563
stage:
15551564
type: string

values/oauth2-proxy/oauth2-proxy-raw.gotmpl

+1-5
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ resources:
4343
path: /
4444
pathType: Prefix
4545
tls:
46-
{{- if eq $cm.issuer "byo-wildcard-cert" }}
47-
- secretName: "otomi-byo-wildcard-cert"
48-
{{- else }}
49-
- secretName: otomi-cert-manager-wildcard-cert
50-
{{- end }}
46+
- secretName: {{ $v._derived.tlsSecretName }}
5147
hosts:
5248
- '{{ $domain }}'

0 commit comments

Comments
 (0)