Ferskfisk
Ferskfisk

Reputation: 25

Expose random unique port on all pods

I have a deployment that creates pods running a container on a specific port. I am looking to give each pod a unique port and exposing it outside the cluster on that unique port. I tried using a service, but this will create one port for all the pods and act as a load balancer.

deployment yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: name-deployment
  labels:
    app: name
spec:
  replicas: 3
  selector:
    matchLabels:
      app: name
  template:
    metadata:
      labels:
        app: name
  spec:
    containers:
    - name: name
      image: image
      ports:
        - containerPort: 25566

Upvotes: 0

Views: 437

Answers (1)

Rushikesh
Rushikesh

Reputation: 222

It's not possible as all pods under one deployment will have same configuration including exposed ports. Creating different deployments and setting custom scaling logic would help you here.

Upvotes: 2

Related Questions