<p>I have a ruby on rails application running on AWS. As usual each application server have an nginx and multiple unicorn workers of the application instance. </p>

<p>I am going to move the workload to Kubernetes. I have couple of question regarding this, please help if anyone out there who have kubernetised there ror application.</p>

<ul>
<li>What will be the role of nginx?. Do i need to install nginx in all the pods or i should have a an nginx pod which will reverse proxy to all rails/unicorn pods?</li>
<li>Which one is the best for ror in kubernetes, passenger or unicorn?</li>
</ul>

<p><strong>How will you use nginx?</strong></p>

<p>A kubernetes service can be backed by several kubernetes pods. Whenever anyone makes a request to the kubernetes service, the request is sent to one of the upstream pods in a round robin fashion.</p>

<p>If you were planning to use nginx as a 'load-balancer' or reverse proxy to front your rails app, you don't really need that anymore. Each pod ofcourse will need to have something like passenger/unicorn to serve the rails app.</p>

<p>Here'a a guide I found that talks about a rails deployment from start to end: <a href="http://www.thagomizer.com/blog/2015/07/01/kubernetes-and-deploying-to-google-container-engine.html" rel="nofollow noreferrer">http://www.thagomizer.com/blog/2015/07/01/kubernetes-and-deploying-to-google-container-engine.html</a></p>

<p>If you're planning to use nginx as a static file server, my recommendation would be to have a different pod for the static files that just contains nginx.</p>

<p><strong>What is better to use with k8s?</strong></p>

<p>K8s doesn't really care, because this is outside k8s's concern. Use whatever you like, or whatever you think works better in a container environment. The better question to ask might be <em>which one of passenger/unicorn is a better fit for containerised rails apps</em>. </p>
