Home > Enterprise >  How to hit a file from browser running inside Kubernetes pod?
How to hit a file from browser running inside Kubernetes pod?

Time:10-06

I have an html file which I want to deploy in Kubernetes. How can I hit that index.html from a browser outside the cloud?

CodePudding user response:

You can serve statics like this using a web server and run it in a pod. (Apache, NGINX etc.) You'd then create a service for this pod and ideally use an Ingress resource to finally expose it publicly.(You could also use a service with type LoadBalancer) Please check K8S Ingress and K8S Service for further reference.

CodePudding user response:

The only correct answer to your opinion based question in this way will be - it depends.

I will show you a few ways how it looks in general and highlight where there may be discrepancies. First, you need to set up a cluster. You can do it locally, e.g. using Minikube, or in the cloud (AWS, GCP, Azure etc.) Bare in mind, that you should not use Minikube in production.

The next step will be the deployment pod of the http server. It can be for example Apache. Another dependencies.

Additionally, if you want your http server to be visible from the outside, you need to create a service and then expose it to the outside world. There are also many types of them, so check the documentation before doing anything. Additionally, you will probably need a database etc.

However, if you want to manage traffic, you can use an ingress solution.

Take into account that there are different types of them on the market (not counting built-in solutions in clouds):

In a more advanced configuration, you can use a service mesh, e.g. istio.

Other solution will be using Helm. Here is one of the guides.

  • Related