diff --git a/jupyterhub/schema.yaml b/jupyterhub/schema.yaml index 01f00ee26a..8bf1ef7c3a 100644 --- a/jupyterhub/schema.yaml +++ b/jupyterhub/schema.yaml @@ -185,6 +185,16 @@ properties: `{"name": "my-secret-name"}`, or you can let list elements be strings naming the secrets directly. + labels: + type: object + additionalProperties: false + patternProperties: + ".*": + type: string + description: | + Chart wide ability to add specific labels via values.yaml to K8s + objects such as DaemonSets or Deployments + hub: type: object additionalProperties: false diff --git a/jupyterhub/templates/_helpers.tpl b/jupyterhub/templates/_helpers.tpl index 5cc5e6dee1..2eaf4e9d67 100644 --- a/jupyterhub/templates/_helpers.tpl +++ b/jupyterhub/templates/_helpers.tpl @@ -109,6 +109,18 @@ {{- end }} +{{/* +helper function for building up labels key value pairs +*/}} +{{- define "jupyterhub.determinedLabels" -}} + {{- with .Values.labels }} + {{- range $key, $value := . }} +{{ $key }}: {{ $value | quote | trunc 63 | trimSuffix "-" }} + {{- end }} + {{- end }} +{{- end -}} + + {{- /* jupyterhub.commonLabels: Foundation for "jupyterhub.labels". @@ -118,6 +130,7 @@ app: {{ .appLabel | default (include "jupyterhub.appLabel" .) }} release: {{ .Release.Name }} {{- if not .matchLabels }} +{{- include "jupyterhub.determinedLabels" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} heritage: {{ .heritageLabel | default .Release.Service }} {{- end }} diff --git a/jupyterhub/values.yaml b/jupyterhub/values.yaml index 40a6f170c6..63e6272c06 100644 --- a/jupyterhub/values.yaml +++ b/jupyterhub/values.yaml @@ -20,6 +20,10 @@ imagePullSecret: # Helm chart's pods can get credentials from to pull their images. imagePullSecrets: [] +# labels enables an opportunity to add general labels to the created K8s objects, +# e.g. DaemonSets or Deployments +labels: {} + # hub relates to the hub pod, responsible for running JupyterHub, its configured # Authenticator class KubeSpawner, and its configured Proxy class # ConfigurableHTTPProxy. KubeSpawner creates the user pods, and