annotate next/create_all.py @ 56:a72c47973aa4

parameterize the python version
author drewp@bigasterisk.com
date Fri, 26 Apr 2024 16:10:47 -0700
parents 24f4ec319f98
children b3addcd4486c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
1 from index_page import makeIndexHtml
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
2 from output import affinityToNode, build, createIngress, createPv, createPvc, toJson, createSvc
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
3
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
4
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
5 def createAgentDeploy(tzArg, vmVersion, pipelineWebRoot, agentFileName, agentName, agentPort, scrapeMapKey, insertName, pipelineName):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
6 (build / f'{agentFileName}_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
7 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
8 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": agentName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
9 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
10 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": agentName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
11 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
12 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
13 "labels": { "app": agentName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
14 "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
15 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
16 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
17 "volumes": [{ "name": "config", "configMap": { "name": "victoriametrics-config" } }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
18 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
19 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
20 "name": "vmagent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
21 "image": f"docker.io/victoriametrics/vmagent:{vmVersion}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
22 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
23 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
24 f"-http.pathPrefix={pipelineWebRoot}/vmagent/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
25 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
26 f"-promscrape.config=/local/config/{scrapeMapKey}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
27 "-promscrape.configCheckInterval=5s",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
28 "-sortLabels",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
29 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
30 "-remoteWrite.showURL",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
31 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
32 "ports": [{ "containerPort": agentPort }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
33 "volumeMounts": [{ "name": "config", "mountPath": "/local/config" }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
34 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
35 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
36 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
37 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
38 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
39
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
40
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
41 def createInsertDeploy(tzArg, vmVersion, pipelineWebRoot, insertName, storageName, insertFileName, insertPort):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
42 (build / f'{insertFileName}_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
43 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
44 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": insertName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
45 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
46 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": insertName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
47 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
48 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
49 "labels": { "app": insertName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
50 "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
51 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
52 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
53 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
54 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
55 "name": "vminsert",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
56 "image": f"docker.io/victoriametrics/vminsert:{vmVersion}-cluster",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
57 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
58 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
59 f"-http.pathPrefix={pipelineWebRoot}/vminsert/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
60 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
61 f"-storageNode={storageName}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
62 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
63 "ports": [{ "containerPort": insertPort }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
64 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
65 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
66 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
67 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
68 })) # yapf: disable
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
69
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
70
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
71 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
72 (build / f'{storageFileName}_2deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
73 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
74 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": storageName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
75 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
76 "replicas": 1, "strategy": { "type": "Recreate" }, "selector": { "matchLabels": { "app": storageName } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
77 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
78 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
79 "labels": { "app": storageName },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
80 "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
81 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
82 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
83 "volumes": [{ "name": "data", "persistentVolumeClaim": { "claimName": volName } }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
84 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
85 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
86 "name": "vmstorage",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
87 "image": f"docker.io/victoriametrics/vmstorage:{vmVersion}-cluster",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
88 "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
89 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
90 f"-http.pathPrefix={pipelineWebRoot}/vmstorage/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
91 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
92 f"-retentionPeriod={retention}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
93 f"-storageDataPath=/data/{pipelineName}",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
94 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
95 "ports": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
96 { "containerPort": 8482, "name": "http" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
97 { "containerPort": storageInsertPort, "name": "vminsert" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
98 { "containerPort": storageSelectPort, "name": "vmselect" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
99 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
100 "volumeMounts": [{ "name": "data", "mountPath": "/data" }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
101 }],
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
102 "affinity": affinityToNode(localPvHost)
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
103 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
104 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
105 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
106 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
107
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
108
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
109 def createVmselectDeploy(tzArg, vmVersion, webRoot, objPrefix, storageSvcs, selectPort):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
110 name = f"{objPrefix}-vmselect"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
111 (build / f'{objPrefix}-1vmselect_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
112 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
113 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
114 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
115 "replicas": 1,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
116 "strategy": { "type": "Recreate" },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
117 "selector": { "matchLabels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
118 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
119 "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
120 "labels": { "app": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
121 "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
122 },
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
123 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
124 "serviceAccountName": "victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
125 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
126 "name": "vmselect", "image": f"docker.io/victoriametrics/vmselect:{vmVersion}-cluster", "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
127 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
128 f"-http.pathPrefix={webRoot}/vmselect/",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
129 tzArg,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
130 ] + [f"-storageNode={n}" for n in storageSvcs],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
131 "ports": [{ "containerPort": selectPort }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
132 }]
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
133 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
134 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
135 }
56
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
136 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
137
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
138 def createIngestPipeline(tzArg, vmVersion, webRoot, objPrefix, pipelineName, scrapeMapKey, retention):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
139 agentName = f"{objPrefix}-{pipelineName}-vmagent"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
140 insertName = f"{objPrefix}-{pipelineName}-vminsert"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
141 storageName = f"{objPrefix}-{pipelineName}-vmstorage"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
142
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
143 agentFileName = f"{objPrefix}-0{pipelineName}-0vmagent"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
144 insertFileName = f"{objPrefix}-0{pipelineName}-1vminsert"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
145 storageFileName = f"{objPrefix}-0{pipelineName}-2vmstorage"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
146
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
147 localPvHost = "ditto"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
148 insertPort = 8480
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
149 agentPort = 8429
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
150 storageInsertPort = 8400
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
151 storageSelectPort = 8401
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
152 volName = f"{objPrefix}-data-{pipelineName}"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
153 request = "50Gi"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
154 pipelineWebRoot = f'{webRoot}/{pipelineName}'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
155
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
156 createAgentDeploy(tzArg, vmVersion, pipelineWebRoot, agentFileName, agentName, agentPort, scrapeMapKey, insertName, pipelineName)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
157 createInsertDeploy(tzArg, vmVersion, pipelineWebRoot, insertName, storageName, insertFileName, insertPort)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
158 createPv(storageFileName, volName, request)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
159 createPvc(storageFileName, volName, request)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
160 createStorageDeploy(tzArg, vmVersion, pipelineWebRoot, pipelineName, retention, storageName, storageFileName, localPvHost, volName, storageInsertPort, storageSelectPort)
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
161
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
162 createSvc(agentFileName, agentName, [{"port": 80, "targetPort": agentPort}])
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
163 createSvc(insertFileName, insertName, [{"port": 80, "targetPort": insertPort}])
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
164 createSvc(storageFileName,storageName, [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
165 {"port": 80, "targetPort": "http", "name": "http"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
166 {"port": storageInsertPort, "targetPort": "vminsert", "name": "vminsert"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
167 {"port": storageSelectPort, "targetPort": "vmselect", "name": "vmselect"},
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
168 ]) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
169
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
170 return storageName
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
171
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 def createIndex(objPrefix, webRoot, html):
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
174 name = f'{objPrefix}-index'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
175 httpServeRoot = '/opt/html'
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
176
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
177 (build / f'{objPrefix}-3index_cmap.yaml').write_text(toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
178 "apiVersion": "v1", "kind": "ConfigMap", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
179 "data": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
180 "index.html": html,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
181 (??) }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
182 (??) }))
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
183 (??)(build / 'vmselect_svc.yaml').write_text(toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
184 (??) "apiVersion": "v1",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
185 (??) "kind": "Service",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
186 (??) "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
187 (??) "name": "next-victoriametrics-vmselect"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
188 (??) },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
189 (??) "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
190 (??) "ports": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
191 (??) "port": 80,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
192 (??) "targetPort": 8481
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
193 (??) }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
194 (??) "selector": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
195 (??) "app": "next-victoriametrics-vmselect"
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
196 (??) }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
197 (??) }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
198 (??)}
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
199 (??) # in vmui, set server url to
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
200 (??) # https://bigasterisk.com/m/next/vmselect/select/0/prometheus
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
201 (??) ))
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 (??)(build / 'vmselect_svc.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
204 (??) toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
205 (??) "apiVersion": "networking.k8s.io/v1",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
206 (??) "kind": "Ingress",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
207 (??) "metadata": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
208 (??) "name": "next-victoriametrics",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
209 (??) "annotations": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
210 (??) "cert-manager.io/cluster-issuer": "letsencrypt-prod",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
211 (??) "ingress.pomerium.io/allow_public_unauthenticated_access": "false",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
212 (??) "ingress.pomerium.io/pass_identity_headers": "true",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
213 (??) "ingress.pomerium.io/preserve_host_header": "true",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
214 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
215
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
216 (build / f'{objPrefix}-3index_deploy.yaml').write_text(
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
217 toJson({
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
218 "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": name },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
219 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
220 "replicas": 1,
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
221 "selector": { "matchLabels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
222 "template": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
223 "metadata": { "labels": { "app": name } },
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
224 "spec": {
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
225 "containers": [{
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
226 "name": "webserver", "image": "docker.io/joseluisq/static-web-server", "imagePullPolicy": "IfNotPresent",
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
227 "args": [
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
228 f'--root={httpServeRoot}',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
229 '--directory-listing=true',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
230 '--experimental-metrics=true',
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
231 ],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
232 "ports": [{ "containerPort": 80 }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
233 "volumeMounts": [{ "name": "html", "mountPath": f"{httpServeRoot}{webRoot}" }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
234 }],
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
235 "volumes": [{ "name": "html", "configMap": { "name": name, "defaultMode": 444 } }]
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
236 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
237 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
238 }
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
239 })) # yapf: disable
a72c47973aa4 parameterize the python version
drewp@bigasterisk.com
parents: 55
diff changeset
240 createSvc(f'{objPrefix}-3index', f'{objPrefix}-index', [{'port': 80, 'targetPort': 80}])
55
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
241
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
242 (build / 'vmselect_svc.yaml').write_text(
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
243 toJson({
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
244 "apiVersion": "networking.k8s.io/v1",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
245 "kind": "Ingress",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
246 "metadata": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
247 "name": "next-victoriametrics",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
248 "annotations": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
249 "cert-manager.io/cluster-issuer": "letsencrypt-prod",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
250 "ingress.pomerium.io/allow_public_unauthenticated_access": "false",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
251 "ingress.pomerium.io/pass_identity_headers": "true",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
252 "ingress.pomerium.io/preserve_host_header": "true",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
253 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
254 },
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
255 "spec": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
256 "ingressClassName": "pomerium",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
257 "rules": [{
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
258 "host": "bigasterisk.com",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
259 "http": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
260 "paths": [{
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
261 "pathType": "Prefix",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
262 "path": "/m/next/vmselect/",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
263 "backend": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
264 "service": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
265 "name": "next-victoriametrics-vmselect",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
266 "port": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
267 "number": 80
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
268 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
269 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
270 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
271 }, {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
272 "pathType": "Prefix",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
273 "path": "/m/next/vmagent/",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
274 "backend": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
275 "service": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
276 "name": "next-victoriametrics-vmagent",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
277 "port": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
278 "number": 80
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
279 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
280 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
281 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
282 }, {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
283 "pathType": "Prefix",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
284 "path": "/m/next/vmselect/",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
285 "backend": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
286 "service": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
287 "name": "next-victoriametrics-vmselect",
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
288 "port": {
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
289 "number": 80
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
290 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
291 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
292 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
293 }]
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
294 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
295 }],
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
296 "tls": [{
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
297 "hosts": ["bigasterisk.com"],
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
298 "secretName": "bigasterisk.com-tls"
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
299 }]
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
300 }
24f4ec319f98 yaml to py
drewp@bigasterisk.com
parents:
diff changeset
301 }))