<p>I have a container which runs a chatbot using python, exposed port 5000 where the bot is running. Now when i deploy this container on kubernetes, I have few questions</p>

<ul>
<li>Do i need to run nginx container in the pod where my app container is
running ? If yes why do i need to ? since kubernetes does load
balancing</li>
<li>If i run nginx container on port 80, do I need to run my
app container also on 80 or (can i use a different port like 5000)</li>
<li>what role does gunicorn play here ?</li>
</ul>

<p>I am a little confused because most of the examples i see online everyone pretty much have nginx container in their pods along with the app containers</p>

<p>As you mentioned Kubernetes can handle its own load balancing, so the answer to your first question is no, you don't need to run nginx especially in the pod where your application is. 
Typically, services and pods have IPs that are routable by the cluster network and all traffic which ends at an edge router will be dropped. So in Kubernetes there is a collection of rules that allows inbound connections to reach a cluster services. Which we call <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress</a>:</p>

<blockquote>
  <p>An API object that manages external access to the services in a
  cluster, typically HTTP.</p>
</blockquote>

<p>Confusing part is that Ingress on it's own does not do much. You will have to create an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource" rel="nofollow noreferrer">Ingress controller</a> which is a  daemon deployed as a Pod. Its job is to read the Ingress Resource information and to process that accordingly. Actually any system capable of reverse proxying can be  ingress controller.  You can read more about Ingress and Ingress controller in practical approach <a href="https://medium.com/@cashisclay/kubernetes-ingress-82aa960f658e" rel="nofollow noreferrer">in this article</a>. Also I do not know about your environment so please remember that you should use type <a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer">LoadBalancer</a> if you are on the Cloud and type <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer">NodePort</a> if in bare-metal environment. </p>

<p>Going to your second question you can run your application on any port you want, just remember to adjust that port in all other configuration files. </p>

<p>About ports and how to expose services you should check the sources in documentation on how the Kubernetes model works in comparison to containers model. You can find a an instructive article <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#the-kubernetes-model-for-connecting-containers" rel="nofollow noreferrer">here</a>. </p>

<p>Unfortunately I do not have experience with gunicorn  so I won't be able to tell you what role does it play in here. Hope this helps. </p>
