forked from tilt-dev/tilt-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tiltfile
100 lines (84 loc) · 2.93 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- mode: Python -*-
load('../Tiltfile', 'helm_resource', 'helm_repo')
is_windows = True if os.name == "nt" else False
python_cmd = ['py', '-3'] if is_windows else ['python3']
local_resource(
name='unittest',
cmd=python_cmd + ['../namespacing_test.py'])
docker_build(
'helloworld-image',
'./src',
dockerfile='./Dockerfile')
# The ./helloworld helm chart is the default
# chart generated by 'helm create'
helm_resource(
'helloworld',
'./helloworld',
namespace='app',
deps=['./helloworld'],
image_deps=['helloworld-image'],
image_keys=[('image.repository', 'image.tag')],
labels=['helloworld'],
flags=['--create-namespace'])
python_check = '; '.join((
'import subprocess',
'import re',
'output = subprocess.run("{}".split(), capture_output=True, text=True)',
'output_txt = re.sub("[\\n|\\r]", "", output.stdout)',
'assert output_txt == {}, f"actual output: {{output_txt}}"'))
python_test_wrap = "\'\\'{}\\'\'"
# Check that our `namespace:` was preserved in configmap data
helloworld_check_kubectl = " ".join(('kubectl get',
'configmap/configmap-namespace-data',
'--namespace app',
"-o jsonpath=\\'{.data.properties}\\'"))
helloworld_test = python_test_wrap.format('namespace:')
local_resource(
'helloworld-check',
python_cmd + ["-c", python_check.format(helloworld_check_kubectl, helloworld_test)],
labels=['helloworld'],
resource_deps=['helloworld'])
# Make sure helm charts that install to multiple namespaces work.
check_multi_namespace_kubectl = " ".join(('kubectl get',
'configmap/helloworld-systemconfig',
'--namespace kube-public',
"-o jsonpath=\\'{.data.hello}\\'"))
multi_namespace_test = python_test_wrap.format('world')
local_resource(
'helloworld-check-multi-namespace',
python_cmd + ["-c", python_check.format(check_multi_namespace_kubectl, multi_namespace_test)],
labels=['helloworld'],
resource_deps=['helloworld'])
helm_resource(
'helloregistry',
'./helloregistry',
namespace='app',
deps=['./helloregistry'],
image_deps=['helloworld-image'],
image_keys=[('image.registry', 'image.repository', 'image.tag')],
labels=['helloregistry'],
flags=['--create-namespace'])
k8s_resource(
'helloworld',
port_forwards=['8080:80'])
k8s_resource(
'helloregistry',
port_forwards=['8081:80']
)
helm_repo(
'bitnami',
'https://charts.bitnami.com/bitnami',
labels=['memcached'],
resource_name='helm-repo-bitnami')
helm_resource(
'memcached',
'bitnami/memcached',
labels=['memcached'],
flags=['--version=6.3.14'],
resource_deps=['helm-repo-bitnami'])
helm_resource(
'memcached-no-init',
'bitnami/memcached',
labels=['memcached'],
resource_deps=['helm-repo-bitnami'],
auto_init=False)