Kubernetes Cluster setup loadbalancing

We have Kubernetes cluster on-premises setup like 3 nodes, one master node and two worker nodes.

master node :
worker1 node :
worker2 node :

I have run the nginx web server application replica count 2 and using nodeport service in my Kubernetes cluster setup and my nodeport port is 34567
we have some doubts below mentioned,

  1. I call the each node IP’s and port example like this:-,, we using firewall device mapped 3 nodes for common ip ( could you say this setup is correct or not ?

  2. In Kubernetes statefulset application(Database) auto scaling doing it is correct or wrong

Alright, let’s unpack this and see what we’ve got!

Your setup with one master node and two worker nodes is a pretty standard small-scale Kubernetes cluster, and running an Nginx web server application with a replica count of 2 exposed via a NodePort service is a common approach for learning and testing.

Regarding your load balancing setup:

Accessing your Nginx application using the NodePort across all nodes (master and workers) like,, and is technically feasible because NodePort services are exposed on all nodes in the cluster. This setup allows you to access your application even if the actual pod isn’t running on the node you’re hitting, thanks to the Kubernetes networking magic that routes the traffic to where the pod is actually running.

Mapping these through a common IP ( on a firewall device to distribute the load across the three nodes can work as a rudimentary form of load balancing. However, it’s a bit manual and doesn’t provide the intelligence or features of a dedicated load balancer, like health checks, SSL termination, or session persistence.

For a more robust solution in a production environment, you might consider:

  • Using a Kubernetes Ingress: This is a more Kubernetes-native solution, where an Ingress controller can manage the routing of external traffic to your services based on the requested host or URL.
  • External Load Balancer: If you’re on-premises, a dedicated load balancer appliance or software load balancer that supports more advanced routing, health checks, and high availability might be more suitable.

Regarding StatefulSet auto-scaling:

Auto-scaling StatefulSets, especially for databases, is a bit more complex than scaling stateless applications like web servers. Here’s why:

  • State: Databases maintain state, and scaling them involves not just spinning up more instances but also ensuring data consistency, replication, and possibly sharding.
  • Persistent Storage: Each replica in a StatefulSet typically has its own associated persistent storage. Scaling up means provisioning new storage volumes, and scaling down requires careful handling of data to avoid loss.
  • Partitioning/Sharding: Depending on the database, you might need to implement partitioning or sharding to distribute data across instances effectively.

In general, auto-scaling databases in Kubernetes using StatefulSets is not inherently “wrong,” but it requires careful planning and implementation to ensure data integrity and performance. For many databases, manual scaling is preferred, with careful consideration of replication, sharding, and data migration strategies.

So, in summary:

  • Your NodePort-based load balancing setup can work for learning and testing but consider more robust solutions for production.
  • Auto-scaling StatefulSets for databases is complex and needs to be approached with caution, often favoring manual scaling strategies.

Keep exploring and experimenting, and don’t hesitate to refine your setup as you learn more about Kubernetes and your specific application needs!