Skip to main content
In this lesson, you’ll learn how to expose your application Pods in Kubernetes by creating a Service of type NodePort. Services provide stable endpoints for accessing your workloads and enable load balancing across Pods.

Prerequisites

Verify that your Deployment is running and has created Pods:
You should see 6/6 READY, meaning six Pods are available.

Step 1: Define the Service

Create a directory called service (optional) and add a file named service-definition.yaml:

Service Specification Breakdown

NodePort Services allocate a port between 30000 and 32767. If you omit nodePort, Kubernetes assigns one automatically.
Save the file, then apply it:

Step 2: Verify the Service

Run the following command to list Services in the current namespace:
Example output:
  • CLUSTER-IP: Internal IP of the Service.
  • 80:30004/TCP: Maps Service port 80 to NodePort 30004.

Step 3: Access the Application

There are two ways to reach your application:
  1. Using your node’s IP address:
    Then open your browser at
  2. Using Minikube’s service tunnel:
    This outputs a URL such as:
Exposing a Service via NodePort makes it accessible externally on the node’s network. Ensure your firewall rules and security groups are configured appropriately.
Open the URL in your browser. You should see the default NGINX welcome page:
The image shows a default "Welcome to nginx!" page, indicating that the nginx web server is successfully installed and running, but further configuration is required.

Next Steps

  • Explore other Service types such as ClusterIP and LoadBalancer.
  • Learn about Ingress resources for advanced HTTP routing.
  • Consult the Kubernetes Services documentation for more details.

Watch Video