Is it possible to replace executable in a container in a POD while it's running?

4/19/2019

I'm developing a Go executable on Ubuntu and running a kubernetes cluster in minikube. The pod+container that's running in minikube is based on Ubuntu, and I just want to replace the executable in the container. More or less bypassing the need to remake the container because executable is the only thing that needs to change. When my changes are 'ready' I plan to remake the image the container is based on, etc., but that's down the road.

I'm looking to iterate a bit quicker really.

Is this possible? Is there a better way?

-- lucidquiet
containers
go
kubernetes
workflow

1 Answer

4/20/2019

For development purposes ONLY (quite hacky solution), you can have your Ubuntu-Go container running tail -f /dev/null to keep it from finishing, and use a hostPath to mount the path containing your executable to your container. You can run your Go application by running a kubectl exec and any changes you make to your application on your host will be reflected in the container. You can restart the application, again with kubectl exec whenever the executable is updated.

Here is a good readme on how to use minikube's hostPath.

REMEMBER IN PRODUCTION to rebuild your container with the correct binary, define the correct entrypoint, and fix your deployment/pod definition to exclude the hostPath.

Hope this helps!

-- Frank Yucheng Gu
Source: StackOverflow