Using Kubernetes with ruby on rails application

11/21/2016

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.

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.

  • 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?
  • Which one is the best for ror in kubernetes, passenger or unicorn?
-- Faisal P P
kubernetes
nginx
ruby
ruby-on-rails

1 Answer

11/21/2016

How will you use nginx?

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.

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.

Here'a a guide I found that talks about a rails deployment from start to end: http://www.thagomizer.com/blog/2015/07/01/kubernetes-and-deploying-to-google-container-engine.html

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.

What is better to use with k8s?

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 which one of passenger/unicorn is a better fit for containerised rails apps.

-- iamnat
Source: StackOverflow