Mercurial > code > home > repos > victoriametrics
annotate tasks.py @ 31:d39a8038227b
reformat
author | drewp@bigasterisk.com |
---|---|
date | Wed, 19 Jul 2023 21:27:46 -0700 |
parents | eec015e90818 |
children | eb1de82c93aa |
rev | line source |
---|---|
20 | 1 import yaml |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
2 from invoke import task |
20 | 3 from kubernetes import config |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
4 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
5 import alert_rules |
27 | 6 from k8s_ops import firstPodName, refreshPodCmaps, replaceCmap |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
7 |
20 | 8 config.load_kube_config() |
12 | 9 |
10 | |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
11 @task |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
12 def push_config(ctx): |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
13 configObj = scrapeConfig(ctx) |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
14 rulesObj = alert_rules.allRules() |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
15 rulesObj["groups"] += alert_rules.expectedK8sNodes(ctx)["groups"] |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
16 rulesObj["groups"] += alert_rules.hostsExpectedOnline(ctx)["groups"] |
10 | 17 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
18 replaceCmap("victoriametrics-config", {"scrape_main": configObj, "rules": rulesObj}) |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
19 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
20 refreshPodCmaps(firstPodName("app=victoriametrics")) |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
21 refreshPodCmaps(firstPodName("app=vmalert")) |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
22 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
23 # If the VM reloader isn't fast enough, we could do this too: |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
24 # hup(ctx, 'deploy/victoriametrics', 'victoria-metrics-prod') |
20 | 25 |
26 | |
27 def scrapeConfig(ctx): | |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
28 return yaml.load(open("config/scrape_main.yaml"), yaml.FullLoader) |