Skip to content

Commit 7580133

Browse files
committed
Change default naming to not include release name
1 parent be5fd8d commit 7580133

File tree

14 files changed

+157
-86
lines changed

14 files changed

+157
-86
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- /*
2+
Common labels
3+
*/}}
4+
{{- define "binderhub-service.labels" -}}
5+
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
6+
{{ include "binderhub-service.selectorLabels" . }}
7+
{{- if .Chart.AppVersion }}
8+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
9+
{{- end }}
10+
app.kubernetes.io/managed-by: {{ .Release.Service }}
11+
{{- end }}
12+
13+
{{- /*
14+
Selector labels
15+
*/}}
16+
{{- define "binderhub-service.selectorLabels" -}}
17+
app.kubernetes.io/name: {{ .Values.nameOverride | default .Chart.Name | trunc 63 | trimSuffix "-" }}
18+
app.kubernetes.io/instance: {{ .Release.Name }}
19+
{{- end }}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{{- /*
2+
These helpers encapsulates logic on how we name resources. They also enable
3+
parent charts to reference these dynamic resource names.
4+
5+
To avoid duplicating documentation, for more information, please see the the
6+
fullnameOverride entry the jupyterhub chart's configuration reference:
7+
https://z2jh.jupyter.org/en/latest/resources/reference.html#fullnameOverride
8+
*/}}
9+
10+
11+
12+
{{- /*
13+
Utility templates
14+
*/}}
15+
16+
{{- /*
17+
Renders to a prefix for the chart's resource names. This prefix is assumed to
18+
make the resource name cluster unique.
19+
*/}}
20+
{{- define "binderhub-service.fullname" -}}
21+
{{- /*
22+
We have implemented a trick to allow a parent chart depending on this
23+
chart to call these named templates.
24+
25+
Caveats and notes:
26+
27+
1. While parent charts can reference these, grandparent charts can't.
28+
2. Parent charts must not use an alias for this chart.
29+
3. There is no failsafe workaround to above due to
30+
https://github.com/helm/helm/issues/9214.
31+
4. .Chart is of its own type (*chart.Metadata) and needs to be casted
32+
using "toYaml | fromYaml" in order to be able to use normal helm
33+
template functions on it.
34+
*/}}
35+
{{- $fullname_override := .Values.fullnameOverride }}
36+
{{- $name_override := .Values.nameOverride }}
37+
{{- if ne .Chart.Name "binderhub-service" }}
38+
{{- if .Values.jupyterhub }}
39+
{{- $fullname_override = .Values.jupyterhub.fullnameOverride }}
40+
{{- $name_override = .Values.jupyterhub.nameOverride }}
41+
{{- end }}
42+
{{- end }}
43+
44+
{{- if eq (typeOf $fullname_override) "string" }}
45+
{{- $fullname_override }}
46+
{{- else }}
47+
{{- $name := $name_override | default .Chart.Name }}
48+
{{- if contains $name .Release.Name }}
49+
{{- .Release.Name }}
50+
{{- else }}
51+
{{- .Release.Name }}-{{ $name }}
52+
{{- end }}
53+
{{- end }}
54+
{{- end }}
55+
56+
{{- /*
57+
Renders to a blank string or if the fullname template is truthy renders to it
58+
with an appended dash.
59+
*/}}
60+
{{- define "binderhub-service.fullname.dash" -}}
61+
{{- if (include "binderhub-service.fullname" .) }}
62+
{{- include "binderhub-service.fullname" . }}-
63+
{{- end }}
64+
{{- end }}
65+
66+
67+
68+
{{- /*
69+
Namespaced resources
70+
*/}}
71+
72+
{{- /* binderhub resources' default name */}}
73+
{{- define "binderhub-service.binderhub.fullname" -}}
74+
{{- include "binderhub-service.fullname.dash" . }}binderhub
75+
{{- end }}
76+
77+
{{- /* binderhub's ServiceAccount name */}}
78+
{{- define "binderhub-service.binderhub.serviceaccount.fullname" -}}
79+
{{- if .Values.serviceAccount.create }}
80+
{{- .Values.serviceAccount.name | default (include "binderhub-service.binderhub.fullname" .) }}
81+
{{- else }}
82+
{{- .Values.serviceAccount.name }}
83+
{{- end }}
84+
{{- end }}
85+
86+
{{- /* binderhub's Ingress name */}}
87+
{{- define "binderhub-service.binderhub.ingress.fullname" -}}
88+
{{- if (include "binderhub-service.fullname" .) }}
89+
{{- include "binderhub-service.fullname" . }}
90+
{{- else -}}
91+
binderhub
92+
{{- end }}
93+
{{- end }}
94+
95+
{{- /* docker-api resources' default name */}}
96+
{{- define "binderhub-service.docker-api.fullname" -}}
97+
{{- include "binderhub-service.fullname.dash" . }}docker-api
98+
{{- end }}
99+
100+
{{- /* build-pods-docker-config name */}}
101+
{{- define "binderhub-service.build-pods-docker-config.fullname" -}}
102+
{{- include "binderhub-service.fullname.dash" . }}build-pods-docker-config
103+
{{- end }}
104+
105+
106+
107+
{{- /*
108+
Cluster wide resources
109+
110+
We enforce uniqueness of names for our cluster wide resources. We assume that
111+
the prefix from setting fullnameOverride to null or a string will be cluster
112+
unique.
113+
*/}}
114+
115+
{{- /*
116+
We currently have no cluster wide resources, but if you add one below in the
117+
future, remove this comment and add an entry mimicing how the jupyterhub helm
118+
chart does it.
119+
*/}}

binderhub-service/templates/_helpers.tpl

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,3 @@
1-
{{- /*
2-
Expand the name of the chart.
3-
*/}}
4-
{{- define "binderhub-service.name" -}}
5-
{{- .Values.nameOverride | default .Chart.Name | trunc 63 | trimSuffix "-" }}
6-
{{- end }}
7-
8-
{{- /*
9-
Create a default fully qualified app name.
10-
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11-
If release name contains chart name it will be used as a full name.
12-
*/}}
13-
{{- define "binderhub-service.fullname" -}}
14-
{{- if .Values.fullnameOverride }}
15-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16-
{{- else }}
17-
{{- $name := .Values.nameOverride | default .Chart.Name }}
18-
{{- if contains $name .Release.Name }}
19-
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20-
{{- else }}
21-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22-
{{- end }}
23-
{{- end }}
24-
{{- end }}
25-
26-
{{- /*
27-
Create chart name and version as used by the chart label.
28-
*/}}
29-
{{- define "binderhub-service.chart" -}}
30-
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31-
{{- end }}
32-
33-
{{- /*
34-
Common labels
35-
*/}}
36-
{{- define "binderhub-service.labels" -}}
37-
helm.sh/chart: {{ include "binderhub-service.chart" . }}
38-
{{ include "binderhub-service.selectorLabels" . }}
39-
{{- if .Chart.AppVersion }}
40-
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41-
{{- end }}
42-
app.kubernetes.io/managed-by: {{ .Release.Service }}
43-
{{- end }}
44-
45-
{{- /*
46-
Selector labels
47-
*/}}
48-
{{- define "binderhub-service.selectorLabels" -}}
49-
app.kubernetes.io/name: {{ include "binderhub-service.name" . }}
50-
app.kubernetes.io/instance: {{ .Release.Name }}
51-
{{- end }}
52-
53-
{{- /*
54-
Create the name of the service account to use
55-
*/}}
56-
{{- define "binderhub-service.serviceAccountName" -}}
57-
{{- if .Values.serviceAccount.create }}
58-
{{- include "binderhub-service.fullname" . | default .Values.serviceAccount.name }}
59-
{{- else }}
60-
{{- .Values.serviceAccount.name }}
61-
{{- end }}
62-
{{- end }}
63-
64-
65-
661
{{- /*
672
binderhub-service.chart-version-to-git-ref:
683
Renders a valid git reference from a chartpress generated version string.

binderhub-service/templates/build-pods-docker-config/secret.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
kind: Secret
88
apiVersion: v1
99
metadata:
10-
# If this is changed, update the value of the PUSH_SECRET_NAME environment
11-
# variable in the binderhub deployment (in deployment.yaml)
12-
name: {{ include "binderhub-service.fullname" . }}-build-pods-docker-config
10+
name: {{ include "binderhub-service.build-pods-docker-config.fullname" . }}
1311
labels:
1412
{{- include "binderhub-service.labels" . | nindent 4 }}
1513
type: Opaque

binderhub-service/templates/deployment.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: {{ include "binderhub-service.fullname" . }}
4+
name: {{ include "binderhub-service.binderhub.fullname" . }}
55
labels:
66
{{- include "binderhub-service.labels" . | nindent 4 }}
77
spec:
@@ -24,7 +24,7 @@ spec:
2424
volumes:
2525
- name: secret
2626
secret:
27-
secretName: {{ include "binderhub-service.fullname" . }}
27+
secretName: {{ include "binderhub-service.binderhub.fullname" . }}
2828
containers:
2929
- name: binderhub
3030
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -40,7 +40,7 @@ spec:
4040
readOnly: true
4141
env:
4242
- name: PUSH_SECRET_NAME
43-
value: {{ include "binderhub-service.fullname" . }}-build-pods-docker-config
43+
value: {{ include "binderhub-service.build-pods-docker-config.fullname" . }}
4444
- name: HELM_RELEASE_NAME
4545
value: {{ .Release.Name }}
4646
# Namespace build pods should be placed in
@@ -70,7 +70,7 @@ spec:
7070
imagePullSecrets:
7171
{{- . | toYaml | nindent 8 }}
7272
{{- end }}
73-
{{- with include "binderhub-service.serviceAccountName" . }}
73+
{{- with include "binderhub-service.binderhub.serviceaccount.fullname" . }}
7474
serviceAccountName: {{ . }}
7575
{{- end }}
7676
{{- with .Values.podSecurityContext }}

binderhub-service/templates/docker-api/daemonset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apps/v1
22
kind: DaemonSet
33
metadata:
4-
name: {{ include "binderhub-service.fullname" . }}-docker-api
4+
name: {{ include "binderhub-service.docker-api.fullname" . }}
55
labels:
66
{{- include "binderhub-service.labels" . | nindent 4 }}
77
app.kubernetes.io/component: docker-api
@@ -57,7 +57,7 @@ spec:
5757
{{- if .Values.dockerApi.extraFiles }}
5858
- name: files
5959
secret:
60-
secretName: {{ include "binderhub-service.fullname" . }}-docker-api
60+
secretName: {{ include "binderhub-service.docker-api.fullname" . }}
6161
items:
6262
{{- range $file_key, $file_details := .Values.dockerApi.extraFiles }}
6363
- key: {{ $file_key | quote }}

binderhub-service/templates/docker-api/secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
kind: Secret
33
apiVersion: v1
44
metadata:
5-
name: {{ include "binderhub-service.fullname" . }}-docker-api
5+
name: {{ include "binderhub-service.docker-api.fullname" . }}
66
labels:
77
{{- include "binderhub-service.labels" . | nindent 4 }}
88
type: Opaque

binderhub-service/templates/ingress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:
5-
name: {{ include "binderhub-service.fullname" . }}
5+
name: {{ include "binderhub-service.binderhub.ingress.fullname" . }}
66
labels:
77
{{- include "binderhub-service.labels" . | nindent 4 }}
88
{{- with .Values.ingress.annotations }}
@@ -21,7 +21,7 @@ spec:
2121
pathType: {{ $.Values.ingress.pathType }}
2222
backend:
2323
service:
24-
name: {{ include "binderhub-service.fullname" $ }}
24+
name: {{ include "binderhub-service.binderhub.fullname" $ }}
2525
port:
2626
name: http
2727
{{- if $host }}

binderhub-service/templates/role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
kind: Role
33
apiVersion: rbac.authorization.k8s.io/v1
44
metadata:
5-
name: {{ include "binderhub-service.fullname" . }}
5+
name: {{ include "binderhub-service.binderhub.fullname" . }}
66
labels:
77
{{- include "binderhub-service.labels" . | nindent 4 }}
88
rules:

binderhub-service/templates/rolebinding.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
kind: RoleBinding
33
apiVersion: rbac.authorization.k8s.io/v1
44
metadata:
5-
name: {{ include "binderhub-service.fullname" . }}
5+
name: {{ include "binderhub-service.binderhub.fullname" . }}
66
labels:
77
{{- include "binderhub-service.labels" . | nindent 4 }}
88
subjects:
99
- kind: ServiceAccount
1010
namespace: {{ .Release.Namespace }}
11-
name: {{ include "binderhub-service.serviceAccountName" . }}
11+
name: {{ include "binderhub-service.binderhub.serviceaccount.fullname" . }}
1212
roleRef:
1313
apiGroup: rbac.authorization.k8s.io
1414
kind: Role
15-
name: {{ include "binderhub-service.fullname" . }}
15+
name: {{ include "binderhub-service.binderhub.fullname" . }}
1616
{{- end }}

0 commit comments

Comments
 (0)