Easly Deploy Static Website to Kubernetes without the custom docker images

While building artifacts (docker images) is a best practice at the end of the Build stage in the CI pipeline, you may consider the GIT repository itself as an artifact for a specified GIT commit.

This means you don’t need to ship your code to a new docker image after each change in your code.

Indeed, I discovered today the “species” gitRepo after running kubectl explain pod.spec.volumes.

This deployment definition defines:

  • A container initiated from the docker image nginx
  • A volume that is created from the GIT repository of this static website.
  • Mounting of that volume on the container path /usr/share/nginx/html
  • subPath with the same value of the GIT repository name to avoid paths like: /usr/share/nginx/html/<repo-name>/index.html . Rather, you will mount the content of the repository directly onto the root path of nginx.

Deploy it kubectl create -f that-deployment.yaml !

Up? kubectl port-forward <name-pod-created> 8888:80

Then go to http://localhost:8888


If you made changes to your code, and you want to release it, you just need to set revision property.



Software engineer, Cloud Architect, 5/5 AWS|GCP|PSM Certified, Owner of kubernetes.tn

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store