tilt-dev / tilt-dev/tilt

Support arrays in k8s_kind's json_path (Play nice with ArgoCD)

Open
#6,045 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
10.1k
Forks
413
Avg merge
1d 10h
Merged PRs (30d)
6

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating k8s_kind's json_path handling and the image lookup path; reproduce the shown Tiltfile against the Application manifest. Done means array paths and the listed repository/tag filters resolve without the current “May only match maps” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes
Domain
devops, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.