tilt icon indicating copy to clipboard operation
tilt copied to clipboard

When specifying a deployment namespace with `tilt up --namespace <NAMESPACE>`, if `<NAMESPACE>` does not currently exist, create the namespace.

Open peter-mcclonski opened this issue 1 year ago • 4 comments

Describe the Feature You Want

When specifying a deployment namespace with tilt up --namespace <NAMESPACE>, if <NAMESPACE> does not currently exist, create the namespace.

Current Behavior

If the namespace does not already exist, deployments will fail.

Why Do You Want This?

There is currently no good way to have a custom namespace created for tilt. Based on the initial description of this flag on release (https://blog.tilt.dev/2021/06/30/namespace-flag.html), it's implied that previous uses of the namespace extension, including namespace_create('test-default') should be fully replaced by the flag.

peter-mcclonski avatar Apr 16 '24 17:04 peter-mcclonski

hmmm...i'm not sure we should do this.

The tilt --namespace flag is indented to map to kubectl --namespace. In kubectl, it sets the default namespace for API requests - https://pkg.go.dev/k8s.io/[email protected]/tools/clientcmd/api/v1#Context

kubectl --namespace=... apply does not auto-create the namespace.

Helm has a separate --create-namespace flag, which you can simulate in tilt as:

namespace_create(k8s_namespace())

nicks avatar Apr 16 '24 19:04 nicks

@nicks Fair concerns. Regardless, I would make the case that this is a reasonable quality-of-life improvement. If tying it directly to the --namespace flag is undesirable, perhaps adding a separate tilt --create-namespace flag to be analogous to the underlying helm --create-namespace flag?

I would make the argument that the current reliance namespace_create(k8s_namespace()) is non-intuitive, and contrasts with the linked tilt feature announcement. The --namespace flag being provided out of the box contrasts with the need to load a separate extension for namespace_create(...). At minimum, if specifying the --namespace flag and the namespace does not exist, I would expect to see the initial tilt up fail immediately.

peter-mcclonski avatar Apr 16 '24 19:04 peter-mcclonski

ya, i guess we'd accept a --create-namespace flag that mirrors the helm flag behavior

nicks avatar Apr 19 '24 20:04 nicks

To make sure we're on the same page-- I'm thinking that this would be a tilt flag on the up command. For instance, tilt up --create-namespace. The flag would be meaningless (and provide an associated error) if not paired with the --namespace flag, and it would result in the namespace being created prior to the actual contents of the Tiltfile being processed.

peter-mcclonski avatar Apr 20 '24 14:04 peter-mcclonski