Skip to content

Instantly share code, notes, and snippets.

@frimik
Created December 26, 2020 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frimik/afd687fec7f5ad6ac8f0ee52d91edd16 to your computer and use it in GitHub Desktop.
Save frimik/afd687fec7f5ad6ac8f0ee52d91edd16 to your computer and use it in GitHub Desktop.
Tilt.dev, Tanka, Jsonnet experiments.
{
_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,
},
],
},
}
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": ""
→ }
→ }
...
""" 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")
@bcotton
Copy link

bcotton commented Jan 28, 2023

This is interesting. Do you have the source for he other tanka functions listed above that you can share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment