Skip to content

Commit

Permalink
Binderhub name overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
noroutine committed Mar 30, 2023
1 parent 2875708 commit 4e1d94d
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 36 deletions.
6 changes: 6 additions & 0 deletions helm-chart/binderhub/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: jupyterhub
repository: https://jupyterhub.github.io/helm-chart
version: 1.1.2
digest: sha256:835ec3cb8d252ccae5136aeea1efc9fcb88a980d59280af1a6521a3b83011d80
generated: "2022-01-11T11:22:16.905033+01:00"
6 changes: 6 additions & 0 deletions helm-chart/binderhub/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ required:
- podAnnotations
- global
properties:

fullnameOverride:
type: [string, "null"]
description: |
Release name override
pdb: &pdb-spec
type: object
additionalProperties: false
Expand Down
34 changes: 34 additions & 0 deletions helm-chart/binderhub/templates/_helpers-names.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- /*
Utility templates
*/}}

{{- /*
Renders to a prefix for the chart's resource names. This prefix is assumed to
make the resource name cluster unique.
*/}}
{{- define "binderhub.fullname" -}}
{{- $fullname_override := .Values.fullnameOverride }}
{{- $name_override := .Values.nameOverride }}
{{- if eq (typeOf $fullname_override) "string" }}
{{- $fullname_override }}
{{- else }}
{{- $name := $name_override | default .Chart.Name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name }}
{{- else }}
{{- .Release.Name }}-{{ $name }}
{{- end }}
{{- end }}
{{- end }}
{{- /*
Renders to a blank string or if the fullname template is truthy renders to it
with an appended dash.
*/}}
{{- define "binderhub.fullname.dash" -}}
{{- if (include "binderhub.fullname" .) }}
{{- include "binderhub.fullname" . }}-
{{- end }}
{{- end }}
54 changes: 54 additions & 0 deletions helm-chart/binderhub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,57 @@ Render docker config.json for the registry-publishing secret and other docker co

{{- $dockerConfig | toPrettyJson }}
{{- end }}

{{- /*
binderhub.appLabel:
Used by "binderhub.labels".
*/}}
{{- define "binderhub.appLabel" -}}
{{ .Values.nameOverride | default .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- /*
binderhub.commonLabels:
Foundation for "binderhub.labels".
Provides labels: app, release, (chart and heritage).
*/}}
{{- define "binderhub.commonLabels" -}}
app: {{ .appLabel | default (include "binderhub.appLabel" .) }}
release: {{ .Release.Name }}
{{- if not .matchLabels }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .heritageLabel | default .Release.Service }}
{{- end }}
{{- end }}

{{- /*
binderhub.componentLabel:
Used by "binderhub.labels".
NOTE: The component label is determined by either...
- 1: The provided scope's .componentLabel
- 2: The template's filename if living in the root folder
- 3: The template parent folder's name
- : ...and is combined with .componentPrefix and .componentSuffix
*/}}
{{- define "binderhub.componentLabel" -}}
binder
{{- end }}
{{- /*
binderhub.labels:
Provides labels: component, app, release, (chart and heritage).
*/}}
{{- define "binderhub.labels" -}}
component: {{ include "binderhub.componentLabel" . }}
{{ include "binderhub.commonLabels" . }}
{{- end }}
{{- /*
binderhub.matchLabels:
Used to provide pod selection labels: component, app, release.
*/}}
{{- define "binderhub.matchLabels" -}}
{{- $_ := merge (dict "matchLabels" true) . -}}
{{ include "binderhub.labels" $_ }}
{{- end }}
21 changes: 8 additions & 13 deletions helm-chart/binderhub/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: binder
name: {{ include "binderhub.fullname" . }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: binder
component: binder
release: {{ .Release.Name }}
{{- include "binderhub.matchLabels" . | nindent 6 }}
strategy:
rollingUpdate:
{{- if eq (.Values.replicas | int) 1 }}
Expand All @@ -18,10 +16,7 @@ spec:
template:
metadata:
labels:
app: binder
name: binder
component: binder
release: {{ .Release.Name }}
{{- include "binderhub.matchLabels" . | nindent 8 }}
heritage: {{ .Release.Service }}
{{- with .Values.deployment.labels }}
{{- . | toYaml | nindent 8 }}
Expand Down Expand Up @@ -49,13 +44,13 @@ spec:
serviceAccountName: binderhub
{{- end }}
volumes:
- name: config
- name: secret-config
secret:
secretName: binder-secret
secretName: {{ include "binderhub.fullname" . }}-binder-secret
{{- if .Values.extraFiles }}
- name: files
secret:
secretName: binder-secret
secretName: {{ include "binderhub.fullname" . }}-binder-secret
items:
{{- range $file_key, $file_details := .Values.extraFiles }}
- key: {{ $file_key | quote }}
Expand All @@ -68,7 +63,7 @@ spec:
{{- if .Values.config.BinderHub.use_registry }}
- name: docker-secret
secret:
secretName: binder-build-docker-config
secretName: {{ include "binderhub.fullname" . }}-binder-build-docker-config
{{- else }}
- name: docker-socket
hostPath:
Expand All @@ -90,7 +85,7 @@ spec:
{{- end }}
volumeMounts:
- mountPath: /etc/binderhub/config/
name: config
name: secret-config
readOnly: true
{{- range $file_key, $file_details := .Values.extraFiles }}
- mountPath: {{ $file_details.mountPath }}
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/binderhub/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: binderhub
name: {{ include "binderhub.fullname" . }}
{{- if or (and .Values.ingress.https.enabled (eq .Values.ingress.https.type "kube-lego")) .Values.ingress.annotations }}
annotations:
{{- if and .Values.ingress.https.enabled (eq .Values.ingress.https.type "kube-lego") }}
Expand All @@ -24,7 +24,7 @@ spec:
pathType: {{ $.Values.ingress.pathType }}
backend:
service:
name: binder
name: {{ include "binderhub.fullname" $ }}
port:
number: 80
{{- with $host }}
Expand Down
12 changes: 3 additions & 9 deletions helm-chart/binderhub/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: binderhub
name: {{ include "binderhub.fullname" . }}
labels:
app: binder
name: binder
component: binder
release: {{ .Release.Name }}
{{- include "binderhub.matchLabels" . | nindent 4 }}
heritage: {{ .Release.Service }}
spec:
{{- if not (.Values.pdb.maxUnavailable | typeIs "<nil>") }}
Expand All @@ -22,8 +19,5 @@ spec:
{{- end }}
selector:
matchLabels:
app: binder
name: binder
component: binder
release: {{ .Release.Name }}
{{- include "binderhub.matchLabels" . | nindent 6 }}
{{- end }}
10 changes: 5 additions & 5 deletions helm-chart/binderhub/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: binderhub
name: {{ include "binderhub.fullname" . }}
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
Expand All @@ -23,14 +23,14 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: binderhub
name: {{ include "binderhub.fullname" . }}
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: binderhub
name: {{ include "binderhub.fullname" . }}
roleRef:
kind: Role
name: binderhub
name: {{ include "binderhub.fullname" . }}
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
Expand All @@ -41,7 +41,7 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: binderhub
name: {{ include "binderhub.fullname" . }}
{{- if .Values.imageCleaner.enabled }}
---
# image-cleaner role
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/binderhub/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
kind: Secret
apiVersion: v1
metadata:
name: binder-secret
name: {{ include "binderhub.fullname" . }}-binder-secret
type: Opaque
stringData:
{{- /*
Expand Down Expand Up @@ -35,7 +35,7 @@ data:
kind: Secret
apiVersion: v1
metadata:
name: binder-build-docker-config
name: {{ include "binderhub.fullname" . }}-binder-build-docker-config
type: Opaque
data:
config.json: {{ include "buildDockerConfig" . | b64enc | quote }}
Expand Down
7 changes: 2 additions & 5 deletions helm-chart/binderhub/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: binder
name: {{ include "binderhub.fullname" . }}
annotations: {{ .Values.service.annotations | toJson }}
labels: {{ .Values.service.labels | toJson }}
spec:
Expand All @@ -10,10 +10,7 @@ spec:
loadBalancerIP: {{ . | quote }}
{{- end }}
selector:
app: binder
name: binder
component: binder
release: {{ .Release.Name }}
{{- include "binderhub.matchLabels" . | nindent 4 }}
heritage: {{ .Release.Service }}
ports:
- protocol: TCP
Expand Down
2 changes: 2 additions & 0 deletions testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# the old version of this file may need to be copied to ./binderhub-chart-config-old.yaml
# before updating, and then deleted in a subsequent PR.

fullnameOverride: binder

service:
type: NodePort
nodePort: 30901
Expand Down

0 comments on commit 4e1d94d

Please sign in to comment.