freshpod helps you automatically restart containers on Kubernetes when their image is updated.
It is designed for single-instance Kubernetes clusters, such as Minikube or Docker for Windows/Mac.
freshpod detects you rebuilt an image and it deletes the Kubernetes Pods are running that image. This way, your workload controller (such as Deployment) will create new Pods running the new image.
🆕 Check out Skaffold, a new tool by Google that simplifies local Kubernetes development experience. Skaffold supersedes freshpod.
This demo shows refactoring an application and running docker build
will automatically restart the application with the new image on Minikube:
freshpod is available as an add-on for Minikube. You just need to enable it:
minikube addons enable freshpod
If you’re using Kubernertes on Docker for Mac/Windows, you can directly apply the manifest used by Minikube:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/minikube/ec1b443722227428bd2b23967e1b48d94350a5ac/deploy/addons/freshpod/freshpod-rc.yaml
Get some test images and tag the :1.0
image as hello:latest
:
eval $(minikube docker-env) # not necessary for docker-for-mac/windows
docker pull gcr.io/google-samples/hello-app:1.0
docker pull gcr.io/google-samples/hello-app:2.0
docker tag gcr.io/google-samples/hello-app:1.0 hello:latest
Run a 2-replica Deployment and NodePort Service with hello:latest
image:
kubectl run hello --image=hello --port 8080 --replicas=2 \
--image-pull-policy=IfNotPresent
kubectl expose deploy/hello --type=NodePort
Visit the app (note the 1.0.0
):
$ URL=$(minikube service hello --url)
$ curl "$URL"
Hello, world!
Version: 1.0.0
Hostname: hello-5766f88f9c-67lgz
Re-tag the hello:latest
image with the 2.0
version:
docker tag gcr.io/google-samples/hello-app:2.0 hello
Visit the app again (note the version has changed to 2.0.0
):
$ curl "$URL"
Hello, world!
Version: 2.0.0
Hostname: hello-5766f88f9c-h88df
See CONTRIBUTING.md for more information.
This is not an official Google product.