-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathservice.tpl
51 lines (51 loc) · 1.51 KB
/
service.tpl
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
# Version: 2.5.0
# DO NOT MODIFY the "Version: " key
# Helm Version: v1
{{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Job.serviceName }}
annotations:
{{- with .Job.metadata.service.annotations }}
{{- range $key, $val := . }}
{{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }}
{{- end }}
{{- end }}
{{- with $templateData.service.annotations }}
{{- range $key, $val := . }}
{{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }}
{{- end }}
{{- end }}
labels:
app.kubernetes.io/managed-by: "launcher"
job-name: {{ toYaml .Job.id }}
{{- with .Job.instanceId }}
launcher-instance-id: {{ toYaml . }}
{{- end }}
{{- with .Job.metadata.service.labels }}
{{- range $key, $val := . }}
{{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }}
{{- end }}
{{- end }}
{{- with $templateData.service.labels }}
{{- range $key, $val := . }}
{{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }}
{{- end }}
{{- end }}
spec:
ports:
{{- $i := 0 }}
{{- range .Job.exposedPorts }}
{{- if not .publishedPort }}
- name: {{ printf "port%d" $i }}
protocol: {{ .protocol }}
port: {{ .targetPort }}
targetPort: {{ .targetPort }}
{{- $i = add $i 1 }}
{{- end }}
{{- end }}
selector:
job-name: {{toYaml .Job.id }}
clusterIP: ''
type: {{ $templateData.service.type }}