-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_helpers.tpl
More file actions
243 lines (223 loc) · 8.52 KB
/
Copy path_helpers.tpl
File metadata and controls
243 lines (223 loc) · 8.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
{{/*
Expand the name of the chart.
*/}}
{{- define "nebari-data-science-pack.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nebari-data-science-pack.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nebari-data-science-pack.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "nebari-data-science-pack.labels" -}}
helm.sh/chart: {{ include "nebari-data-science-pack.chart" . }}
{{ include "nebari-data-science-pack.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Singleuser config ConfigMap name
*/}}
{{- define "nebari-data-science-pack.singleuser-config" -}}
{{- printf "%s-singleuser-config" (include "nebari-data-science-pack.name" .) -}}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "nebari-data-science-pack.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nebari-data-science-pack.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Effective NFS-server enablement.
The chart's in-cluster NFS server is a fallback for clusters that have no
native RWX StorageClass. When a deployer sets sharedStorage.storageClass
explicitly, they have their own RWX class (Longhorn, EFS, Filestore…) so
the chart's NFS pod is redundant — silently disable it.
Returns "true" / "false" (strings) so callers gate via `eq ... "true"`.
*/}}
{{- define "nebari-data-science-pack.nfsServerEnabled" -}}
{{- if .Values.sharedStorage.storageClass -}}
false
{{- else if .Values.sharedStorage.nfsServer.enabled -}}
true
{{- else -}}
false
{{- end -}}
{{- end -}}
{{/*
============================================================================
Zero-config derivation helpers
============================================================================
The deployer-visible API is two fields:
keycloak.hostname — drives subdomain inference for hub + nebi
nebi.image.tag — pinned per chart release (CI-bumped)
Everything else has a chart-side default; explicit values still win.
*/}}
{{/*
Base DNS domain extracted from keycloak.hostname by stripping the leading
subdomain label. e.g. "keycloak.example.com" -> "example.com". Empty when
keycloak.hostname is unset or has no dot — callers fall back to explicit
nebariapp.hostname / nebi.remoteURL.
*/}}
{{- define "nebari-data-science-pack.baseDomain" -}}
{{- $kc := .Values.keycloak.hostname | default "" -}}
{{- if and $kc (contains "." $kc) -}}
{{- $parts := splitList "." $kc -}}
{{- join "." (rest $parts) -}}
{{- end -}}
{{- end -}}
{{/*
External hub hostname. Order of precedence:
1. .Values.nebariapp.hostname (explicit)
2. <subdomains.hub>.<baseDomain(keycloak.hostname)>
Empty when neither is available.
*/}}
{{- define "nebari-data-science-pack.hubHostname" -}}
{{- if .Values.nebariapp.hostname -}}
{{- .Values.nebariapp.hostname -}}
{{- else -}}
{{- $base := include "nebari-data-science-pack.baseDomain" . -}}
{{- if $base -}}
{{- printf "%s.%s" (.Values.subdomains.hub | default "hub") $base -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
External Nebi URL. Order of precedence:
1. .Values.nebi.remoteURL (explicit)
2. https://<subdomains.nebi>.<baseDomain(keycloak.hostname)>
Empty when neither is available.
*/}}
{{- define "nebari-data-science-pack.nebiRemoteURL" -}}
{{- if .Values.nebi.remoteURL -}}
{{- .Values.nebi.remoteURL -}}
{{- else -}}
{{- $base := include "nebari-data-science-pack.baseDomain" . -}}
{{- if $base -}}
{{- printf "https://%s.%s" (.Values.subdomains.nebi | default "nebi") $base -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
In-cluster Nebi URL. Order of precedence:
1. .Values.nebi.internalURL (explicit)
2. http://nebi-pack-nebari-nebi-pack.<nebi.namespace>.svc.cluster.local
*/}}
{{- define "nebari-data-science-pack.nebiInternalURL" -}}
{{- if .Values.nebi.internalURL -}}
{{- .Values.nebi.internalURL -}}
{{- else -}}
{{- printf "http://nebi-pack-nebari-nebi-pack.%s.svc.cluster.local" (.Values.nebi.namespace | default "nebi") -}}
{{- end -}}
{{- end -}}
{{/*
Nebi image reference (repository:tag). Empty when nebi.image.tag is not
pinned — Python init-container code path stays a no-op.
*/}}
{{- define "nebari-data-science-pack.nebiImage" -}}
{{- $repo := .Values.nebi.image.repository | default "quay.io/nebari/nebi" -}}
{{- $tag := .Values.nebi.image.tag | default "" -}}
{{- if $tag -}}
{{- printf "%s:%s" $repo $tag -}}
{{- end -}}
{{- end -}}
{{/*
Keycloak token endpoint. Order of precedence:
1. .Values.jupyterhub.custom.keycloak-token-url (explicit)
2. https://<keycloak.hostname>/realms/<realm>/protocol/openid-connect/token
3. http://<keycloak.serviceHost>/realms/<realm>/... (in-cluster default)
The in-cluster default matches the bitnami/keycloakx layout that every
Nebari deployment ships with.
*/}}
{{- define "nebari-data-science-pack.keycloakTokenURL" -}}
{{- $explicit := index .Values.jupyterhub.custom "keycloak-token-url" | default "" -}}
{{- $realm := .Values.keycloak.realm | default "nebari" -}}
{{- if $explicit -}}
{{- $explicit -}}
{{- else if .Values.keycloak.hostname -}}
{{- printf "https://%s/realms/%s/protocol/openid-connect/token" .Values.keycloak.hostname $realm -}}
{{- else -}}
{{- printf "http://%s/realms/%s/protocol/openid-connect/token" (.Values.keycloak.serviceHost | default "keycloak-keycloakx-http.keycloak.svc.cluster.local:8080") $realm -}}
{{- end -}}
{{- end -}}
{{/*
Backchannel issuer URL for split-horizon OIDC. When non-empty, the hub uses
this URL as the base for ``token_url`` and ``userdata_url`` while the browser
continues to use the primary (``issuer``) URL for authorize + end_session.
Needed on private-VPC clusters where in-cluster CoreDNS cannot resolve the
external Keycloak hostname.
Order of precedence:
1. .Values.jupyterhub.custom.keycloak-backchannel-issuer-url (explicit
full issuer URL, e.g. http://keycloak-keycloakx-http.keycloak.svc.cluster.local:8080/realms/nebari)
2. .Values.keycloak.backchannelURL + /realms/<realm> (base URL only,
realm suffix added by the helper)
3. Empty string — no split-horizon (the caller falls back to the primary
issuer for all four URLs)
Emits WITHOUT a trailing ``/protocol/openid-connect`` — that suffix is
appended by the Python side in ``KeyCloakConfig.build()`` so the tokens
URL and userinfo URL sit next to each other under one base.
*/}}
{{- define "nebari-data-science-pack.keycloakBackchannelIssuerURL" -}}
{{- $explicit := index .Values.jupyterhub.custom "keycloak-backchannel-issuer-url" | default "" -}}
{{- $realm := .Values.keycloak.realm | default "nebari" -}}
{{- if $explicit -}}
{{- $explicit -}}
{{- else if .Values.keycloak.backchannelURL -}}
{{- printf "%s/realms/%s" .Values.keycloak.backchannelURL $realm -}}
{{- end -}}
{{- end -}}
{{/*
OIDC client IDs follow nebari-operator's naming convention:
jupyterhub-<release>-<chart> (hub's own client)
nebi-<release>-<chart> (nebi service client, provisioned by nebi-pack)
*/}}
{{- define "nebari-data-science-pack.hubClientID" -}}
{{- $explicit := index .Values.jupyterhub.custom "jupyterhub-client-id" | default "" -}}
{{- if $explicit -}}
{{- $explicit -}}
{{- else -}}
{{- printf "jupyterhub-%s" (include "nebari-data-science-pack.fullname" .) -}}
{{- end -}}
{{- end -}}
{{- define "nebari-data-science-pack.nebiClientID" -}}
{{- $explicit := index .Values.jupyterhub.custom "nebi-client-id" | default "" -}}
{{- if $explicit -}}
{{- $explicit -}}
{{- else -}}
{{- printf "nebi-%s-nebari-nebi-pack" (.Values.nebi.releaseName | default "nebi-pack") -}}
{{- end -}}
{{- end -}}
{{/*
External JupyterHub URL with scheme. Used for OAuth callback / bind_url.
Empty when no hub hostname is available.
*/}}
{{- define "nebari-data-science-pack.hubExternalURL" -}}
{{- $h := include "nebari-data-science-pack.hubHostname" . -}}
{{- if $h -}}
{{- printf "https://%s/" $h -}}
{{- end -}}
{{- end -}}