Repository navigation
Expand file tree
/
Copy path_chronicle-agent.tpl
More file actions
53 lines (52 loc) · 3.24 KB
/
Copy path_chronicle-agent.tpl
File metadata and controls
53 lines (52 loc) · 3.24 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
{{/*
Attempts to determine an image tag for the chronicle-agent image by looking up a Chronicle server in the current
namespace. If no server is found, it will default to "latest". If a tag is specified in the passed config, it will be
used instead of the server tag.
Takes a dict:
- .chronicleAgent: the chronicle-agent config
- .chronicleAgent.image.registry: the registry to use for the image
- .chronicleAgent.image.repository: the repository to use for the image
- .chronicleAgent.image.tag: the tag to use for the image (optional)
- .chronicleAgent.serverNamespace: the namespace to search for the Chronicle server, defaults to the current release namespace
*/}}
{{- define "rstudio-library.chronicle-agent.image" }}
{{- $registry := required "registry must be specified for the chronicle-agent config." .chronicleAgent.image.registry }}
{{- $repository := required "repository must be specified for the chronicle-agent config." .chronicleAgent.image.repository }}
{{- $version := "latest" }}
{{- if not .chronicleAgent.image.tag }}
{{- range $index, $service := (lookup "v1" "Service" (default .Release.Namespace .chronicleAgent.serverNamespace) "").items }}
{{- $name := get $service.metadata.labels "app.kubernetes.io/name" }}
{{- $component := get $service.metadata.labels "app.kubernetes.io/component" }}
{{- if and (eq $name "posit-chronicle") (eq $component "server") }}
{{- $version = get $service.metadata.labels "app.kubernetes.io/version" }}
{{- end }}
{{- end }}
{{- else }}
{{- $version = .chronicleAgent.image.tag }}
{{- end }}
{{- $registry }}/{{ $repository }}:{{ $version }}
{{- end }}
{{/*
Attempts to determine the server address for the chronicle-agent image by looking up a Chronicle server in the current
namespace. If no server is found, it will default to "". If a serverAddress is specified in the passed config,
it will be used instead of the server address.
Takes a dict:
- .chronicleAgent: the chronicle-agent config
- .chronicleAgent.serverAddress: the server address to use for the image (optional)
- .chronicleAgent.serverNamespace: the namespace to search for the Chronicle server, defaults to the current release namespace
*/}}
{{- define "rstudio-library.chronicle-agent.serverAddress" }}
{{- if .chronicleAgent.serverAddress }}
{{- .chronicleAgent.serverAddress }}
{{- else if lookup "v1" "Service" (default .Release.Namespace .chronicleAgent.serverNamespace) "" }}
{{- range $index, $service := (lookup "v1" "Service" (default .Release.Namespace .chronicleAgent.serverNamespace) "").items }}
{{- $name := get $service.metadata.labels "app.kubernetes.io/name" }}
{{- $component := get $service.metadata.labels "app.kubernetes.io/component" }}
{{- if and (eq $name "posit-chronicle") (eq $component "server") }}
{{- (index $service.spec.ports 0).name }}://{{ $service.metadata.name }}.{{ $service.metadata.namespace }}
{{- end }}
{{- end }}
{{- else }}
{{- fail "Unable to resolve a Chronicle server address for Chronicle agent. Ensure that a Chronicle server is deployed in the same namespace as this chart or the namespace is specfied with chronicleAgent.serverNamespace when using chronicleAgent.autoDiscovery=true. Alternatively, specify chronicleAgent.serverAddress in the values.yaml file." }}
{{- end }}
{{- end }}