Easly Deploy Static Website to Kubernetes without the custom docker images

apiVersion: apps/v1
kind: Deployment
metadata:
name: static-website
spec:
selector:
matchLabels:
app: static-website
template:
metadata:
labels:
app: static-website
spec:
containers:
- name: static-website
image: nginx:alpine
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html
subPath: example-static-website
name: static-website-volume
volumes:
- name: static-website-volume
gitRepo:
repository: https://github.com/abdennour/example-static-website.git
  • 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.
volumes:- name: static-website-volume        gitRepo:repository: https://github.com/abdennour/example-static-website.git
revision: 0229f2c228fba8728183878cf58fb078c7612763

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

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
Abdennour Toumi

Abdennour Toumi

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