Skip to content

Commit

Permalink
imagePullSecrets: add switch for imagePullSecret.automaticReferenceIn…
Browse files Browse the repository at this point in the history
…jection
  • Loading branch information
consideRatio committed Oct 9, 2020
1 parent 8bdd2c9 commit 3115053
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion jupyterhub/files/hub/jupyterhub_config.py
Expand Up @@ -166,7 +166,9 @@ def camelCaseify(s):
# Combine imagePullSecret.create (single), imagePullSecrets (list), and
# singleuser.image.pullSecrets (list).
image_pull_secrets = []
if get_config('imagePullSecret.create') or get_config('imagePullSecret.enabled'):
if get_config("imagePullSecret.automaticReferenceInjection") and (
get_config("imagePullSecret.create") or get_config("imagePullSecret.enabled")
):
image_pull_secrets.append('image-registry-credentials')
if get_config('imagePullSecrets'):
image_pull_secrets.extend(get_config('imagePullSecrets'))
Expand Down
5 changes: 5 additions & 0 deletions jupyterhub/schema.yaml
Expand Up @@ -39,6 +39,11 @@ properties:
description: |
Toggle the creation of the k8s Secret with provided credentials to
access a private image registry.
automaticReferenceInjection:
type: boolean
description: |
Toggle the automatic reference injection of the created Secret to all
pods' `spec.imagePullSecrets` configuration.
registry:
type: string
description: |
Expand Down
2 changes: 1 addition & 1 deletion jupyterhub/templates/_helpers.tpl
Expand Up @@ -200,7 +200,7 @@ component: {{ include "jupyterhub.componentLabel" . }}
{{- define "jupyterhub.imagePullSecrets" -}}
{{- /* Populate $_.list with all relevant entries */}}
{{- $_ := dict "list" (concat .image.pullSecrets .root.Values.imagePullSecrets | uniq) }}
{{- if .root.Values.imagePullSecret.create }}
{{- if and .root.Values.imagePullSecret.automaticReferenceInjection .root.Values.imagePullSecret.create }}
{{- $__ := set $_ "list" (append $_.list "image-registry-credentials" | uniq) }}
{{- end }}

Expand Down
1 change: 1 addition & 0 deletions jupyterhub/values.yaml
Expand Up @@ -4,6 +4,7 @@ custom: {}
# can get credentials from to pull their images.
imagePullSecret:
create: false
automaticReferenceInjection: true
registry: ''
username: ''
email: ''
Expand Down
1 change: 1 addition & 0 deletions tools/templates/lint-and-validate-values.yaml
@@ -1,5 +1,6 @@
imagePullSecret:
create: true
automaticReferenceInjection: true
registry: R
username: U
email: e@domain.com
Expand Down

0 comments on commit 3115053

Please sign in to comment.