tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.6k stars 298 forks source link

docs on how to wire up Argo with Tilt #3045

Open nicks opened 4 years ago

nicks commented 4 years ago

We've had at least two users in the Tilt channel struggle to set up Tilt with Argo

Our current docs on setting up other, similar kinds of CRDs are pretty sparse and don't have good working examples

Gibstick commented 3 years ago

I managed to get it working after seeing https://github.com/tilt-dev/tilt/issues/3679#issuecomment-670942427 and I thought I should share what I did.

For our basic setup we only needed

k8s_kind(
    "WorkflowTemplate",
    api_version="argoproj.io/v1alpha1",
    image_json_path="{.spec.templates[*].container.image}",
    pod_readiness="ignore",
)

combined with docker_build(...) calls for all of the images specified in the WorkflowTemplate. In our use case we didn't want Tilt to keep track of the pods in the workflows themselves so we set pod_readiness="ignore" there.

antoine-de commented 3 years ago

Hi, thanks for the great tool Tilt is!

I'm trying to do the same, using argo with tilt, however argo workflow templates can have several forms.

The image can be either defined in {.spec.templates[*].container.image} or {.spec.templates[*].script.image} or there can be no images at all (for workflow template referring to other workflow templates).

if I use

k8s_kind(
    "WorkflowTemplate",
    api_version="argoproj.io/v1alpha1",
    image_json_path="{.spec.templates[*].container.image}",
    pod_readiness="ignore",
)

I got the error

Matching (json_path="{.spec.templates[*].container.image}"): container is not found

(If I only have a WorkflowTemplate with a .container.image path it works perfectly)

I tried adding the other path

k8s_kind(
    "WorkflowTemplate",
    api_version="argoproj.io/v1alpha1",
    image_json_path=['{.spec.templates[*].container.image}', '{.spec.templates[*].script.image}']
    pod_readiness="ignore",
)

but with the same result.

It seems Tilt is not happy when the image_json_path is not found in all the objects. Is it possible to tell Tilt those paths might sometimes not exists?

antoine-de commented 3 years ago

oh I manage to have the hot reload with a better jsonpath:

k8s_kind(
    'WorkflowTemplate',
    api_version='argoproj.io/v1alpha1',
    image_json_path=[
        '{.spec.templates[?(@.container.image)].container.image}', 
        '{.spec.templates[?(@.script.image)].script.image}'
    ],
    pod_readiness='ignore',
)

It works great :tada: :heart:

nicks commented 3 years ago

@antoine-de thanks for the example! :partying_face:

jdechicchis commented 2 years ago

This is great and it helped us with getting docker_build working with Argo resources such as workflow templates! However, I was curious if there is a way to configure things so the logs from the workflow themself are available in the Tilt UI. Currently, we need to either use the Argo UI or get logs from the workflow using kubectl etc directly. Having a unified place to see logs like for Stateful Sets would be great