mazecreator
mazecreator

Reputation: 555

Opening Multiple Ports on the same pod Guaranteed?

I am fairly new to Kubernetes. I am trying to figure out the best structure for a pod that requires configuration depending upon which pod requests its services.

So for example. Data Stream port might be 8080, this is a stream of data of unknown size. Data is processes as it is received. So I can't really use a REST API with a payload as the payload is a stream which could be days long.

The issue is that I might have 10+ copies of this service, and they need to be configured dynamically upon a client pod connecting to that service. I would prefer to use a separate port like 9000 to connect to the pod with an XML or INI file type of configuration.

My concern is the following. Since there is 10 copies and the same pod is making 2 unique requests to a services, are they guaranteed to connect to the same service pod or could they be 2 different ones? Ultimately, I would want to select a service pod (orchestrator can select, but it be a known IP address now), send a configuration file to 9000, then connect to port 8080 with a data stream for the service to be properly completed.

Upvotes: 0

Views: 335

Answers (1)

Kranthiveer Dontineni
Kranthiveer Dontineni

Reputation: 1543

Since you are trying to open multiple ports for the same service on the same pod, you can assign each port a different name. I’m providing you with a sample yaml file in which a service is communicating outside using both port 80 and port 443.

apiVersion: v1
kind: Service
metadata:
 name: my-service
spec:
 selector:
   app: MyApp
 ports:
   - name: http
     protocol: TCP
     port: 80
     targetPort: 9376
   - name: https
     protocol: TCP
     port: 443
     targetPort: 9377

For more information and explanation you can refer to this link from where the above yaml example is provided.

Update:

  1. @mazecreator I can suggest a workaround for now, attach a temp or persistent volume to your service deployment and when you are trying to push your configuration files using port 9000 push them to this volume and when your application is performing data stream operation it will fetch your configs from here and it will be completed properly.
  2. @mazecreator follow these steps and create separate deployment files for each application you are going to deploy in this way all the pods related to that particular application can only access this volume.

Upvotes: 1

Related Questions