view tasks.py @ 6:ae41d1d0b567

no longer running my lanscape/main.lua ntop plugin
author drewp@bigasterisk.com
date Sat, 03 Sep 2022 23:42:01 -0700
parents 1eb6e6a2b9b6
children 2023a6ce7bc0
line wrap: on
line source

import urllib.request
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)


@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')