Mercurial > code > home > repos > victoriametrics
view tasks.py @ 10:2023a6ce7bc0
some of the config-rebuild code
author | drewp@bigasterisk.com |
---|---|
date | Sun, 04 Dec 2022 02:09:40 -0800 |
parents | 1eb6e6a2b9b6 |
children | b6720e379d5b |
line wrap: on
line source
import json import sys import tempfile import time import urllib.request from pathlib import Path from typing import Dict from invoke import task def updateConfigmapCmd(path): return f'kubectl create configmap victoriametrics-config --from-file {path}=config/{path} -o yaml --dry-run=client | kubectl apply -f -' def reload(ctx, svc): host = ctx.run(f'khost {svc}').stdout path = {'victoriametrics': '/m', 'vmalert': '/vmalert'}[svc] print(' -> status', urllib.request.urlopen(f'http://{host}{path}/-/reload').status) def hostsExpectedOnline(ctx): return ctx.run( 'cd /my/serv/lanscape; pdm run python hosts_expected_online.py').stdout @task def sync_config(ctx): ctx.run(updateConfigmapCmd("scrape_config.yaml")) ctx.run(updateConfigmapCmd("scrape_ssl.yaml")) reload(ctx, 'victoriametrics') ctx.run(updateConfigmapCmd("rules_expected_hosts.yaml")) ctx.run(updateConfigmapCmd("rules_expected_nodes.yaml")) ctx.run(updateConfigmapCmd("rules_k8s.yaml")) ctx.run(updateConfigmapCmd("rules_main.yaml")) reload(ctx, 'vmalert') @task def build_config(ctx): with open('rules/build/expected_hosts.yaml', 'w') as out: out.write(hostsExpectedOnline(ctx))