From 820e11b3e9dc4c662b5a96b0f929e00600eb2c06 Mon Sep 17 00:00:00 2001 From: Martynov Maxim Date: Fri, 14 Oct 2022 17:46:29 +0300 Subject: [PATCH] Allow to disable proxy pod and service creation --- jupyterhub/schema.yaml | 6 ++++++ jupyterhub/templates/NOTES.txt | 6 ++++++ jupyterhub/templates/proxy/deployment.yaml | 3 +++ jupyterhub/templates/proxy/service.yaml | 15 +++++++++------ jupyterhub/values.yaml | 1 + tools/templates/lint-and-validate-values.yaml | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/jupyterhub/schema.yaml b/jupyterhub/schema.yaml index 01f00ee26a..183c0248ba 100644 --- a/jupyterhub/schema.yaml +++ b/jupyterhub/schema.yaml @@ -1446,6 +1446,12 @@ properties: type: object additionalProperties: false properties: + enabled: + type: boolean + description: | + Default `true`. + + If `false`, disables proxy pod and service creation. Can be used with some existing external proxy, or with kubespawner.proxy.KubeIngressProxy class chp: type: object additionalProperties: false diff --git a/jupyterhub/templates/NOTES.txt b/jupyterhub/templates/NOTES.txt index e9a4edfcd4..bb2014308c 100644 --- a/jupyterhub/templates/NOTES.txt +++ b/jupyterhub/templates/NOTES.txt @@ -40,6 +40,7 @@ kubectl --namespace={{ .Release.Namespace }} logs --previous {{- println }} + {{- if .Values.proxy.enabled }} {{- if eq .Values.proxy.service.type "LoadBalancer" }} - Verify an external IP is provided for the k8s Service {{ $proxy_service }}. @@ -84,6 +85,11 @@ Try insecure HTTP access: http://localhost:8080 {{- end }} + {{- end }} + You disabled proxy pod and service creation. This means that your proxy should be set up manually. + + Please follow documentation of + current proxy class (see c.Jupyterhub.proxy_class setting), e.g. KubeIngressProxy {{- end }} {{- println }} diff --git a/jupyterhub/templates/proxy/deployment.yaml b/jupyterhub/templates/proxy/deployment.yaml index 2b35382446..332c594f4b 100644 --- a/jupyterhub/templates/proxy/deployment.yaml +++ b/jupyterhub/templates/proxy/deployment.yaml @@ -1,3 +1,5 @@ +{{- $enabled := .Values.proxy.enabled -}} +{{- if $enabled }} {{- $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/v1 @@ -176,3 +178,4 @@ spec: {{- with .Values.proxy.chp.extraPodSpec }} {{- . | toYaml | nindent 6 }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/jupyterhub/templates/proxy/service.yaml b/jupyterhub/templates/proxy/service.yaml index 8a96eb135c..2fd07e2101 100644 --- a/jupyterhub/templates/proxy/service.yaml +++ b/jupyterhub/templates/proxy/service.yaml @@ -1,10 +1,12 @@ -{{- $enabled := .Values.proxy.https.enabled -}} -{{- $autoHTTPS := and $enabled (and (eq .Values.proxy.https.type "letsencrypt") .Values.proxy.https.hosts) -}} -{{- $manualHTTPS := and $enabled (eq .Values.proxy.https.type "manual") -}} -{{- $manualHTTPSwithsecret := and $enabled (eq .Values.proxy.https.type "secret") -}} -{{- $offloadHTTPS := and $enabled (eq .Values.proxy.https.type "offload") -}} +{{- $enabled := .Values.proxy.enabled -}} +{{- if $enabled }} +{{- $httpsEnabled := .Values.proxy.https.enabled -}} +{{- $autoHTTPS := and $httpsEnabled (and (eq .Values.proxy.https.type "letsencrypt") .Values.proxy.https.hosts) -}} +{{- $manualHTTPS := and $httpsEnabled (eq .Values.proxy.https.type "manual") -}} +{{- $manualHTTPSwithsecret := and $httpsEnabled (eq .Values.proxy.https.type "secret") -}} +{{- $offloadHTTPS := and $httpsEnabled (eq .Values.proxy.https.type "offload") -}} {{- $valid := or $autoHTTPS (or $manualHTTPS (or $manualHTTPSwithsecret $offloadHTTPS)) -}} -{{- $HTTPS := and $enabled $valid -}} +{{- $HTTPS := and $httpsEnabled $valid -}} apiVersion: v1 kind: Service metadata: @@ -78,3 +80,4 @@ spec: {{- . | toYaml | nindent 4 }} {{- end }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/jupyterhub/values.yaml b/jupyterhub/values.yaml index 147c3f6db7..ad249a262e 100644 --- a/jupyterhub/values.yaml +++ b/jupyterhub/values.yaml @@ -145,6 +145,7 @@ rbac: # proxy relates to the proxy pod, the proxy-public service, and the autohttps # pod and proxy-http service. proxy: + enabled: true secretToken: annotations: {} deploymentStrategy: diff --git a/tools/templates/lint-and-validate-values.yaml b/tools/templates/lint-and-validate-values.yaml index 4dda6ce095..1c0d44b1f4 100644 --- a/tools/templates/lint-and-validate-values.yaml +++ b/tools/templates/lint-and-validate-values.yaml @@ -210,6 +210,7 @@ rbac: create: true proxy: + enabled: true service: extraPorts: - name: ssh