Skip to content

Commit

Permalink
feat(helm): support tls on datastore
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-pad committed May 20, 2024
1 parent 878444f commit b97853d
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 6 deletions.
4 changes: 4 additions & 0 deletions deploy/charts/burrito/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Datastore Authorized Service Accounts
{{- $server := printf "%s/%s" .Release.Namespace "burrito-server" }}
{{- $datastoreAuthorizedServiceAccounts = append $datastoreAuthorizedServiceAccounts $server }}
{{- $_ := set $config.datastore "serviceAccounts" $datastoreAuthorizedServiceAccounts }}
{{- $_ := set $config.hermitcrab "certificateSecretName" .Values.hermitcrab.tls.certManager.certificate.spec.secretName }}
{{- $_ := set $config.hermitcrab "enabled" .Values.hermitcrab.enabled }}
{{- $_ := set $config.datastore "tls" .Values.datastore.tls.certManager.use }}


apiVersion: v1
kind: ConfigMap
Expand Down
14 changes: 14 additions & 0 deletions deploy/charts/burrito/templates/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ spec:
- name: burrito-token
mountPath: /var/run/secrets/token
readOnly: true
{{- if $.Values.datastore.tls.certManager.use }}
- name: burrito-ca
mountPath: /etc/ssl/certs/burrito-ca.crt
subPath: burrito-ca.crt
readOnly: true
{{- end }}
{{- with .deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -86,6 +92,14 @@ spec:
audience: burrito
expirationSeconds: 3600
path: burrito
{{- if $.Values.datastore.tls.certManager.use }}
- name: burrito-ca
secret:
secretName: {{ $.Values.datastore.tls.certManager.certificate.spec.secretName }}
items:
- key: ca.crt
path: burrito-ca.crt
{{- end }}
{{- if .service.enabled }}
---
apiVersion: v1
Expand Down
21 changes: 21 additions & 0 deletions deploy/charts/burrito/templates/datastore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ spec:
- name: burrito-config
mountPath: /etc/burrito
readOnly: true
{{- if .tls.certManager.use }}
- name: burrito-tls
mountPath: /etc/burrito/tls
readOnly: true
{{- end }}
{{- with .deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -73,6 +78,11 @@ spec:
- name: burrito-config
configMap:
name: burrito-config
{{- if .tls.certManager.use }}
- name: burrito-datastore-tls
secret:
secretName: {{ .tls.certManager.certificate.spec.secretName }}
{{- end }}
{{- if .service.enabled }}
---
apiVersion: v1
Expand Down Expand Up @@ -118,4 +128,15 @@ subjects:
- kind: ServiceAccount
name: burrito-datastore
namespace: {{ $.Release.Namespace }}
---
{{- if .tls.certManager.use }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: burrito-datastore
labels:
{{- toYaml .metadata.labels | nindent 4 }}
spec:
{{- toYaml .tls.certManager.certificate.spec | nindent 4 }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion deploy/charts/burrito/templates/hermitcrab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ spec:
{{- if .tls.certManager.use }}
- name: burrito-hermitcrab-tls
secret:
secretName: {{ $.Values.config.burrito.hermitcrab.certificateSecretName }}
secretName: {{ .tls.certManager.certificate.spec.secretName }}
{{- end }}
{{- if .deployment.extraVolumes }}
{{- toYaml .deployment.extraVolumes | nindent 8 }}
Expand Down
30 changes: 30 additions & 0 deletions deploy/charts/burrito/templates/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: burrito-selfsigned-issuer
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: burrito-ca
spec:
isCA: true
commonName: burrito-ca
secretName: burrito-ca
privateKey:
algorithm: ECDSA
size: 256
issuerRef:
name: burrito-selfsigned-issuer
kind: Issuer
group: cert-manager.io
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: burrito-ca-issuer
spec:
ca:
secretName: burrito-ca
14 changes: 14 additions & 0 deletions deploy/charts/burrito/templates/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ spec:
- name: burrito-token
mountPath: /var/run/secrets/token
readOnly: true
{{- if $.Values.datastore.tls.certManager.use }}
- name: burrito-ca
mountPath: /etc/ssl/certs/burrito-ca.crt
subPath: burrito-ca.crt
readOnly: true
{{- end }}
{{- with .deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -85,6 +91,14 @@ spec:
audience: burrito
expirationSeconds: 3600
path: burrito
{{- if $.Values.datastore.tls.certManager.use }}
- name: burrito-ca
secret:
secretName: {{ $.Values.datastore.tls.certManager.certificate.spec.secretName }}
items:
- key: ca.crt
path: burrito-ca.crt
{{- end }}
{{- if .service.enabled }}
---
apiVersion: v1
Expand Down
30 changes: 25 additions & 5 deletions deploy/charts/burrito/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ config:
# -- Prefer override with the BURRITO_CONTROLLER_GITLABCONFIG_APITOKEN environment variable
apiToken: ""
url: ""
hermitcrab:
enabled: false
certificateSecretName: burrito-hermitcrab-tls

datastore:
serviceAccounts: []
Expand All @@ -67,6 +64,7 @@ config:
sshKnownHostsConfigMapName: burrito-ssh-known-hosts

hermitcrab:
enabled: false
metadata:
labels:
app.kubernetes.io/component: hermitcrab
Expand All @@ -76,9 +74,16 @@ hermitcrab:
size: 1Gi
tls:
certManager:
use: false
use: true
certificate:
spec: {}
spec:
secretName: burrito-hermitcrab-tls
commonName: burrito-hermitcrab.burrito-system.svc.cluster.local
dnsNames:
- burrito-hermitcrab.burrito-system.svc.cluster.local
issuerRef:
name: burrito-ca-issuer
kind: ClusterIssuer

deployment:
image:
Expand Down Expand Up @@ -258,5 +263,20 @@ datastore:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: http
tls:
certManager:
use: false
certificate:
spec:
secretName: burrito-datastore-tls
commonName: burrito-datastore.burrito-system.svc.cluster.local
dnsNames:
- burrito-datastore.burrito-system.svc.cluster.local
issuerRef:
name: burrito-ca-issuer
kind: ClusterIssuer

tenants: []

0 comments on commit b97853d

Please sign in to comment.