Considerations when deploying app relying on web sockets on kubernetes.

TargetPorts, Ports & Nodeports

These two concepts govern ingress at the Service & Pod level:

  • port: port that corresponding Service is listening on
  • targetPort: port to which traffic is directed inside the container

These two concepts govern ingress at the Service & Cluster level:

  • ClusterIP: This is the default type for service in Kubernetes; an address that can be used inside the cluster. Can be used in conjunction with a Load balancer/ingress controller to redirect outside traffic to Services.
  • NodePort:
    • “A NodePort is an open port on every node of your cluster. Kubernetes transparently routes incoming traffic on the NodePort to your service, even if your application is running on a different node.”
    • “A NodePort service has two differences from a normal “ClusterIP” service. First, the type is “NodePort.” There is also an additional port called the nodePort that specifies which port to open on the nodes. If you don’t specify this port, it will pick a random port”.

Sources