Skip to content

Commit

Permalink
improve: create infra-server-ca secret
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 29, 2022
1 parent 4dfd974 commit b7b5ecd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test/update:
go test ./internal/cmd -test.update-golden

dev:
docker build . -t infrahq/infra:dev
docker buildx build . -t infrahq/infra:dev
kubectl config use-context docker-desktop
helm upgrade --install --wait \
--set global.image.pullPolicy=Never \
Expand Down
6 changes: 6 additions & 0 deletions helm/charts/infra/templates/server/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ data:
{{- end }}
{{- end }}

{{- if (not .Values.server.config.tls) }}
tls:
ca: "/var/run/secrets/infrahq.com/tls-ca/ca.crt"
caPrivateKey: "file:/var/run/secrets/infrahq.com/tls-ca/ca.key"
{{- end }}

providers:
{{- .Values.server.additionalProviders | default list | concat .Values.server.config.providers | uniq | toYaml | nindent 6 }}

Expand Down
9 changes: 9 additions & 0 deletions helm/charts/infra/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ spec:
- name: conf
mountPath: /etc/infrahq
readOnly: true
{{- if (not .Values.server.config.tls) }}
- name: tls-ca
mountPath: /var/run/secrets/infrahq.com/tls-ca
{{- end }}
{{- if .Values.server.persistence.enabled }}
- name: data
mountPath: /var/lib/infrahq/server
Expand Down Expand Up @@ -89,6 +93,11 @@ spec:
- name: conf
configMap:
name: {{ include "server.fullname" . }}
{{- if (not .Values.server.config.tls) }}
- name: tls-ca
secret:
secretName: {{ include "server.fullname" . }}-ca
{{- end }}
{{- if .Values.server.persistence.enabled }}
- name: data
persistentVolumeClaim:
Expand Down
29 changes: 29 additions & 0 deletions helm/charts/infra/templates/server/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{- if include "server.enabled" . | eq "true" }}
{{- if (not .Values.server.config.tls) }}
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-ca" (include "server.fullname" .)) -}}

apiVersion: v1
kind: Secret
metadata:
name: {{ include "server.fullname" . }}-ca
labels:
{{- include "server.labels" . | nindent 4 }}
stringData:

{{- if $secret.data }}
ca.crt: |
{{- get $secret.data "ca.crt" | b64dec | nindent 4 }}
ca.key: |
{{- get $secret.data "ca.key" | b64dec | nindent 4 }}

{{- else }}
{{- $ca := genCA "Infra Server" 3650 }}
ca.crt: |
{{- $ca.Cert | nindent 4 }}
ca.key: |
{{- $ca.Key | nindent 4 }}

{{- end }}{{/* if secret.data */}}
{{- end }}{{/* if not tls */}}
{{- end }}{{/* if server.enabled */}}
4 changes: 4 additions & 0 deletions helm/charts/infra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ server:
# - name: [email protected]
# password: file:/var/run/secrets/[email protected]

# TLS configuration for the API server. Defaults to generating a self-signed CA and
# generating certificates from that CA.
tls: {}

## Default connector configurations
connector:

Expand Down

0 comments on commit b7b5ecd

Please sign in to comment.