Exposing Services

Kubernetes Cluster: Exposing Services

Kubernetes applications can communicate internally through Service names, but external access requires an appropriate Service type or an additional routing layer. Kubernetes provides three common Service types for this purpose: ClusterIP, NodePort, and LoadBalancer.
ClusterIP Internal-only access inside the Kubernetes cluster.
NodePort Exposes a service through a high-numbered port on Kubernetes nodes.
LoadBalancer Common way to expose a service directly to the Internet through a public IP.

ClusterIP

ClusterIP is the default Kubernetes Service type. It exposes the application only to other workloads inside the Kubernetes cluster and does not provide external access.

kind: Service
apiVersion: v1
metadata:
  name: nginx1
  namespace: test
spec:
  type: ClusterIP
  selector:
    app: nginx
  ports:
    - port: 80
Use ClusterIP when the service is intended only for internal communication, for example application-to-database or microservice-to-microservice traffic.

NodePort

NodePort is the most basic method for exposing a Kubernetes Service externally. Kubernetes opens a port on the cluster nodes and forwards traffic received on that port to the target Service.

By default, Kubernetes assigns a NodePort from the range 30000–32767.

kind: Service
apiVersion: v1
metadata:
  name: nginx1
  namespace: test
  labels:
    run: nginx
spec:
  type: NodePort
  selector:
    run: nginx
  ports:
    - port: 80
      targetPort: 80

If a specific NodePort is required, define it explicitly:

ports:
  - port: 80
    targetPort: 80
    nodePort: 30984
NodePort rules: A manually selected nodePort must be within the allowed 30000–32767 range and must be unique so it does not collide with another Service.

If a public IP is already attached to the Kubernetes worker nodes, no additional platform-side exposure is required for the selected NodePort.

Expose NodePort through a Platform Endpoint

If the Kubernetes worker does not have a public IP, expose the NodePort through a platform endpoint.

  • Open the Kubernetes environment.
  • Navigate to Settings > Endpoints.
  • Click Add.
  • Node — select any worker node.
  • Name — enter a preferred endpoint name.
  • Private Port — enter the NodePort configured for the Service.
  • Protocol — select TCP.
Platform endpoint to expose Kubernetes NodePort service
Create a platform endpoint that forwards traffic to the selected Kubernetes NodePort.

After clicking Add, allow a few minutes for the platform to expose the port and begin redirecting requests to the NodePort Service.

LoadBalancer

LoadBalancer is the commonly used Service type for publishing a Kubernetes application directly on the Internet. It requires a public IP attached to a Kubernetes worker node.

kind: Service
apiVersion: v1
metadata:
  name: nginx1
  namespace: test
spec:
  type: LoadBalancer
  selector:
    app: nginx
  ports:
    - port: 80
      targetPort: 8080

In this example, incoming Internet traffic arrives on port 80 and is forwarded to application port 8080.

Direct forwarding: With a LoadBalancer Service, traffic is forwarded directly to the Service. This method does not automatically provide advanced filtering, hostname routing, path routing, or other ingress features.

Production Considerations

NodePort is simple but has limitations, including one Service per exposed port and a restricted high-port range. It is therefore more suitable for demonstrations, testing, or temporary applications.

ClusterIP Best for internal-only communication.
NodePort Simple external exposure, mainly useful for temporary or test workloads.
LoadBalancer / Ingress Better suited to production environments requiring Internet access and more structured routing.
For production applications, consider using Kubernetes Ingress resources or the platform’s public-IP integration together with the appropriate Service type.
Service exposure summary: Use ClusterIP for internal access, NodePort for simple external exposure, and LoadBalancer or Ingress-based routing for production-facing applications.

What’s next?