carvel-dev / kwt

Kubernetes Workstation Tools CLI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[workspace] non-default images do not support injecting inputs?

drnic opened this issue · comments

$ kwt workspace create -i app=. --rm --enter
... works as expected

$ kwt workspace create -i app=. --rm --enter --image ubuntu:18.04
Name        w-gdjm5
Image       ubuntu:18.04
Ports       -
Privileged  false

[2018-10-16T11:35:13+10:00] Waiting for workspace...

[2018-10-16T11:35:18+10:00] Uploading input 'app'...

[2018-10-16T11:35:19+10:00] Finished uploading input 'app'...

[2018-10-16T11:35:19+10:00] Deleting workspace...

Error: Removing remote directory: Execution error: unable to upgrade connection: container not found ("debug") (stderr:  [optional])

Also failed are golang and golang:alpine images.

when specifying custom image, kwt will assume that image either provides a command or user will specify following flags

--image string                Set image (example: nginx)
--image-command strings       Set command (can be set multiple times)
--image-command-arg strings   Set command args (can be set multiple times)

if no image is specified, kwt defaults to

Image:    "ubuntu:xenial",
Command: []string{"/bin/bash"},
Args:    []string{"-c", "while true; do sleep 86400; done"}, // sleep forever

Also failed are golang and golang:alpine images.

these images have a similar problem (no default command backed) but also probably do not include tar, hence sync (upload/download) will not work even after command is specified.

Reminder to self when I forget how to use alternate images in future - need to pass explicit args:

kwt w create --enter --image starkandwayne/update-all-cf-buildpacks --image-command bash --image-command-arg -c --image-command-arg "while true; do sleep 86400; done"

@cppforlife is this right - if I pick an alternate image then it drops the default command/args and I have to remember to provide --image-command bash --image-command-arg -c --image-command-arg "while true; do sleep 86400; done" explicitly? Or can we keep these defaults even if --image is explicit?

currently that's true (https://github.com/k14s/kwt/blob/46d997d99f962cb01205460b1966bd10b291d544/pkg/kwt/workspace/workspaces_create.go#L53-L75).

i've kept it that way because images may come with default command/args baked into the image. i would be open to adding a flag that specifies these default args though. wdyt?

When an image is used with kwt workspace create - are there any other entry commands they use aside from "sleep for a long time so we can exec in later"? Currently I can't imagine what the alternate (internal default of an image) might be that's useful for kwt workspace create.

are there any other entry commands they use aside from "sleep for a long time so we can exec in later"?

could be anything, including running some service that is useful to that container. for example some ppl may want to run a web IDE.

Ok. I’ll close this. It shall serve as google juice for each time I forget about to create a workspace using my images :)