Skip to content

Commit

Permalink
Support running multiple instances on same cluster
Browse files Browse the repository at this point in the history
Without this parameterization, all installations try to use
the same hostPath paths and everything except 1 fails
  • Loading branch information
yuvipanda committed Jan 17, 2024
1 parent 1b269d5 commit 981989c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions binderhub-service/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ spec:
env:
- name: HELM_DEPLOYMENT_NAME
value: {{ include "binderhub-service.fullname" . }}
# Namespace build pods should be placed in
- name: BUILD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# Namespace the binderhub pod is running in
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
{{- .Values.resources | toYaml | nindent 12 }}
securityContext:
Expand Down
14 changes: 7 additions & 7 deletions binderhub-service/templates/docker-api/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ spec:
image: {{ .Values.dockerApi.image.repository }}:{{ .Values.dockerApi.image.tag }}
args:
- dockerd
- --data-root=/var/lib/docker-api
- --exec-root=/var/run/docker-api
- --host=unix:///var/run/docker-api/docker-api.sock
- --data-root=/var/lib/{{ .Release.Namespace }}-{{ .Release.Name }}/docker-api
- --exec-root=/var/run/{{ .Release.Namespace }}-{{ .Release.Name }}/docker-api
- --host=unix:///var/run/{{ .Release.Namespace}}-{{ .Release.Name }}/docker-api/docker-api.sock
{{- with .Values.dockerApi.extraArgs }}
{{- . | toYaml | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: /var/lib/docker-api
mountPath: /var/lib/{{ .Release.Namespace }}-{{ .Release.Name }} /docker-api
- name: exec
mountPath: /var/run/docker-api
mountPath: /var/run/{{ .Release.Namespace }}-{{ .Release.Name }}/docker-api
{{- range $file_key, $file_details := .Values.dockerApi.extraFiles }}
- name: files
mountPath: {{ $file_details.mountPath }}
Expand All @@ -48,11 +48,11 @@ spec:
volumes:
- name: data
hostPath:
path: /var/lib/docker-api
path: /var/lib/{{ .Release.Namespace }}-{{ .Release.Name }}/docker-api
type: DirectoryOrCreate
- name: exec
hostPath:
path: /var/run/docker-api
path: /var/run/{{ .Release.Namespace}}-{{ .Release.Name }}/docker-api
type: DirectoryOrCreate
{{- if .Values.dockerApi.extraFiles }}
- name: files
Expand Down
13 changes: 8 additions & 5 deletions binderhub-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ config:
base_url: /
port: 8585
enable_api_only_mode: true
KubernetesBuildExecutor:
# docker_host must not be updated, assumptions about it are hardcoded in
# docker-api/daemonset.yaml
docker_host: /var/run/docker-api/docker-api.sock
extraConfig:
# binderhub-service creates a k8s Secret with a docker config.json file
# including registry credentials.
binderhub_service_00_build_pods_docker_config: |
binderhub-service-01-build-pods-docker-config: |
import os
helm_deployment_name = os.environ["HELM_DEPLOYMENT_NAME"]
c.KubernetesBuildExecutor.push_secret = f"{helm_deployment_name}-build-pods-docker-config"
binderhub-service-02-set-docker-api: |
import os
helm_deployment_name = os.environ["HELM_DEPLOYMENT_NAME"]
namespace = os.environ["NAMESPACE"]
c.KubernetesBuildExecutor.docker_host = f"/var/lib/{ namespace }/{ helm_deployment_name }/docker-api/docker-api.sock"
replicas: 1
image:
repository: quay.io/2i2c/binderhub-service
Expand Down

0 comments on commit 981989c

Please sign in to comment.