Skip to content

Tilt down not respecting --context argument #6554

@mishafeingold

Description

@mishafeingold

Expected Behavior

If my current context is on lets say prod-k8s-cluster and I run tilt up --context minikube and then run tilt down --context minikube then all resources specified in the tilt file should be deleted in the local minikube cluster because we overrode the context.

Current Behavior

tilt up --context minikube works as intended and spins up resources in the minikube context. However, when I run tilt down --context minikube it actually deletes resources on whatever context you are on and not the context which was overriden. In my case my kube context was on a production cluster and even though I passed in tilt down --context minikube, Tilt deleted resources on the production cluster which is very bad.

Steps to Reproduce

Note we are using the following extensions in our tilt file

# Load extensions
load("ext://helm_resource", "helm_resource", "helm_repo") # direct
load('ext://namespace', 'namespace_create', 'namespace_inject')
load('ext://secret', 'secret_from_dict')
load('ext://uibutton', 'cmd_button', 'text_input', 'location')
  1. Switch contexts using kubectx to another cluster ex kubectx dev
  2. Run tilt up --context minikube
  3. Run tilt down --context minikube

Context

tilt doctor Output

❯ tilt doctor
Tilt: v0.34.3, built 2025-05-14
System: darwin-arm64
---
Docker (cluster)
- Host: tcp://127.0.0.1:60536
- Server Version: 27.4.1
- API Version: 1.47
- Builder: 2
---
Docker (local)
- Host: unix:///Users/mfein0529/.docker/run/docker.sock
- Server Version: 28.0.4
- Version: 1.48
- Builder: 2
- Compose Version: v2.34.0-desktop.1
---
Kubernetes
- Env: minikube
- Context: minikube
- Cluster Name: minikube
- Namespace: default
- Container Runtime: docker
- Version: v1.32.3
- Cluster Local Registry: none
---
Thanks for seeing the Tilt Doctor!
Please send the info above when filing bug reports. 💗

The info below helps us understand how you're using Tilt so we can improve,
but is not required to ask for help.
---
Analytics Settings
--> (These results reflect your personal opt in/out status and may be overridden by an `analytics_settings` call in your Tiltfile)
- User Mode: opt-out
- Machine: ae6f6818c4ffc076ce90de470fec7146
- Repo: KC/K1MlNv0jQAwqGJsRFEA==
...

About Your Use Case

This actually caused me to delete production resources by accident. Usually tilt would detect that the context is not minikube or a local k8s env and stop this from happening. If I were to switch contexts and run any of the tilt commands without using the --context minikube argument, then everything works as usual and warns me and not proceeded. However the --context argument for specifically tilt down appears to be bugged in some way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions