Skip to content
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

Funcionality : being able to give an already existing secret as SSL #728

Merged
merged 4 commits into from
Aug 10, 2018
Merged
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
16 changes: 14 additions & 2 deletions jupyterhub/templates/proxy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- $manualHTTPS := (and .Values.proxy.https.enabled (eq .Values.proxy.https.type "manual")) -}}
{{- $manualHTTPSwithsecret := (and .Values.proxy.https.enabled (eq .Values.proxy.https.type "secret")) -}}
apiVersion: apps/v1beta2
kind: Deployment
metadata:
Expand Down Expand Up @@ -44,6 +45,12 @@ spec:
- key: release
operator: In
values: [{{ .Release.Name | quote }}]
{{- if $manualHTTPSwithsecret }}
volumes:
- name: tls-secret
secret:
secretName: {{ .Values.proxy.https.secret.name }}
{{- end }}
{{- if $manualHTTPS }}
volumes:
- name: tls-secret
Expand All @@ -65,13 +72,18 @@ spec:
- --redirect-port=8000
- --ssl-key=/etc/chp/tls/tls.key
- --ssl-cert=/etc/chp/tls/tls.crt
{{- else if $manualHTTPSwithsecret }}
- --port=8443
- --redirect-port=8000
- --ssl-key=/etc/chp/tls/{{ .Values.proxy.https.secret.key }}
- --ssl-cert=/etc/chp/tls/{{ .Values.proxy.https.secret.crt }}
Copy link
Member

Choose a reason for hiding this comment

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

This PR wanted to utilize a pre-existing secret containing a key/crt for TLS. This means that this PR should

  1. Ensure that we can override the secret name.
  2. Ensure we don't create a secret with TLS content any more.

This PR is now overriding the secret name, mounting it etc, but then letting the container utilize the key/crt through command line arguments anyhow. This means that the provided secret mounted is never utilized anyhow.

Note that the secret is made available on line 48-53, and it is mounted to the chp container on line 86.


If a secret is to be provided though, it must have the same keys that we have, which isn't obvious though. @konfiot, what is the structure of the pre-existing secret that you wanted to utilize?

Does it happen to be formatted exactly like this, having tls.crt and tls.key as keys for the secrets data dictionary?

data:
  tls.crt: <base-64-encoded cert>
  tls.key: <base-64-encoded key>

Copy link
Member

Choose a reason for hiding this comment

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

To summarize @konfiot, if you pass the crt / key file anyhow, you could utilize the manual proxy.https.type, and if you want to utilize a preexisting secret, the following lines should reference the files that the secret has mounted in /etc/chp/tls. You must know the files names though, and that depends on what you have named the keys within your pre-existing secrets data dictionary. Every key in the data dictionary will become a file.

{{- else }}
- --port=8000
{{- end }}
{{- if .Values.debug.enabled }}
- --log-level=debug
{{- end }}
{{- if $manualHTTPS }}
{{- if or $manualHTTPS $manualHTTPSwithsecret }}
volumeMounts:
- name: tls-secret
mountPath: /etc/chp/tls
Expand All @@ -87,7 +99,7 @@ spec:
key: proxy.token
imagePullPolicy: {{ .Values.proxy.chp.image.pullPolicy }}
ports:
{{- if $manualHTTPS }}
{{- if or $manualHTTPS $manualHTTPSwithsecret }}
- containerPort: 8443
name: proxy-https
{{- end }}
Expand Down
3 changes: 2 additions & 1 deletion jupyterhub/templates/proxy/netpol.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $HTTPS := (and .Values.proxy.https.hosts .Values.proxy.https.enabled) }}
{{- $autoHTTPS := (and $HTTPS (eq .Values.proxy.https.type "letsencrypt")) }}
{{- $manualHTTPS := (and $HTTPS (eq .Values.proxy.https.type "manual")) }}
{{- $manualHTTPSwithsecret := (and .Values.proxy.https.enabled (eq .Values.proxy.https.type "secret")) -}}
{{- if and .Values.proxy.networkPolicy.enabled -}}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
Expand All @@ -25,7 +26,7 @@ spec:
- protocol: TCP
port: 8000
{{- end }}
{{- if $manualHTTPS }}
{{- if or $manualHTTPS $manualHTTPSwithsecret}}
- protocol: TCP
port: 8443
{{- end }}
Expand Down
3 changes: 2 additions & 1 deletion jupyterhub/templates/proxy/service.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $HTTPS := (and .Values.proxy.https.hosts .Values.proxy.https.enabled) }}
{{- $autoHTTPS := (and $HTTPS (eq .Values.proxy.https.type "letsencrypt")) }}
{{- $manualHTTPS := (and $HTTPS (eq .Values.proxy.https.type "manual")) -}}
{{- $manualHTTPSwithsecret := (and .Values.proxy.https.enabled (eq .Values.proxy.https.type "secret")) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -56,7 +57,7 @@ spec:
- name: https
port: 443
protocol: TCP
{{- if $manualHTTPS }}
{{- if or $manualHTTPS $manualHTTPSwithsecret }}
targetPort: 8443
{{- else }}
targetPort: 443
Expand Down
5 changes: 5 additions & 0 deletions jupyterhub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,16 @@ proxy:
https:
enabled: true
type: letsencrypt
#type: letsencrypt, manual, secret
letsencrypt:
contactEmail: ''
manual:
key:
cert:
secret:
name: ""
key: ""
crt: ""
hosts: []
networkPolicy:
enabled: false
Expand Down