-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to pass registry credentials to build pods' docker clients
- Loading branch information
1 parent
ec68830
commit 80906fd
Showing
7 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
binderhub-service/templates/build-pods-docker-config/secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This Secret is mounted by BinderHub's managed build pods because | ||
# c.KubernetesBuildExecutor.push_secret is configured with this Secret's name. | ||
# | ||
# IMPORTANT: This is _not_ a Kubernetes imagePullSecrets formatted Secret, it | ||
# instead provides a config file for a docker client. | ||
# | ||
kind: Secret | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ include "binderhub-service.fullname" . }}-build-pods-docker-config | ||
labels: | ||
{{- include "binderhub-service.labels" . | nindent 4 }} | ||
type: Opaque | ||
stringData: | ||
# config.json refers to docker config that should house credentials for the | ||
# docker client in a build pod to use against the docker-api. | ||
# | ||
# Docker's config.json expects something like below, where the xx...xx= string | ||
# is "<username>:<password>" base64 encoded. | ||
# | ||
# { | ||
# "auths": { | ||
# "https://index.docker.io/v1/": { | ||
# "auth": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" | ||
# } | ||
# } | ||
# } | ||
# | ||
# ref: https://github.com/jupyterhub/binderhub/blob/79c5f61a992010f108637e3c434d9e606a3c8f72/binderhub/build.py#L397-L406 | ||
# | ||
{{- /* initialize a dict to represent a docker client config */}} | ||
{{- $dockerConfig := dict }} | ||
|
||
{{- $server := .Values.buildPodsRegistryCredentials.server }} | ||
{{- $username := .Values.buildPodsRegistryCredentials.username }} | ||
{{- $password := .Values.buildPodsRegistryCredentials.password }} | ||
{{- $blob := printf "%s:%s" $username $password | b64enc }} | ||
{{- $credentials := dict "auths" (dict $server (dict "auth" $blob)) }} | ||
|
||
{{- /* merge docker client config with registry credentials */}} | ||
{{- if .Values.config.BinderHub.use_registry }} | ||
{{- $dockerConfig = merge $dockerConfig $credentials }} | ||
{{- end }} | ||
|
||
{{- /* merge docker client config of any kind */}} | ||
{{- if .Values.buildPodsDockerConfig }} | ||
{{- $dockerConfig = merge $dockerConfig .Values.buildPodsDockerConfig }} | ||
{{- end }} | ||
config.json: | | ||
{{- $dockerConfig | toPrettyJson | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# FIXME: When running tests, we will need a local container registry to test | ||
# pushing images to that can be reached from the build pods. | ||
# | ||
config: | ||
BinderHub: | ||
use_registry: false | ||
image_prefix: localhost/binderhub-service/ | ||
buildPodsRegistryCredentials: | ||
server: "localhost" | ||
username: "dummy-username" | ||
password: "dummy-password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters