Mercurial > code > home > repos > victoriametrics
view tasks.py @ 72:85d9dae18656
fix up vmalert k8s objs
author | drewp@bigasterisk.com |
---|---|
date | Fri, 03 May 2024 13:33:33 -0700 |
parents | 68164135ae66 |
children |
line wrap: on
line source
from pathlib import Path import yaml from invoke import task from kubernetes import config import alert_rules from k8s_ops import firstPodName, refreshPodCmaps, replaceCmap config.load_kube_config() def scrapeConfig(fn): return yaml.load(open(fn), yaml.FullLoader) @task def build_k8s_config(ctx): ctx.run('pdm run python create_k8s.py') @task def build_scrape_config(ctx): ctx.run('pdm run python create_scrape_configs.py') @task(pre=[build_k8s_config, build_scrape_config]) def push_config(ctx): cmap: dict[str, object] = { 'rules': alert_rules.allRules(ctx), } top = Path('build/scrape_config') for p in top.glob('*.yaml'): cmap[str(p.relative_to(top))] = scrapeConfig(p) replaceCmap("victoriametrics-config", cmap) # note: these will fail on first run, since you have to make config before # you can launch the service for the first time. Also, these won't error if # there are problems with the config. Watch the vmagent (etc) logs. refreshPodCmaps(firstPodName("app=victoriametrics-forever-vmagent")) refreshPodCmaps(firstPodName("app=victoriametrics-recent-vmagent"))