Dynamically assign port numbers in Kubernetes?

6/27/2018

Is it possible to dynamically assign port numbers in kubernetes?

Use Case: I have logstash, Kafka, Cassandra and other services running in kubernetes and I create multiple pipelines in different namespaces.

Everytime I create a pipeline, I need to change the container ports for each pod so that there won't be any port conflict.

I am looking for something where in kubernetes can give me a unused port number from the pool or an option to create a named port like kafka_port or logstash_port so that I do not have to worry about changing the container ports for each pipeline.

Please advise.

-- Srinivas
kubernetes

1 Answer

6/28/2018

For pods, you dont need to randomize ports as each of them has its own networking namespace. Unless you use hostNetwork.

For services, NodePort type of service will be assigned random high ports regardless of the port numbers your pods listen on

-- Radek 'Goblin' Pieczonka
Source: StackOverflow