tilt
tilt copied to clipboard
Support arrays in k8s_kind's json_path (Play nice with ArgoCD)
Describe the Feature You Want
We use Helm to render manifests via ArgoCD.
We would like to modify Argocd Application CRDs with Tilt in our dev cluster.
Unfortunately, this CRD only allows us define the container image via a string field (.spec.source.helm.values), or as an array (spec.source.helm.parameters).
Therefore, we would need Tilt to allow the following config:
# Tiltfile
k8s_kind(
kind = 'Application',
image_object = {
'json_path': '{.spec.source.helm.parameters}',
'repo_field': '.[?(@.name=="image.repository")].value',
'tag_field': '.[?(@.name=="image.tag")].value'
}
)
---
# Application manifest
apiVersion: argoproj.io/v1alpha1
kind: Application
spec:
source:
...
helm:
parameters:
- name: image.repository
value: <my-repo-and-image>
- name: image.tag
value: <my-image-tag>
Current Behavior
tilt up will throw the following error:
finding image in Application/hello-kubernetes: May only match maps (json_path="{.spec.source.helm.parameters}") Got Type: interface {} Got Value: <interface {} Value>
Why Do You Want This?
We would like to incorporate Tilt as a tool for speeding up container development in a mature platform with ArgoCD at its core.
ArgoCD already handles the deployment of manifests; we think that Tilt's ideal role would be to modify pre-existing Application objects, instead of competing with ArgoCD over the rights to manipulate downstream resources like deployments and pods.
I think that Tilt can potentially be a very powerful complementary tool in ArgoCD stacks.
Right now, the only thing that's missing is a straight-forward approach to manipulating the Application CRDs via the Tiltfile.
Additional context
I would also add that Tilt seems to be quite oriented toward deploying and deleting manifests via tilt up and tilt down. When incorporating Tilt into ArgoCD driven platforms, Tilt's role would be to modify existing manifests rather than creating and destroying.
I've learned that it's possible to tweak Tilt in this direction, for example via annotations:
metadata:
...
annotations:
tilt.dev/down-policy: keep
Or via config.tilt_subcommand:
if (config.tilt_subcommand == "up"):
<modify existing stuff>
elif (config.tilt_subcommand == "down")
<reset existing stuff, but don't delete it>
It would be nice to have some built in functionality for managing ArgoCD applications, or a chapter of the documentation on how to incorporate Tilt into a cluster managed by ArgoCD. I would be happy to contribute this when I have working example.
I like the syntax you proposed for using repo/tag field selectors. i think we'd accept something like this.
HOWEVER -- if you're thinking about this as part of a bigger project to improve interop between Tilt and ArgoCD, you might consider an extension that uses k8s_custom_deploy: https://blog.tilt.dev/2021/12/03/k8s-custom-deploy.html It's a bit harder to setup & use -- you're essentially replacing Tilt's deploy engine with your own bash script. But it is built exactly for the use case of "I have a custom CD system that I want to use as the deploy engine". We use it to implement the helm_resource extension under the covers.