joyrex2001 / kubedock

Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
MIT License
226 stars 33 forks source link

Passing environment variables, podman #73

Closed cidrblock closed 9 months ago

cidrblock commented 9 months ago

Admittedly I am somewhat unfamiliar with the environment in which I am working, but was testing kubedock with some simple commands and receieve errors when passing env vars:

➜  dev-spaces-container git:(main) ✗ podman --remote --url "tcp://127.0.0.1:2475" run --env NO_EQUALS=123 alpine env
Error: json: cannot unmarshal object into Go struct field ContainerCreateRequest.Env of type []string
➜  dev-spaces-container git:(main) ✗ podman --remote --url "tcp://127.0.0.1:2475" run -e NO_EQUALS=123 alpine env 
Error: json: cannot unmarshal object into Go struct field ContainerCreateRequest.Env of type []string
➜  dev-spaces-container git:(main) ✗ podman --remote --url "tcp://127.0.0.1:2475" run  alpine env 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
<...>

It appears that the env vars are being passed in the request, but the error appears immediately after:

I0216 20:11:04.969267   60175 util.go:76] Request Headers: http.Header{"Content-Length":[]string{"806"}, "User-Agent":[]string{"Go-http-client/1.1"}}
I0216 20:11:04.969309   60175 util.go:77] Request Body: {"command":["env"],"httpproxy":true,"env":{"NO_EQUALS":"123"},"stop_timeout":10,"log_configuration":{},"raw_image_name":"alpine","systemd":"true","sdnotifyMode":"container","pidns":{},"utsns":{},"containerCreateCommand":["podman","--remote","--url","tcp://127.0.0.1:2475","run","-e","NO_EQUALS=123","alpine","env"],"init_container_type":"","manage_password":true,"image":"alpine","image_volume_mode":"anonymous","ipcns":{},"seccomp_policy":"default","userns":{},"idmappings":{"HostUIDMapping":true,"HostGIDMapping":true,"UIDMap":null,"GIDMap":null,"AutoUserNs":false,"AutoUserNsOpts":{"Size":0,"InitialSize":0,"PasswdFile":"","GroupFile":"","AdditionalUIDMappings":null,"AdditionalGIDMappings":null}},"umask":"0022","cgroupns":{},"cgroups_mode":"enabled","netns":{},"Networks":null,"use_image_hosts":false}
E0216 20:11:04.969380   60175 util.go:17] error during request[500]: json: cannot unmarshal object into Go struct field ContainerCreateRequest.Env of type []string
I0216 20:11:04.969415   60175 util.go:100] Response Body: {"message":"json: cannot unmarshal object into Go struct field ContainerCreateRequest.Env of type []string"}

This could very well be a problem elsewhere in the chain, but any hints, idea, pointers would be greatly appreciated.

really cool stuff here BTW, TY

-brad

cidrblock commented 9 months ago

Oh, this was with the latest: kubedock-0.15.3

joyrex2001 commented 9 months ago

Thanks, this is a bug in kubedock. The podman api passes the environment variables as a hash (instead of an array like docker does).

cidrblock commented 9 months ago

Thanks! Looking froward to the next release to give it a run.

-Brad

cidrblock commented 9 months ago

built from source, works great. Thanks again.

joyrex2001 commented 9 months ago

Released in 0.15.4.