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:6/6 READY, meaning six Pods are available.
Step 1: Define the Service
Create a directory calledservice (optional) and add a file named service-definition.yaml:
Service Specification Breakdown
| Field | Description | Example |
|---|---|---|
type | Service exposure method (ClusterIP, NodePort, LoadBalancer) | NodePort |
selector | Matches Pods by label | app: myapp |
ports.port | Port exposed inside the cluster | 80 |
ports.targetPort | Port on the Pod that receives traffic | 80 |
ports.nodePort | Port on each Node for external access (30000–32767) | 30004 |
NodePort Services allocate a port between
30000 and 32767. If you omit nodePort, Kubernetes assigns one automatically.Step 2: Verify the Service
Run the following command to list Services in the current namespace:- CLUSTER-IP: Internal IP of the Service.
- 80:30004/TCP: Maps Service port
80to NodePort30004.
Step 3: Access the Application
There are two ways to reach your application:-
Using your node’s IP address:
Then open your browser at
-
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.

Next Steps
- Explore other Service types such as
ClusterIPandLoadBalancer. - Learn about Ingress resources for advanced HTTP routing.
- Consult the Kubernetes Services documentation for more details.