<p>I am currently designing a system where users should be able to start a simulation through a Web Portal and then connect to it with a gRPC client (amongst other things). After the user is finished the simulation then terminates. I want to run the whole system in a kind of microservice architecture in a kubernetes cluster if possible. This is however my first time working with kubernetes and I am unsure if it is possible to achieve this. </p>

<p>As far as I could gather from reading the documentation and googling around it seems like I should be able to launch a pod by calling <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#create-pod-v1-core" rel="nofollow noreferrer">POST /api/v1/namespaces/{namespace}/pods</a> and making it availble under the Host IP by setting <code>hostPort</code>. However what I dont know is how I would determine a free port on the Node to deploy to or let kubernetes decide that (if <code>hostPort</code> is even the correct choice for this). After that it should be pretty straightforward. Send the user the IP:Port to connect to and he just plugs that into his gRPC client.</p>

<p>Any suggestions on how to best achieve this?</p>

ACB
<p>Using <code>hostPort</code> is rather not recommended, so you'd be better off by specifying a <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">service</a> and access your Pod via a service. In your case you can define <code>NodePort</code> service and let Kubernetes decide on the port. Then, fetch the service port using Kubernetes API.</p>
