I am trying to deploy a simple HTML file to Kubernetes and host it using Nginx as a test. I am running into issues when copying over my website files.
Dockerfile
FROM nginx:alpine
COPY ./public /usr/share/nginx/html/
When I build this image and run it using docker run
the website loads fine and I see my index.html file located in my public directory. If I try to run this in a pod using kubectl
the files don’t get copied over. All I see when I go to my site is the default Nginx welcome page. I am not sure why this is the case. the cluster is hosted on AWS EKS so it’s remote to all the files. This is the same as I build and host my docker image on GitLab.
The image builds without any errors and as I said works fine when run in vanilla docker. It’s only when I move over to Kubernetes that I run into issues.
I’ve made the project public so you guys can see all the abstractions that I might have left out in my question.
https://gitlab.com/k8group/k8site
Any help is appreciated.
Best Regards,
Eddy.
2
Answers
So it looks like this was a case of the image not being pulled. I changed the commit tag from master to a hash and the site started working.
changing a variable in my ci pipeline from
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
to
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
thanks, @EugeneDW for pointing me in the correct direction.
I know if is only this, but in the quick glance I can say the key value in your ingress template must be pointing to the service port, not to the pod container port. Check the right config below: