annotate create_k8s.py @ 71:bfacf01fd119

conv vmalert/alertmanager config to py
author drewp@bigasterisk.com
date Fri, 03 May 2024 12:27:16 -0700
parents 6a021aa7b4be
children 85d9dae18656
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
1 from pathlib import Path
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
2 from index_page import makeIndexHtml
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
3 from output import affinityToNode, build, createIngress, createPv, createPvc, toJson, createSvc
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
4
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
5
60
e3151ab43579 moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents: 57
diff changeset
6 def createAgentDeploy(tzArg, vmVersion, pipelineWebRoot, agentFileName, agentName, agentPort, scrapeMapKey, insertName, objPrefix):
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
7 (build / f'{agentFileName}_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
8 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
9 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": agentName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
10 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
11 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": agentName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
12 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
13 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
14 "labels": { "app": agentName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
15 "annotations": { "prometheus.io/scrape": "true", "prometheus.io/path": f"{pipelineWebRoot}/vmagent/metrics", "prometheus.io/port": "80" }
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
16 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
17 "spec": {
60
e3151ab43579 moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents: 57
diff changeset
18 "volumes": [{ "name": "config", "configMap": { "name": f"{objPrefix}-config" } }],
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
19 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
20 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
21 "name": "vmagent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
22 "image": f"docker.io/victoriametrics/vmagent:{vmVersion}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
23 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
24 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
25 f"-http.pathPrefix={pipelineWebRoot}/vmagent/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
26 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
27 f"-promscrape.config=/local/config/{scrapeMapKey}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
28 "-promscrape.configCheckInterval=5s",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
29 "-sortLabels",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
30 f"-remoteWrite.url=http://{insertName}{pipelineWebRoot}/vminsert/insert/0/prometheus/api/v1/write",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
31 "-remoteWrite.showURL",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
32 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
33 "ports": [{ "containerPort": agentPort }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
34 "volumeMounts": [{ "name": "config", "mountPath": "/local/config" }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
35 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
36 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
37 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
38 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
39 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
40
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
41
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
42 def createInsertDeploy(tzArg, vmVersion, pipelineWebRoot, insertName, storageName, insertFileName, insertPort):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
43 (build / f'{insertFileName}_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
44 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
45 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": insertName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
46 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
47 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": insertName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
48 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
49 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
50 "labels": { "app": insertName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
51 "annotations": { "prometheus.io/scrape": "true", "prometheus.io/path": "/m/metrics", "prometheus.io/port": "80" }
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
52 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
53 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
54 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
55 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
56 "name": "vminsert",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
57 "image": f"docker.io/victoriametrics/vminsert:{vmVersion}-cluster",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
58 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
59 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
60 f"-http.pathPrefix={pipelineWebRoot}/vminsert/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
61 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
62 f"-storageNode={storageName}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
63 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
64 "ports": [{ "containerPort": insertPort }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
65 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
66 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
67 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
68 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
69 })) # yapf: disable
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
70
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
71
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
72 def createStorageDeploy(tzArg, vmVersion, pipelineWebRoot, pipelineName, retention, storageName, storageFileName, localPvHost, volName, storageInsertPort, storageSelectPort):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
73 (build / f'{storageFileName}_2deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
74 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
75 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": storageName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
76 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
77 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": storageName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
78 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
79 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
80 "labels": { "app": storageName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
81 "annotations": { "prometheus.io/scrape": "true", "prometheus.io/path": "/m/vmstorage/metrics", "prometheus.io/port": "80" }
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
82 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
83 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
84 "volumes": [{ "name": "data", "persistentVolumeClaim": { "claimName": volName } }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
85 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
86 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
87 "name": "vmstorage",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
88 "image": f"docker.io/victoriametrics/vmstorage:{vmVersion}-cluster",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
89 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
90 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
91 f"-http.pathPrefix={pipelineWebRoot}/vmstorage/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
92 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
93 f"-retentionPeriod={retention}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
94 f"-storageDataPath=/data/{pipelineName}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
95 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
96 "ports": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
97 { "containerPort": 8482, "name": "http" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
98 { "containerPort": storageInsertPort, "name": "vminsert" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
99 { "containerPort": storageSelectPort, "name": "vmselect" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
100 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
101 "volumeMounts": [{ "name": "data", "mountPath": "/data" }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
102 }],
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
103 "affinity": affinityToNode(localPvHost)
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
104 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
105 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
106 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
107 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
108
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
109
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
110 def createVmselectDeploy(tzArg, vmVersion, webRoot, objPrefix, storageSvcs, selectPort):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
111 name = f"{objPrefix}-vmselect"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
112 (build / f'{objPrefix}-1vmselect_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
113 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
114 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
115 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
116 "replicas": 1,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
117 "strategy": { "type": "Recreate" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
118 "selector": { "matchLabels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
119 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
120 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
121 "labels": { "app": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
122 "annotations": { "prometheus.io/scrape": "true", "prometheus.io/path": "/m/metrics", "prometheus.io/port": "80" }
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
123 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
124 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
125 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
126 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
127 "name": "vmselect", "image": f"docker.io/victoriametrics/vmselect:{vmVersion}-cluster", "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
128 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
129 f"-http.pathPrefix={webRoot}/vmselect/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
130 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
131 ] + [f"-storageNode={n}" for n in storageSvcs],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
132 "ports": [{ "containerPort": selectPort }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
133 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
134 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
135 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
136 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
137 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
138
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
139 def createIngestPipeline(tzArg, vmVersion, webRoot, objPrefix, pipelineName, scrapeMapKey, retention):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
140 agentName = f"{objPrefix}-{pipelineName}-vmagent"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
141 insertName = f"{objPrefix}-{pipelineName}-vminsert"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
142 storageName = f"{objPrefix}-{pipelineName}-vmstorage"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
143
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
144 agentFileName = f"{objPrefix}-0{pipelineName}-0vmagent"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
145 insertFileName = f"{objPrefix}-0{pipelineName}-1vminsert"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
146 storageFileName = f"{objPrefix}-0{pipelineName}-2vmstorage"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
147
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
148 localPvHost = "ditto"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
149 insertPort = 8480
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
150 agentPort = 8429
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
151 storageInsertPort = 8400
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
152 storageSelectPort = 8401
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
153 volName = f"{objPrefix}-data-{pipelineName}"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
154 request = "50Gi"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
155 pipelineWebRoot = f'{webRoot}/{pipelineName}'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
156
60
e3151ab43579 moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents: 57
diff changeset
157 createAgentDeploy(tzArg, vmVersion, pipelineWebRoot, agentFileName, agentName, agentPort, scrapeMapKey, insertName, objPrefix)
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
158 createInsertDeploy(tzArg, vmVersion, pipelineWebRoot, insertName, storageName, insertFileName, insertPort)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
159 createPv(storageFileName, volName, request)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
160 createPvc(storageFileName, volName, request)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
161 createStorageDeploy(tzArg, vmVersion, pipelineWebRoot, pipelineName, retention, storageName, storageFileName, localPvHost, volName, storageInsertPort, storageSelectPort)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
162
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
163 createSvc(agentFileName, agentName, [{"port": 80, "targetPort": agentPort}])
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
164 createSvc(insertFileName, insertName, [{"port": 80, "targetPort": insertPort}])
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
165 createSvc(storageFileName,storageName, [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
166 {"port": 80, "targetPort": "http", "name": "http"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
167 {"port": storageInsertPort, "targetPort": "vminsert", "name": "vminsert"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
168 {"port": storageSelectPort, "targetPort": "vmselect", "name": "vmselect"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
169 ]) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
170
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
171 return storageName
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
172
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
173
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
174 def createIndex(objPrefix, webRoot, html):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
175 name = f'{objPrefix}-index'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
176 httpServeRoot = '/opt/html'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
177
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
178 (build / f'{objPrefix}-3index_cmap.yaml').write_text(toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
179 "apiVersion": "v1", "kind": "ConfigMap", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
180 "data": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
181 "index.html": html,
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
182 "index.js": Path("index.js").read_text(),
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
183 "index.css": Path("index.css").read_text(),
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
184 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
185 })) # yapf: disable
62
8134cd480817 make next/ a complete standalone setup dir- no deps on ./
drewp@bigasterisk.com
parents: 60
diff changeset
186
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
187 (build / f'{objPrefix}-3index_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
188 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
189 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
190 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
191 "replicas": 1,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
192 "selector": { "matchLabels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
193 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
194 "metadata": { "labels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
195 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
196 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
197 "name": "webserver", "image": "docker.io/joseluisq/static-web-server", "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
198 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
199 f'--root={httpServeRoot}',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
200 '--directory-listing=true',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
201 '--experimental-metrics=true',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
202 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
203 "ports": [{ "containerPort": 80 }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
204 "volumeMounts": [{ "name": "html", "mountPath": f"{httpServeRoot}{webRoot}" }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
205 }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
206 "volumes": [{ "name": "html", "configMap": { "name": name, "defaultMode": 444 } }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
207 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
208 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
209 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
210 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
211 createSvc(f'{objPrefix}-3index', f'{objPrefix}-index', [{'port': 80, 'targetPort': 80}])
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
212
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
213
69
6a021aa7b4be collect alert obj yaml config for a minute (moving it to py)
drewp@bigasterisk.com
parents: 68
diff changeset
214 def createAlertObjs(objPrefix, webRoot):
71
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
215 (build / f'{objPrefix}-4vmalert_0pv.yaml').write_text(
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
216 toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
217 "apiVersion": "v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
218 "kind": "PersistentVolume",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
219 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
220 "name": "opt-alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
221 "labels": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
222 "type": "local"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
223 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
224 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
225 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
226 "storageClassName": "manual",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
227 "hostPath": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
228 "path": "/opt/alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
229 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
230 "capacity": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
231 "storage": "50Gi"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
232 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
233 "accessModes": ["ReadWriteOnce"],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
234 "persistentVolumeReclaimPolicy": "Retain",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
235 "claimRef": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
236 "namespace": "default",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
237 "name": "opt-alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
238 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
239 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
240 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
241 (build / f'{objPrefix}-4vmalert_1pvc.yaml').write_text(toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
242 "apiVersion": "v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
243 "kind": "PersistentVolumeClaim",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
244 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
245 "name": "opt-alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
246 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
247 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
248 "storageClassName": "",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
249 "volumeName": "opt-alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
250 "accessModes": ["ReadWriteOnce"],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
251 "resources": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
252 "requests": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
253 "storage": "50Gi"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
254 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
255 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
256 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
257 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
258 (build / f'{objPrefix}-4vmalert_2deploy.yaml').write_text(
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
259 toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
260 "apiVersion": "apps/v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
261 "kind": "Deployment",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
262 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
263 "name": "vmalert"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
264 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
265 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
266 "replicas": 1,
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
267 "strategy": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
268 "type": "Recreate"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
269 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
270 "selector": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
271 "matchLabels": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
272 "app": "vmalert"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
273 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
274 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
275 "template": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
276 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
277 "labels": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
278 "app": "vmalert"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
279 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
280 "annotations": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
281 "prometheus.io/scrape": "true"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
282 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
283 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
284 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
285 "volumes": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
286 "name": "config",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
287 "configMap": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
288 "name": "victoriametrics-config"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
289 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
290 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
291 "serviceAccountName":
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
292 "victoriametrics",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
293 "containers": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
294 "name": "vmalert",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
295 "image": "docker.io/victoriametrics/vmalert:v1.91.2",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
296 "args": [
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
297 "-configCheckInterval=5s",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
298 "-datasource.url=http://victoriametrics/m/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
299 "-datasource.queryStep=5m",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
300 "-evaluationInterval=1m",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
301 "-external.url=https://bigasterisk.com/vmalert",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
302 "-loggerLevel=INFO",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
303 "-loggerTimezone=America/Los_Angeles",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
304 "-memory.allowedBytes=512MB",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
305 "-notifier.url=http://alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
306 "-remoteRead.url=http://victoriametrics/m/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
307 "-remoteWrite.url=http://victoriametrics/m/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
308 "-rule=/local/rules",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
309 ],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
310 "ports": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
311 "containerPort": 8880
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
312 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
313 "volumeMounts": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
314 "name": "config",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
315 "mountPath": "/local"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
316 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
317 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
318 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
319 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
320 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
321 }))
69
6a021aa7b4be collect alert obj yaml config for a minute (moving it to py)
drewp@bigasterisk.com
parents: 68
diff changeset
322
71
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
323 (build / f'{objPrefix}-4vmalert_svc.yaml').write_text(toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
324 "apiVersion": "v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
325 "kind": "Service",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
326 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
327 "name": "vmalert"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
328 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
329 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
330 "ports": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
331 "port": 80,
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
332 "targetPort": 8880
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
333 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
334 "selector": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
335 "app": "vmalert"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
336 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
337 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
338 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
339 (build / f'{objPrefix}-5alertmanager_deploy.yaml').write_text(
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
340 toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
341 "apiVersion": "apps/v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
342 "kind": "Deployment",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
343 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
344 "name": "alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
345 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
346 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
347 "replicas": 1,
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
348 "selector": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
349 "matchLabels": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
350 "app": "alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
351 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
352 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
353 "template": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
354 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
355 "labels": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
356 "app": "alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
357 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
358 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
359 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
360 "volumes": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
361 "name": "opt-alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
362 "persistentVolumeClaim": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
363 "claimName": "opt-alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
364 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
365 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
366 "serviceAccountName": "victoriametrics",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
367 "containers": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
368 "name": "alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
369 "image": "docker.io/prom/alertmanager:v0.27.0",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
370 "args": [
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
371 "--config.file=/alertmanager/alertmanager.yml",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
372 "--web.external-url=https://bigasterisk.com/alertmanager/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
373 "--web.route-prefix=/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
374 "--log.level=info",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
375 ],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
376 "ports": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
377 "containerPort": 9093
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
378 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
379 "volumeMounts": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
380 "name": "opt-alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
381 "mountPath": "/alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
382 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
383 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
384 "affinity": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
385 "nodeAffinity": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
386 "requiredDuringSchedulingIgnoredDuringExecution": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
387 "nodeSelectorTerms": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
388 "matchExpressions": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
389 "key": "kubernetes.io/hostname",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
390 "operator": "In",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
391 "values": ["ditto"]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
392 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
393 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
394 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
395 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
396 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
397 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
398 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
399 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
400 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
401 (build / f'{objPrefix}-5alertmanager_svc.yaml').write_text(toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
402 "apiVersion": "v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
403 "kind": "Service",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
404 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
405 "name": "alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
406 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
407 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
408 "ports": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
409 "port": 80,
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
410 "targetPort": 9093
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
411 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
412 "selector": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
413 "app": "alertmanager"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
414 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
415 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
416 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
417 (build / f'{objPrefix}-4vmalert_ingress.yaml').write_text(
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
418 toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
419 "apiVersion": "networking.k8s.io/v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
420 "kind": "Ingress",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
421 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
422 "name": "vmalert",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
423 "annotations": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
424 "cert-manager.io/cluster-issuer": "letsencrypt-prod",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
425 "ingress.pomerium.io/allow_public_unauthenticated_access": "false",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
426 "ingress.pomerium.io/pass_identity_headers": "true",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
427 "ingress.pomerium.io/preserve_host_header": "true",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
428 "ingress.pomerium.io/policy": "allow:\n or: \n - { email: { is: \"drewpca@gmail.com\" }}\n - { email: { is: \"kelsimp@gmail.com\" }}\n"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
429 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
430 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
431 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
432 "ingressClassName": "pomerium",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
433 "rules": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
434 "host": "bigasterisk.com",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
435 "http": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
436 "paths": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
437 "pathType": "Prefix",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
438 "path": "/vmalert/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
439 "backend": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
440 "service": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
441 "name": "vmalert",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
442 "port": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
443 "number": 80
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
444 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
445 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
446 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
447 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
448 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
449 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
450 "tls": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
451 "hosts": ["bigasterisk.com"],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
452 "secretName": "bigasterisk.com-tls"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
453 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
454 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
455 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
456 (build / f'{objPrefix}-5alertmanager_ingress.yaml').write_text(
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
457 toJson({
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
458 "apiVersion": "networking.k8s.io/v1",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
459 "kind": "Ingress",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
460 "metadata": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
461 "name": "alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
462 "annotations": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
463 "cert-manager.io/cluster-issuer": "letsencrypt-prod",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
464 "ingress.pomerium.io/allow_public_unauthenticated_access": "false",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
465 "ingress.pomerium.io/pass_identity_headers": "true",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
466 "ingress.pomerium.io/preserve_host_header": "true",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
467 "ingress.pomerium.io/policy": "allow:\n or: \n - { email: { is: \"drewpca@gmail.com\" }}\n - { email: { is: \"kelsimp@gmail.com\" }}\n",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
468 "ingress.pomerium.io/prefix_rewrite": "/"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
469 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
470 },
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
471 "spec": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
472 "ingressClassName": "pomerium",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
473 "rules": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
474 "host": "bigasterisk.com",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
475 "http": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
476 "paths": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
477 "pathType": "Prefix",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
478 "path": "/alertmanager/",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
479 "backend": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
480 "service": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
481 "name": "alertmanager",
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
482 "port": {
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
483 "number": 80
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
484 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
485 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
486 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
487 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
488 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
489 }],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
490 "tls": [{
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
491 "hosts": ["bigasterisk.com"],
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
492 "secretName": "bigasterisk.com-tls"
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
493 }]
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
494 }
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
495 }))
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
496
69
6a021aa7b4be collect alert obj yaml config for a minute (moving it to py)
drewp@bigasterisk.com
parents: 68
diff changeset
497
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
498 def main():
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
499 tzArg = "-loggerTimezone=America/Los_Angeles"
68
c5e98d891638 remove 'next' prefix
drewp@bigasterisk.com
parents: 67
diff changeset
500 objPrefix = "victoriametrics" # prefix on all k8s object names
c5e98d891638 remove 'next' prefix
drewp@bigasterisk.com
parents: 67
diff changeset
501 webRoot = "/m"
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
502 vmVersion = "v1.100.1"
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
503 webHost = 'bigasterisk.com'
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
504 pipelines = [
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
505 ('forever', '100y'),
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
506 ('recent', '90y'),
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
507 ]
60
e3151ab43579 moving scrape target configs in py, and into separate retention classes
drewp@bigasterisk.com
parents: 57
diff changeset
508 storageSvcs = [createIngestPipeline(tzArg, vmVersion, webRoot, objPrefix, p, f'scrape_{p}.yaml', ret) for p, ret in pipelines]
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
509
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
510 selectPort = 8481
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
511 createVmselectDeploy(tzArg, vmVersion, webRoot, objPrefix, storageSvcs, selectPort)
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
512 createSvc(f'{objPrefix}-1vmselect', f"{objPrefix}-vmselect", [{"port": 80, "targetPort": selectPort}])
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
513
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
514 ingressPaths = [
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
515 { "pathType": "Prefix", "path": f"{webRoot}/", "backend": { "service": { "name": f"{objPrefix}-index", "port": { "number": 80 } } } },
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
516 { "pathType": "Prefix", "path": f"{webRoot}/vmselect/", "backend": { "service": { "name": f"{objPrefix}-vmselect", "port": { "number": 80 } } } },
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
517 ] # yapf: disable
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
518 for p, _ in pipelines:
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
519 ingressPaths.extend([
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
520 { "pathType": "Prefix", "path": f"{webRoot}/{p}/vmagent/", "backend": { "service": { "name": f"{objPrefix}-{p}-vmagent", "port": { "number": 80 } } } },
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
521 { "pathType": "Prefix", "path": f"{webRoot}/{p}/vminsert/", "backend": { "service": { "name": f"{objPrefix}-{p}-vminsert", "port": { "number": 80 } } } },
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
522 { "pathType": "Prefix", "path": f"{webRoot}/{p}/vmstorage/", "backend": { "service": { "name": f"{objPrefix}-{p}-vmstorage", "port": { "number": 80 } } } },
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
523 ]) # yapf: disable
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
524
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
525 policy = """\
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
526 allow:
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
527 or:
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
528 - { email: { is: "drewpca@gmail.com" }}
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
529 - { email: { is: "kelsimp@gmail.com" }}
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
530 """
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
531 createIngress(f'{objPrefix}-2ingress.yaml', objPrefix, policy, ingressPaths, webHost)
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
532 createIndex(objPrefix, webRoot, makeIndexHtml(objPrefix, webRoot, webHost))
69
6a021aa7b4be collect alert obj yaml config for a minute (moving it to py)
drewp@bigasterisk.com
parents: 68
diff changeset
533 createAlertObjs(objPrefix, webRoot)
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
534
71
bfacf01fd119 conv vmalert/alertmanager config to py
drewp@bigasterisk.com
parents: 69
diff changeset
535
57
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
536 main()
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
537
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
538 # in vmui, set server url to
b3addcd4486c extract css/js to their own files
drewp@bigasterisk.com
parents: 56
diff changeset
539 # https://bigasterisk.com{webRoot}/vmselect/select/0/prometheus