Is there any way to save the current state of kubernetes pod?

Is there any way to save the current state of kubernetes pod?

Problem Description:

I have a pod running linux, i have installed many software/tools, if I restart the pod, k8s will start a new pod and I’ll lose all my resources installed, is there any way to save the pod as docker image or any other way it can be persistant even after restarting pod.

Is there a way to download the container image from a pod in kuberentes environment? tried the solution, but wasn’t helpful.

Solution – 1

The answer in the link is not wrong, you will probably have to jump through some hoops. One method I can think of is to:

  1. Run a container that has the docker cli installed, mounts the docker socket from the host, and has an node affinity rule so that the container is scheduled on the same node as the container you want to capture.
  2. From within this container, you should be able to access the docker daemon running on the node, issue docker commands to capture, tag, push the updated image.

I wouldn’t advise doing this though… have not tested it myself but I have done something "similar" before.

It would be better to create your own dockerfile, install software, and use that image for your containers.

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.