-
Notifications
You must be signed in to change notification settings - Fork 164
/
helmfile-60.teams.yaml
214 lines (212 loc) · 8.5 KB
/
helmfile-60.teams.yaml
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
bases:
- snippets/defaults.gotmpl
---
{{- $v := .Environment.Values }}
{{- $tc := $v.teamConfig }}
{{- $coreTeamServices := list }}{{- range $s := $tc.services }}{{ $coreTeamServices = append $coreTeamServices (merge $s (dict "isCore" true)) }}{{ end }}
{{- $c := $v.charts }}
{{- $cm := index $v.charts "cert-manager" }}
{{- $po := index $v.charts "prometheus-operator" }}
{{- $slackTpl := tpl (readFile "../helmfile.d/snippets/slack.gotmpl") $v | toString }}
releases:
{{- range $teamId, $team := $tc.teams }}
{{- if hasKey $team "services" }}
{{- $domain := printf "%s%s.%s" $v.otomi.teamPrefix $teamId $v.cluster.domain }}
{{- $appsDomain := printf "apps.%s" $domain }}
{{- $azure := $team | get "azure" dict }}
- name: team-ns-{{ $teamId }}
installed: true
namespace: team-{{ $teamId }}
chart: ../charts/team-ns
labels:
tag: teams
team: {{ $teamId }}
values:
- cluster: {{- $v.cluster | toYaml | nindent 10 }}
otomi: {{- $v.otomi | toYaml | nindent 10 }}
hasKeycloak: {{ $v.charts.keycloak | get "enabled" true }}
domain: {{ $domain }}
certStage: {{ $cm.stage }}
knative:
enabled: true
- {{- $team | toYaml | nindent 8 }}
teamId: {{ $teamId }}
- services: {{- concat $coreTeamServices ($team | get "services" list) | toYaml | nindent 10 }}
{{- if $v.otomi.isMultitenant }}
{{- if ($team | get "cicd.enabled" "false") }}
{{- $cicdFlavour := ($team | get "cicd.type" "drone") }}
{{- if eq $cicdFlavour "drone" }}
# TODO: fix this weirdness: the next two lines fook the yaml parser:
# - name: drone
# svc: drone-{{ $teamId }}
{{- end }}
{{- end }}
{{- if ne (len ($team | get "sites" list)) 0 }}
- name: blackbox
svc: prometheus-blackbox-exporter
port: 9115
{{- end }}
{{- end }}
{{- if $v.otomi.isMultitenant }}
- name: prometheus-{{ $teamId }}
installed: {{ has $v.cluster.id $team.clusters }}
namespace: team-{{ $teamId }}
chart: ../charts/prometheus-operator
labels:
tag: teams
team: {{ $teamId }}
values:
- ../values/prometheus-operator/prometheus-operator.gotmpl
- ../values/prometheus-operator/prometheus-operator-team.gotmpl
- nameOverride: {{ $teamId }}-po
fullnameOverride: {{ $teamId }}-po
alertmanager:
alertmanagerSpec:
externalUrl: https://{{ $appsDomain }}/alertmanager
config: {{- tpl (readFile "../helmfile.d/snippets/alertmanager.gotmpl") (dict "instance" $team "root" $v "slackTpl" $slackTpl) | nindent 12 }}
commonLabels:
prometheus: team-{{ $teamId }}
prometheus:
prometheusSpec:
serviceMonitorSelector:
matchLabels:
prometheus: team-{{ $teamId }}
externalUrl: https://{{ $appsDomain }}/prometheus
ruleNamespaceSelector:
matchLabels:
name: team-{{ $teamId }}
podMonitorNamespaceSelector:
matchLabels:
name: team-{{ $teamId }}
serviceMonitorNamespaceSelector:
matchLabels:
name: team-{{ $teamId }}
additionalScrapeConfigs:
- job_name: probe-services-{{ $teamId }}
metrics_path: /probe
scrape_interval: 10m
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
{{ $registry := list }}
{{- range $s := $team.services }}
{{- if and (hasKey $s "isPublic") (not ($s | get "ksvc.scaleToZero" false)) }}
{{- $svcDomain := ($s | get "domain" (printf "%s.%s" $s.name $domain)) }}
{{- $path := "/" }}{{ if hasKey $s "paths" }}{{ $path = index $s.paths 0 }}{{ end }}
{{- $url := printf "%s%s" $svcDomain $path }}
{{- if not (has $url $registry) }}
{{- $registry = append $registry $url }}
- https://{{ $url }}
{{- end }}
{{- end }}
{{- end }}
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: prometheus-blackbox-exporter.monitoring:9115
additionalPrometheusRules:
- name: blackbox
{{- readFile "../values/prometheus-operator/rules/blackbox.yaml" | nindent 12 }}
grafana:
nameOverride: {{ $teamId }}-po-grafana
fullnameOverride: {{ $teamId }}-po-grafana
grafana.ini:
server:
root_url: https://{{ $appsDomain }}/grafana
additionalDataSources:
- name: Prometheus-admin
editable: false
type: prometheus
access: proxy
url: http://po-prometheus.monitoring:9090
- name: Prometheus-Istio
editable: false
type: prometheus
access: proxy
url: http://prometheus.istio-system:9090
- name: Loki
editable: false
type: loki
access: proxy
url: http://loki.monitoring:11811
basicAuth: true
basicAuthUser: {{ $teamId }}
basicAuthPassword: {{ $team.password }}
{{- if $c.sitespeed.enabled }}
- name: Graphite
editable: false
type: graphite
access: proxy
url: http://graphite.monitoring:80
{{- end }}
{{- if and (eq $v.cluster.provider "azure") }}
{{- $monitor := ($team | get "azure.monitor" ($v.clouds.azure | get "monitor" nil)) }}
{{- with $monitor }}
{{- $a := $v.clouds.azure }}
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
cloudName: azuremonitor
subscriptionId: {{ $a.subscriptionId }}
tenantId: {{ $a.tenantId }}
clientId: {{ .clientId }}
logAnalyticsTenantId: {{ . | get "logAnalyticsTenantId" $a.tenantId }}
logAnalyticsClientId: {{ . | get "logAnalyticsClientId" .clientId }}
logAnalyticsDefaultWorkspace: {{ .logAnalyticsWorkspace }}
appInsightsAppId: {{ . | get "appInsightsAppId" .clientId }}
azureLogAnalyticsSameAs: true
keepCookies: []
secureJsonData:
clientSecret: {{ .clientSecret }}
logAnalyticsClientSecret: {{ . | get "logAnalyticsClientSecret" .clientSecret }}
appInsightsAppSecret : {{ . | get "appInsightsAppSecret" .clientSecret }}
version: 4
editable: false
{{- end }}
{{- end }}
{{ if has "msteams" ($team | get "receivers" list) }}
- name: prometheus-msteams-{{ $teamId }}
installed: {{ has $v.cluster.id $team.clusters }}
namespace: team-{{ $teamId }}
chart: ../charts/prometheus-msteams
labels:
tag: teams
team: {{ $teamId }}
values:
- ../values/prometheus-msteams/prometheus-msteams.gotmpl
- commonLabels:
team: {{ $teamId }}
metrics:
serviceMonitor:
additionalLabels:
release: prometheus-{{ $teamId }}
connectors:
- high_priority_channel: {{ $team | get "msteams.highPrio" }}
- low_priority_channel: {{ $team | get "msteams.lowPrio" }}
{{- end }}
- name: grafana-dashboards-{{ $teamId }}
installed: {{ has $v.cluster.id $team.clusters }}
namespace: team-{{ $teamId }}
chart: ../charts/grafana-dashboards
labels:
tag: teams
team: {{ $teamId }}
values:
- ../values/grafana-dashboards/grafana-dashboards.gotmpl
- cluster: {{- $v.cluster | toYaml | nindent 10 }}
team: {{ $teamId }}
folders:
- k8s
- istio
{{- if and (eq $v.cluster.provider "azure") ($team | get "azure.monitor" ($v.clouds | get "azure.monitor" nil)) }}
- azure{{ end }}
{{- if $team | get "stack.sitespeed" false }}
- sitespeed{{ end }}
{{- end }}
{{- end }}
{{- end }}