Can I update my code in Google Kubernetes Engine(GKE) without re-building the docker image?

7/11/2018

I'm new in GKE.

Is there anyway to update new version of my code without re-building the docker image? Because I had to rebuild the docker image and uploaded it on GKE every single time I changed even a bit in my source code and it took me a lot of time. Thank you.

-- Quoc Lap
docker
google-kubernetes-engine
kubernetes

2 Answers

7/11/2018

There are some workarounds possible, but it depends on your exact use case. I will specify one use case and let you interpolate for your situation.

Let's say you have a docker container running a web application using a binary which uses the image: quoclap/webapp. Instead of starting a container with this image what you could do is a run a ubuntu container, exec into the container, get the source code, build/compile and run the binary manually.

This is a very hacky way of doing things. I have used this technique multiple times during development phase, but never on a production setup.

Please use this approach with caution.

-- leodotcloud
Source: StackOverflow

7/11/2018

Building Docker images manually - is not so good idea... It's no surprise you spend too much time for this. Better way - is configure and deploy any CI/CD System, which could build image or make any other action automatically per commit or merge request. Of course, this is going to take your hours, but you'll have to do it anyway, sooner or later. Current realities provide all too many examples of this:

  • Let's say you need to test (unit/integration tests) your app before deploying
  • Let's say you have more then one environments
  • Moving forward imagine your company would like to develop apps by "DevOps way"
  • much many other cases

Depending on where you store your source code you can choose the most suitable CI/CD. For example, if you store the sources in GitLab, then GitLab CI might be the best one

-- Konstantin Vustin
Source: StackOverflow