@@ -25,12 +25,27 @@ If release name contains chart name it will be used as a full name.
25
25
{ {- end } }
26
26
{ {- end } }
27
27
28
+ { {/* Helm required labels: legacy */} }
29
+ { {- define " harbor.legacy.labels" -} }
30
+ heritage: { { .Release.Service } }
31
+ release: { { .Release.Name } }
32
+ chart: { { .Chart.Name } }
33
+ app: "{ { template " harbor.name" . } }"
34
+ { {- end -} }
35
+
28
36
{ {/* Helm required labels */} }
29
37
{ {- define " harbor.labels" -} }
30
38
heritage: { { .Release.Service } }
31
39
release: { { .Release.Name } }
32
40
chart: { { .Chart.Name } }
33
41
app: "{ { template " harbor.name" . } }"
42
+ app.kubernetes.io/instance: { { .Release.Name } }
43
+ app.kubernetes.io/name: { { include " harbor.name" . } }
44
+ app.kubernetes.io/managed-by: { { .Release.Service } }
45
+ app.kubernetes.io/part-of: { { include " harbor.name" . } }
46
+ { {- if .Chart.AppVersion } }
47
+ app.kubernetes.io/version: { { .Chart.AppVersion | quote } }
48
+ { {- end } }
34
49
{ {- end -} }
35
50
36
51
{ {/* matchLabels */} }
@@ -39,6 +54,13 @@ release: {{ .Release.Name }}
39
54
app: "{ { template " harbor.name" . } }"
40
55
{ {- end -} }
41
56
57
+ { {/* Helper for printing values from existing secrets*/} }
58
+ { {- define " harbor.secretKeyHelper" -} }
59
+ { {- if and (not (empty .data)) (hasKey .data .key) } }
60
+ { {- index .data .key | b64dec -} }
61
+ { {- end -} }
62
+ { {- end -} }
63
+
42
64
{ {- define " harbor.autoGenCert" -} }
43
65
{ {- if and .Values.expose.tls.enabled (eq .Values.expose.tls.certSource " auto" ) -} }
44
66
{ {- printf " true" -} }
@@ -89,7 +111,12 @@ app: "{{ template "harbor.name" . }}"
89
111
90
112
{ {- define " harbor.database.rawPassword" -} }
91
113
{ {- if eq .Values.database.type " internal" -} }
92
- { {- .Values.database.internal.password -} }
114
+ { {- $existingSecret := lookup " v1" " Secret" .Release.Namespace (include " harbor.database" .) -} }
115
+ { {- if and (not (empty $existingSecret )) (hasKey $existingSecret .data " POSTGRES_PASSWORD" ) -} }
116
+ { {- .Values.database.internal.password | default (index $existingSecret .data " POSTGRES_PASSWORD" | b64dec) -} }
117
+ { {- else -} }
118
+ { {- .Values.database.internal.password -} }
119
+ { {- end -} }
93
120
{ {- else -} }
94
121
{ {- .Values.database.external.password -} }
95
122
{ {- end -} }
@@ -111,22 +138,6 @@ app: "{{ template "harbor.name" . }}"
111
138
{ {- end -} }
112
139
{ {- end -} }
113
140
114
- { {- define " harbor.database.notaryServerDatabase" -} }
115
- { {- if eq .Values.database.type " internal" -} }
116
- { {- printf " %s" " notaryserver" -} }
117
- { {- else -} }
118
- { {- .Values.database.external.notaryServerDatabase -} }
119
- { {- end -} }
120
- { {- end -} }
121
-
122
- { {- define " harbor.database.notarySignerDatabase" -} }
123
- { {- if eq .Values.database.type " internal" -} }
124
- { {- printf " %s" " notarysigner" -} }
125
- { {- else -} }
126
- { {- .Values.database.external.notarySignerDatabase -} }
127
- { {- end -} }
128
- { {- end -} }
129
-
130
141
{ {- define " harbor.database.sslmode" -} }
131
142
{ {- if eq .Values.database.type " internal" -} }
132
143
{ {- printf " %s" " disable" -} }
@@ -135,14 +146,6 @@ app: "{{ template "harbor.name" . }}"
135
146
{ {- end -} }
136
147
{ {- end -} }
137
148
138
- { {- define " harbor.database.notaryServer" -} }
139
- postgres://{ { template " harbor.database.username" . } }:{ { template " harbor.database.escapedRawPassword" . } }@{ { template " harbor.database.host" . } }:{ { template " harbor.database.port" . } }/{ { template " harbor.database.notaryServerDatabase" . } }?sslmode={ { template " harbor.database.sslmode" . } }
140
- { {- end -} }
141
-
142
- { {- define " harbor.database.notarySigner" -} }
143
- postgres://{ { template " harbor.database.username" . } }:{ { template " harbor.database.escapedRawPassword" . } }@{ { template " harbor.database.host" . } }:{ { template " harbor.database.port" . } }/{ { template " harbor.database.notarySignerDatabase" . } }?sslmode={ { template " harbor.database.sslmode" . } }
144
- { {- end -} }
145
-
146
149
{ {- define " harbor.redis.scheme" -} }
147
150
{ {- with .Values.redis } }
148
151
{ {- ternary " redis+sentinel" " redis" (and (eq .type " external" ) (not (not .external.sentinelMasterSet))) } }
@@ -168,12 +171,26 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
168
171
{ {- end } }
169
172
{ {- end -} }
170
173
174
+
175
+ { {- define " harbor.redis.pwdfromsecret" -} }
176
+ { {- (lookup " v1" " Secret" .Release.Namespace (.Values.redis.external.existingSecret)).data.REDIS_PASSWORD | b64dec } }
177
+ { {- end -} }
178
+
179
+ { {- define " harbor.redis.cred" -} }
180
+ { {- with .Values.redis } }
181
+ { {- if (and (eq .type " external" ) (.external.existingSecret)) } }
182
+ { {- printf " :%s@" (include " harbor.redis.pwdfromsecret" $) } }
183
+ { {- else } }
184
+ { {- ternary (printf " %s:%s@" (.external.username | urlquery) (.external.password | urlquery)) " " (and (eq .type " external" ) (not (not .external.password))) } }
185
+ { {- end } }
186
+ { {- end } }
187
+ { {- end -} }
188
+
171
189
/*scheme://[:password@]host:port[/master_set]*/
172
190
{ {- define " harbor.redis.url" -} }
173
191
{ {- with .Values.redis } }
174
192
{ {- $path := ternary " " (printf " /%s" (include " harbor.redis.masterSet" $)) (not (include " harbor.redis.masterSet" $)) } }
175
- { {- $cred := ternary (printf " :%s@" (.external.password | urlquery)) " " (and (eq .type " external" ) (not (not .external.password))) } }
176
- { {- printf " %s://%s%s%s" (include " harbor.redis.scheme" $) $cred (include " harbor.redis.addr" $) $path -} }
193
+ { {- printf " %s://%s%s%s" (include " harbor.redis.scheme" $) (include " harbor.redis.cred" $) (include " harbor.redis.addr" $) $path -} }
177
194
{ {- end } }
178
195
{ {- end -} }
179
196
@@ -188,36 +205,46 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
188
205
/*scheme://[:password@]addr/db_index*/
189
206
{ {- define " harbor.redis.urlForJobservice" -} }
190
207
{ {- with .Values.redis } }
191
- { {- $index := ternary " 1 " .external.jobserviceDatabaseIndex (eq .type " internal" ) } }
208
+ { {- $index := ternary .internal.jobserviceDatabaseIndex .external.jobserviceDatabaseIndex (eq .type " internal" ) } }
192
209
{ {- printf " %s/%s" (include " harbor.redis.url" $) $index -} }
193
210
{ {- end } }
194
211
{ {- end -} }
195
212
196
213
/*scheme://[:password@]addr/db_index?idle_timeout_seconds=30*/
197
214
{ {- define " harbor.redis.urlForRegistry" -} }
198
215
{ {- with .Values.redis } }
199
- { {- $index := ternary " 2 " .external.registryDatabaseIndex (eq .type " internal" ) } }
216
+ { {- $index := ternary .internal.registryDatabaseIndex .external.registryDatabaseIndex (eq .type " internal" ) } }
200
217
{ {- printf " %s/%s?idle_timeout_seconds=30" (include " harbor.redis.url" $) $index -} }
201
218
{ {- end } }
202
219
{ {- end -} }
203
220
204
221
/*scheme://[:password@]addr/db_index?idle_timeout_seconds=30*/
205
222
{ {- define " harbor.redis.urlForTrivy" -} }
206
223
{ {- with .Values.redis } }
207
- { {- $index := ternary " 5 " .external.trivyAdapterIndex (eq .type " internal" ) } }
224
+ { {- $index := ternary .internal.trivyAdapterIndex .external.trivyAdapterIndex (eq .type " internal" ) } }
208
225
{ {- printf " %s/%s?idle_timeout_seconds=30" (include " harbor.redis.url" $) $index -} }
209
226
{ {- end } }
210
227
{ {- end -} }
211
228
212
- { {- define " harbor.redis.dbForRegistry" -} }
229
+ /*scheme://[:password@]addr/db_index?idle_timeout_seconds=30*/
230
+ { {- define " harbor.redis.urlForHarbor" -} }
213
231
{ {- with .Values.redis } }
214
- { {- ternary " 2" .external.registryDatabaseIndex (eq .type " internal" ) } }
232
+ { {- $index := ternary .internal.harborDatabaseIndex .external.harborDatabaseIndex (eq .type " internal" ) } }
233
+ { {- printf " %s/%s?idle_timeout_seconds=30" (include " harbor.redis.url" $) $index -} }
215
234
{ {- end } }
216
235
{ {- end -} }
217
236
218
- { {- define " harbor.redis.dbForChartmuseum" -} }
237
+ /*scheme://[:password@]addr/db_index?idle_timeout_seconds=30*/
238
+ { {- define " harbor.redis.urlForCache" -} }
219
239
{ {- with .Values.redis } }
220
- { {- ternary " 3" .external.chartmuseumDatabaseIndex (eq .type " internal" ) } }
240
+ { {- $index := ternary .internal.cacheLayerDatabaseIndex .external.cacheLayerDatabaseIndex (eq .type " internal" ) } }
241
+ { {- printf " %s/%s?idle_timeout_seconds=30" (include " harbor.redis.url" $) $index -} }
242
+ { {- end } }
243
+ { {- end -} }
244
+
245
+ { {- define " harbor.redis.dbForRegistry" -} }
246
+ { {- with .Values.redis } }
247
+ { {- ternary .internal.registryDatabaseIndex .external.registryDatabaseIndex (eq .type " internal" ) } }
221
248
{ {- end } }
222
249
{ {- end -} }
223
250
@@ -245,10 +272,6 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
245
272
{ {- printf " %s-registryctl" (include " harbor.fullname" .) -} }
246
273
{ {- end -} }
247
274
248
- { {- define " harbor.chartmuseum" -} }
249
- { {- printf " %s-chartmuseum" (include " harbor.fullname" .) -} }
250
- { {- end -} }
251
-
252
275
{ {- define " harbor.database" -} }
253
276
{ {- printf " %s-database" (include " harbor.fullname" .) -} }
254
277
{ {- end -} }
@@ -257,14 +280,6 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
257
280
{ {- printf " %s-trivy" (include " harbor.fullname" .) -} }
258
281
{ {- end -} }
259
282
260
- { {- define " harbor.notary-server" -} }
261
- { {- printf " %s-notary-server" (include " harbor.fullname" .) -} }
262
- { {- end -} }
263
-
264
- { {- define " harbor.notary-signer" -} }
265
- { {- printf " %s-notary-signer" (include " harbor.fullname" .) -} }
266
- { {- end -} }
267
-
268
283
{ {- define " harbor.nginx" -} }
269
284
{ {- printf " %s-nginx" (include " harbor.fullname" .) -} }
270
285
{ {- end -} }
@@ -277,12 +292,8 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
277
292
{ {- printf " %s-ingress" (include " harbor.fullname" .) -} }
278
293
{ {- end -} }
279
294
280
- { {- define " harbor.ingress-notary" -} }
281
- { {- printf " %s-ingress-notary" (include " harbor.fullname" .) -} }
282
- { {- end -} }
283
-
284
295
{ {- define " harbor.noProxy" -} }
285
- { {- printf " %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s " (include " harbor.core" .) (include " harbor.jobservice" .) (include " harbor.database" .) ( include " harbor.chartmuseum " .) ( include " harbor.notary-server " .) ( include " harbor.notary-signer " .) (include " harbor.registry" .) (include " harbor.portal" .) (include " harbor.trivy" .) (include " harbor.exporter" .) .Values.proxy.noProxy -} }
296
+ { {- printf " %s,%s,%s,%s,%s,%s,%s,%s" (include " harbor.core" .) (include " harbor.jobservice" .) (include " harbor.database" .) (include " harbor.registry" .) (include " harbor.portal" .) (include " harbor.trivy" .) (include " harbor.exporter" .) .Values.proxy.noProxy -} }
286
297
{ {- end -} }
287
298
288
299
{ {- define " harbor.caBundleVolume" -} }
@@ -297,7 +308,7 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
297
308
subPath: ca.crt
298
309
{ {- end -} }
299
310
300
- { {/* scheme for all components except notary because it only support http mode */} }
311
+ { {/* scheme for all components because it only support http mode */} }
301
312
{ {- define " harbor.component.scheme" -} }
302
313
{ {- if .Values.internalTLS.enabled -} }
303
314
{ {- printf " https" -} }
@@ -306,24 +317,6 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
306
317
{ {- end -} }
307
318
{ {- end -} }
308
319
309
- { {/* chartmuseum component container port */} }
310
- { {- define " harbor.chartmuseum.containerPort" -} }
311
- { {- if .Values.internalTLS.enabled -} }
312
- { {- printf " 9443" -} }
313
- { {- else -} }
314
- { {- printf " 9999" -} }
315
- { {- end -} }
316
- { {- end -} }
317
-
318
- { {/* chartmuseum component service port */} }
319
- { {- define " harbor.chartmuseum.servicePort" -} }
320
- { {- if .Values.internalTLS.enabled -} }
321
- { {- printf " 443" -} }
322
- { {- else -} }
323
- { {- printf " 80" -} }
324
- { {- end -} }
325
- { {- end -} }
326
-
327
320
{ {/* core component container port */} }
328
321
{ {- define " harbor.core.containerPort" -} }
329
322
{ {- if .Values.internalTLS.enabled -} }
@@ -468,14 +461,6 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
468
461
{ {- printf " %s://%s:%s" (include " harbor.component.scheme" .) (include " harbor.trivy" .) (include " harbor.trivy.servicePort" .) -} }
469
462
{ {- end -} }
470
463
471
- { {- define " harbor.internalTLS.chartmuseum.secretName" -} }
472
- { {- if eq .Values.internalTLS.certSource " secret" -} }
473
- { {- .Values.internalTLS.chartmuseum.secretName -} }
474
- { {- else -} }
475
- { {- printf " %s-chartmuseum-internal-tls" (include " harbor.fullname" .) -} }
476
- { {- end -} }
477
- { {- end -} }
478
-
479
464
{ {- define " harbor.internalTLS.core.secretName" -} }
480
465
{ {- if eq .Values.internalTLS.certSource " secret" -} }
481
466
{ {- .Values.internalTLS.core.secretName -} }
@@ -526,16 +511,6 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
526
511
{ {- end -} }
527
512
{ {- end -} }
528
513
529
- { {- define " harbor.tlsNotarySecretForIngress" -} }
530
- { {- if eq .Values.expose.tls.certSource " none" -} }
531
- { {- printf " " -} }
532
- { {- else if eq .Values.expose.tls.certSource " secret" -} }
533
- { {- .Values.expose.tls.secret.notarySecretName -} }
534
- { {- else -} }
535
- { {- include " harbor.ingress" . -} }
536
- { {- end -} }
537
- { {- end -} }
538
-
539
514
{ {- define " harbor.tlsSecretForNginx" -} }
540
515
{ {- if eq .Values.expose.tls.certSource " secret" -} }
541
516
{ {- .Values.expose.tls.secret.secretName -} }
@@ -557,7 +532,7 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
557
532
TRACE_SAMPLE_RATE: "{ { .Values.trace.sample_rate } }"
558
533
TRACE_NAMESPACE: "{ { .Values.trace.namespace } }"
559
534
{ {- if .Values.trace.attributes } }
560
- TRACE_ATTRIBUTES: " { { .Values.trace.attributes | toJson } }"
535
+ TRACE_ATTRIBUTES: { { .Values.trace.attributes | toJson | squote } }
561
536
{ {- end } }
562
537
{ {- if eq .Values.trace.provider " jaeger" } }
563
538
TRACE_JAEGER_ENDPOINT: "{ { .Values.trace.jaeger.endpoint } }"
@@ -603,4 +578,4 @@ postgres://{{ template "harbor.database.username" . }}:{{ template "harbor.datab
603
578
{ {/* Allow KubeVersion to be overridden. */} }
604
579
{ {- define " harbor.ingress.kubeVersion" -} }
605
580
{ {- default .Capabilities.KubeVersion.Version .Values.expose.ingress.kubeVersionOverride -} }
606
- { {- end -} }
581
+ { {- end -} }
0 commit comments