Mercurial > code > home > repos > victoriametrics
annotate tasks.py @ 54:21185db8a52e
refactor
author | drewp@bigasterisk.com |
---|---|
date | Wed, 24 Apr 2024 12:08:39 -0700 |
parents | 3b91d52b007d |
children | 0064c490c33d |
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): |
32
eb1de82c93aa
refactor the merging of all the groups
drewp@bigasterisk.com
parents:
27
diff
changeset
|
13 rulesObj = alert_rules.allRules(ctx) |
10 | 14 |
54 | 15 replaceCmap("victoriametrics-config", { |
16 "scrape_main": scrapeConfig("config/scrape_main.yaml"), | |
17 "rules": rulesObj, | |
18 }) | |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
19 |
34 | 20 # these don't give errors on rules format! they just quietly keep the old |
21 # rules! use `skaffold run` to get errs. | |
22 # | |
23 # or run | |
24 # validateTemplates = flag.Bool("rule.validateTemplates", true, "Whether to validate annotation and label templates") | |
54 | 25 # validateExpressions = flag.Bool("rule.validateExpressions", true, "Whether to validate rules expressions via MetricsQL engine") |
34 | 26 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
27 refreshPodCmaps(firstPodName("app=victoriametrics")) |
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
28 refreshPodCmaps(firstPodName("app=vmalert")) |
4
1eb6e6a2b9b6
version control configs finally; use configmaps to present them to VM
drewp@bigasterisk.com
parents:
diff
changeset
|
29 |
22
cd115f1ca2a8
use configmaps and a special pod refresh trick
drewp@bigasterisk.com
parents:
20
diff
changeset
|
30 # 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
|
31 # hup(ctx, 'deploy/victoriametrics', 'victoria-metrics-prod') |
20 | 32 |
33 | |
54 | 34 def scrapeConfig(fn): |
35 return yaml.load(open(fn), yaml.FullLoader) |