Kubernetes and Docker Desktop for Fast Local Development

RMAG news

Docker Desktop can run a Kubernetes node that is accessible locally. It enables you to build and re-build local Docker images and have them available to Kubernetes pods for deployments.

For typical deployments in Kubernetes, you will want to specify a version tag for a Docker image.

For local development with Docker Desktop and Kubernetes, you can set the tag of the image latest or development, any tag without a version number.

You must also set the deployment’s restartPolicy to Always and the container’s imagePullPolicy to IfNotPresent. This ensures that Kubernetes can pull the image from Docker Desktop, and that it will always restart with the latest updated image.

Then you can run kubectl rollout restart deployment $DEPLOYMENT_NAME to restart the pod and pull the latest development image.

The iteration cycle looks like this:

Write code
Build the image with the development tag
Restart the deployment

You can use fswatch or some other watch tool to monitor changes in source code and kick off the Docker image rebuild and then the Kubernetes deployment restart.

For monitoring the local Kubernetes cluster, I have been using Headlamp which is available as a Docker Desktop extension.

Leave a Reply

Your email address will not be published. Required fields are marked *