What is the point of nginx when I have Kubernetes?

When I go to the Docker / Kubernetes tutorials I notice that a lot of people are putting nginx into pods.

Even after reading about nginx, I'm not sure what they are using it for. Doesn't Kubernete serve your application and handle things like load balancing and more?

Not something like a Node.js "web server" that can "serve static assets, do caching, and TLS / SSL"?

So with your Node.js app on Kubernetes you have your app, static assets, caching, especially with things like Redis and load balancing, etc, why nginx?

+3


source to share


3 answers


Kubernetes is all about balancing the load of requests to your application. It is now up to you to decide if you want to expose your application directly or if you want to use the WebServer in front of it.

Putting Nginx in front of it will allow you to have things like access logs, error logs, caching, serving static files, etc. There are times when you might want your application to be exposed directly (this usually happens when you create applications in GoLang)



So, Nginx is not a required element inside a module, but it depends on your architecture design whether you want it or not.

+2


source


There are several reasons why people start an Nginx instance in a Pod. The most common use case is for static assets. Apache or lighttpd will play the same role for this purpose. Without seeing the tutorials, I can't shed light on the role that Nginx plays.

Since you mentioned the "tutorials" I suspect it's just for serving a static page to say "Hey, I'm here! You've successfully deployed something that works."



To answer your question on handling k8s load balancing - it is. The service object performs Layer 3 (i.e., IP) load balancing between its associated modules, and the Ingress object does the same, but at layer 7 (i.e., HTTP). This load balancing is on a cluster basis.

To summarize, Nginx in the tutorials will most likely serve static assets, while k8s will load balance across the entire clan.

+1


source


nginx is a web server like apache http server or tomcat web server. The nginx docker image is small compared to other webservers. It takes less time to download and start the web server. This is why everyone uses it during the container learning phase.

Kubernetes is used to manage containerized applications like (nginx, mysql and tomcat, etc.).

0


source







All Articles