Skip to content

Support custom CA certificates in Helm #2984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,16 @@ storage:
{{ toYaml .remoteStorage | indent 2 }}
{{- end -}}
{{- end -}}

{{/* custom ca bundle volume and volumeMount */}}
{{- define "gitpod.caBundleVolume" -}}
- name: ca-bundle-certs
secret:
secretName: {{ .Values.caBundleSecretName }}
{{- end -}}

{{- define "gitpod.caBundleVolumeMount" -}}
- name: ca-bundle-certs
mountPath: /etc/ssl/certs/ca-certificates.crt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about mounting just the root CA with a unique name (e.g. ca-cert-gitpod.crt) in the folder /etc/ssl/certs/ instead of the full ca-certificates.crt (addresses the comments #2984 (comment) and #2984 (comment))?

Suggested change
mountPath: /etc/ssl/certs/ca-certificates.crt
mountPath: /etc/ssl/certs/ca-cert-gitpod.crt

Then, you don't need to run update-ca-certificates on a local Linux and can add your root CA directly. In my tests, that works pretty fine.

subPath: ca-certificates.crt
{{- end -}}
6 changes: 6 additions & 0 deletions chart/templates/blobserve-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ spec:
mountPath: /mnt/pull-secret.json
subPath: .dockerconfigjson
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolumeMount" . | indent 8 }}
{{- end }}
volumes:
- name: cache
emptyDir: {}
Expand All @@ -80,5 +83,8 @@ spec:
secret:
secretName: {{ .Values.components.workspace.pullSecret.secretName }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolume" . | indent 6 }}
{{- end }}
{{ toYaml .Values.defaults | indent 6 }}
{{ end }}
6 changes: 6 additions & 0 deletions chart/templates/image-builder-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ spec:
secret:
secretName: {{ $sec.secret }}
{{- end }}
{{- if .Values.caBundleSecretName }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #2984 (comment) by another user, this does not work for me too but need to be this:

Suggested change
{{- if .Values.caBundleSecretName }}
{{- if $.Values.caBundleSecretName }}

{{ include "gitpod.caBundleVolume" . | indent 6 }}
{{- end }}
containers:
- name: dind
image: {{ $comp.dindImage | default "docker:19.03-dind" }}
Expand All @@ -78,6 +81,9 @@ spec:
{{- range $idx, $sec := $comp.registryCerts }}
- mountPath: /etc/docker/certs.d/{{- if eq $sec.name "builtin" -}}{{ template "gitpod.builtinRegistry.name" $this.root }}{{ else }}{{ $sec.name }}{{ end }}
name: docker-tls-certs-{{ $idx }}
{{- if .Values.caBundleSecretName }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (#2984 (comment))

Suggested change
{{- if .Values.caBundleSecretName }}
{{- if $.Values.caBundleSecretName }}

{{ include "gitpod.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{- end }}
{{- if $comp.dindResources }}
resources:
Expand Down
6 changes: 6 additions & 0 deletions chart/templates/registry-facade-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ spec:
- name: https-certificates
mountPath: "/mnt/certificates"
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolumeMount" . | indent 8 }}
{{- end }}
volumes:
- name: cache
emptyDir: {}
Expand Down Expand Up @@ -132,5 +135,8 @@ spec:
path: privkey.pem
{{- end }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolume" . | indent 6 }}
{{- end }}
{{ toYaml .Values.defaults | indent 6 }}
{{ end }}
10 changes: 10 additions & 0 deletions chart/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
{{- if $comp.serverContainer.volumeMounts }}
{{ toYaml $comp.serverContainer.volumeMounts | indent 8 }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolumeMount" . | indent 8 }}
{{- end }}
{{ include "gitpod.container.defaultEnv" $this | indent 8 }}
{{ include "gitpod.container.dbEnv" $this | indent 8 }}
{{ include "gitpod.container.tracingEnv" $this | indent 8 }}
Expand Down Expand Up @@ -213,6 +216,10 @@ spec:
value: {{ $comp.garbageCollection.disabled | default "false" | quote }}
{{- if $comp.serverContainer.env }}
{{ toYaml $comp.serverContainer.env | indent 8 }}
{{- end }}
{{- if .Values.caBundleSecretName }}
- name: NODE_EXTRA_CA_CERTS
value: /etc/ssl/certs/ca-certificates.crt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change the cert name in the _helper.tpl file (see above) we need to change it here as well, right?

Suggested change
value: /etc/ssl/certs/ca-certificates.crt
value: /etc/ssl/certs/ca-cert-gitpod.crt

{{- end }}
volumes:
{{- if $comp.storage.secretName }}
Expand All @@ -228,5 +235,8 @@ spec:
{{- if $comp.volumes }}
{{ toYaml $comp.volumes | indent 6 }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolume" . | indent 6 }}
{{- end }}
{{ toYaml .Values.defaults | indent 6 }}
{{ end }}
6 changes: 6 additions & 0 deletions chart/templates/ws-daemon-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ spec:
{{- if $comp.volumes }}
{{ toYaml $comp.volumes | indent 6 }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolume" . | indent 6 }}
{{- end }}
{{- if (or $comp.userNamespaces.shiftfsModuleLoader.enabled $comp.userNamespaces.seccompProfileInstaller.enabled) }}
initContainers:
{{- end }}
Expand Down Expand Up @@ -155,6 +158,9 @@ spec:
name: tls-certs
{{- if $comp.volumeMounts }}
{{ toYaml $comp.volumeMounts | indent 8 }}
{{- end }}
{{- if .Values.caBundleSecretName }}
{{ include "gitpod.caBundleVolumeMount" . | indent 8 }}
{{- end }}
args: ["run", "-v", "--config", "/config/config.json"]
image: {{ template "gitpod.comp.imageFull" $this }}
Expand Down