Created
December 26, 2020 08:14
-
-
Save frimik/afd687fec7f5ad6ac8f0ee52d91edd16 to your computer and use it in GitHub Desktop.
Tilt.dev, Tanka, Jsonnet experiments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
_tilt+:: { | |
megapush: { | |
registry: '', | |
port_forwards: [ | |
{ | |
port: $._config.megapush.port, | |
name: 'http', | |
}, | |
{ | |
port: $._config.megapush.admin_port, | |
name: 'stats', | |
link_path: '/stats', | |
}, | |
], | |
}, | |
megaproxy: { | |
registry: '', | |
port_forwards: [ | |
{ | |
port: $._config.megaproxy.health_port, | |
name: 'health', | |
link_path: $._config.megaproxy.environmentMap.HAPROXY_STATS_URI, | |
}, | |
], | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Beginning Tiltfile execution | |
local: tk eval environments/default -e '_tilt' | |
→ { | |
→ "megaproxy": { | |
→ "port_forwards": [ | |
→ { | |
→ "link_path": "/haproxy/stats", | |
→ "name": "health", | |
→ "port": 8404 | |
→ } | |
→ ], | |
→ "registry": "" | |
→ }, | |
→ "megapush": { | |
→ "port_forwards": [ | |
→ { | |
→ "name": "http", | |
→ "port": 6050 | |
→ }, | |
→ { | |
→ "link_path": "/stats", | |
→ "name": "stats", | |
→ "port": 6053 | |
→ } | |
→ ], | |
→ "registry": "" | |
→ } | |
→ } | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Tiltfile for megapush | |
""" | |
load("lib/Tiltfile", "tanka_tilt") | |
tanka_tilt("megapush") | |
""" Library snippet from `lib/Tiltfile` | |
""" | |
def tanka_tilt(application, tilt_config=None): | |
"""Tilt everything based on a config dictionary object | |
Args: | |
application (str): Application name | |
tilt_config (dict): Dictionary object containing all the necessary items. If not set will eval the default Tanka environment. | |
""" | |
allow_k8s_contexts(["local", "k3d-local", "k3d-k3s-default", "kind"]) | |
if not tilt_config: | |
tilt_config = decode_json(local("tk eval environments/default -e '_tilt'")) | |
watch_libsonnet_files(application) | |
for (_key, _tilt_obj) in tilt_config.items(): | |
print(_key) | |
if _tilt_obj: | |
_path = _tilt_obj.get("path", _key) | |
_image_ref = os.path.join(_tilt_obj["registry"], application, _key) | |
print("Queuing for docker build: {0}, {1}".format(_image_ref, _path)) | |
docker_build(_image_ref, _path) | |
_port_forwards=[] | |
for _p in _tilt_obj.get('port_forwards'): | |
_port_forwards.append(port_forward(int(_p['port']), name = _p['name'], link_path = _p.get('link_path', '/'))) | |
k8s_resource( | |
workload = _key, | |
port_forwards = _port_forwards | |
) | |
watch_tanka_environment() | |
k8s_yaml(local("tk show --dangerous-allow-redirect environments/default")) | |
local_resource("kubectl events", serve_cmd = "kubectl get events -A -w") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is interesting. Do you have the source for he other tanka functions listed above that you can share?