Service type – NodePort

When you are using a Kubernetes cluster on premises, or in our case in a virtual machine on your development machine with Minikube, NodePort is a common service type used to expose your services. NodePort relies on the underlying hosts upon which you run Kubernetes to be accessible on your local network, and exposes the service definition through a high-numbered port on all of the Kubernetes cluster nodes. 

These services are exactly like the default ClusterIP services, with the exception that they have a type of NodePort. If we wanted to create such a service with the expose command, we could add a --type=Nodeport option to our earlier command, for example:

kubectl delete service flask
kubectl expose deploy flask ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.