forked from containers/nri-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tiltfile
63 lines (53 loc) · 1.88 KB
/
Tiltfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- mode: Python -*-
# Extensions
load('ext://helm_resource', 'helm_resource', 'helm_repo')
# Specifies that Tilt is allowed to run against the specified k8s context name.
allow_k8s_contexts('kubernetes-admin@kubernetes')
# Anonymous, ephemeral image registry.
default_registry('ttl.sh')
# Run a defined set of services via config.set_enabled_resources.
config.define_string_list("to-run", args=True)
cfg = config.parse()
groups = {
'balloons': ['binary-build-logs', 'controller-logs'],
'topology-aware': ['binary-build-logs', 'controller-logs'],
}
resources = []
for resource_name in cfg.get('to-run', []):
if resource_name in groups:
resources += groups[resource_name]
config.set_enabled_resources(resources)
# Fail if the policy name is not provided.
if len(resources) == 0:
fail("🚨 ERROR: No policy passed! Please run: tilt up <POLICY_NAME>")
POLICY = resource_name
IMAGE_BASE = "ttl.sh/ghcr.io/containers/nri-plugins/nri-resource-policy-"
IMAGE = IMAGE_BASE + POLICY
COMPILE_CMD = ('make BINARIES= OTHER_IMAGE_TARGETS= PLUGINS=nri-resource-policy-' + POLICY + ' build-plugins')
DEPS = ['./pkg', './cmd', './deployment']
###################################
# The main tasks are executed here.
###################################
# Builds a binary.
local_resource(
'binary-build-logs',
COMPILE_CMD,
deps=DEPS
)
# Builds a container image.
docker_build(
IMAGE,
'.',
dockerfile='./cmd/plugins/' + POLICY + '/Dockerfile'
)
# Deploy the policy Helm chart.
helm_resource(
'controller-logs',
'./deployment/helm/' + POLICY,
namespace='kube-system',
deps=DEPS,
image_deps=[IMAGE],
image_keys=[('image.registry', 'image.repository', 'image.tag')],
flags=['--set=config.instrumentation.prometheusExport=true','--set=ports[0].name=metrics','--set=ports[0].container=8891','--set=image.name=' + IMAGE],
resource_deps=['binary-build-logs']
)