Kubernetes NodePort Service

Kubernetes NodePort Service is an service which is used for to expose the nodes which are available in the cluster to the outside of the cluster. It will also expose the applications which are running in the node it also allows the traffic from the outside to reach the application with the help of NodePort.

Example Of NodePort Service

Following is the sample YAML file for the kubernetes NodePort Service.

apiVersion: v1
kind: Service
metadata:
name: <Name Of the Service>
spec:
type: NodePort
ports:
- port: 80 # Port exposed within the cluster
targetPort: 8080 # Port on the pods
nodePort: 30000 # Port accessible externally on each node
selector:
app: example-app # Select pods with this label

Kubernetes – NodePort Service

NodePort service in Kubernetes is a service that is used to expose the application to the internet from where the end-users can access it. If you create a NodePort Service Kubernetes will assign the port within the range of (30000-32767). The application can be accessed by end-users using the node’s IP address.

Similar Reads

Kubernetes Service

Kubernetes service will help you to expose the pods that are running in the cluster to the outside world and also they will make it available for the pods to each other that are running in the Kubernetes cluster....

Types Of Kubernetes Services

In Kubernetes, there are 3 types of services to provide discovery and routing between pods....

Kubernetes NodePort Service

Kubernetes NodePort Service is an service which is used for to expose the nodes which are available in the cluster to the outside of the cluster. It will also expose the applications which are running in the node it also allows the traffic from the outside to reach the application with the help of NodePort....

How NodePort Service Work?

NodePort service will exposes the pods of node to the another and also it will expose the pods to the outside of the cluster from where the users can aceses from the internet by using the IP address of node and port....

Steps To Use NodePort Service

Step 1. Create a deployment. For our demo purpose, I choose Nginx as our application with 2 replicas, you can change it as per your requirement....

Difference Between NodePort And ClusterIP

NodePort ClusterIP NodePort service will exposes the static port on each IP address and also it allows the traffic from internet to access the pod. Expose the service on an internal IP address which can be reachable with in the cluster. If you want to expose the pods to external and also want to use it for inside the cluster then you can use NodePort. If you didn’t want to expose the pod to out side and need to be used for internal purpose you can use the ClusterIP. If you need to expose the application like web-applications then you can use the NodePort Serivce Mainly used for the internal purposes like databases API services which are used for internal purpose....

FAQs On NodePort Service

1. Why Do We Use NodePort?...