How do you expose pods/containers to outside world in Kubernetes

  • To expose Kubernetes pods and containers to the outside world, you typically use Services, specifically the NodePort or LoadBalancer types. NodePort exposes the service on each node’s IP at a static port, while LoadBalancer uses a cloud provider’s load balancer for external access      
  •   NodePort: Exposes the service on a specific port on
    each node in the cluster. You’ll then access your application by
    connecting to the Node’s IP address and the specified port. 

    ·   LoadBalancer: Uses a cloud provider’s load balancer to
    create an external IP address for your service. This is often the
    preferred method for exposing services to the internet, as it provides a more stable and scalable external entry point

Example for Nodeport : 

				
					    kubectl expose deployment my-deployment --type=NodePort --port=80 --target-port=8080
				
			

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top