Exposing port range for Deployment

7/6/2019

I have an application that I want to host in kubernetes cluster. This application can listen to multiple RTP streams on different ports in parallel. My question is: how can I expose this application for externally? I see that Service object exposes Deployments on certain port, but I need to expose it regardless the port.

-- eddyuk
kubernetes

1 Answer

7/10/2019

According to github discussion, port ranges are not supported in the services yet

Thought, take a look at headless service. If you use it to expose your container with selector , you will be able to connect to your container's IP on any port

Something like this:

apiVersion: v1 
kind: Service 
metadata: 
  name: nginx-headless-svc
  labels: 
    run: nginx
spec: 
  clusterIP: None
  selector:
    run: nginx

And you get an endpoint

sukhoversha@sukhoversha:~/GCP$ kk get pod nginx-64f497f8fd-pvk4b -owide
NAME                     READY     STATUS    RESTARTS   AGE       IP           NODE                                  NOMINATED NODE
nginx-64f497f8fd-pvk4b   2/2       Running   0          6d        10.20.0.10   gke-ic-1-default-pool-963dd3ea-365w   <none>
sukhoversha@sukhoversha:~/GCP$ kk get ep  nginx-headless-svc
NAME                 ENDPOINTS    AGE
nginx-headless-svc   10.20.0.10   1h
-- A_Suh
Source: StackOverflow