Using NodePort
NodePort is an external-facing Service type, which means that it can actually be accessed from outside the Cluster. When creating a NodePort Service, a ClusterIP Service of the same name will automatically be created and routed to by the NodePort, so you will still be able to access the Service from inside the cluster. This makes NodePort a good option for external access to applications when a LoadBalancer Service is not feasible or possible.
NodePort sounds like what it is – this type of Service opens a port on every Node in the cluster on which the Service can be accessed. This port will be in a range that is by default between 30000
-32767
and will be linked automatically on Service creation.
Here's what our NodePort Service YAML looks like:
nodeport-service.yaml
apiVersion: v1 kind: Service metadata: name: my-svc Spec: type: NodePort selector: app: web-application ports...