GithubHelp home page GithubHelp logo

vmlellis / kubernetes-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from foxio/kubernetes-rails

0.0 2.0 0.0 58 KB

a demo repo using Kubernetes to deploy a rails/nginx pod to GCE

Ruby 78.27% JavaScript 2.47% CoffeeScript 1.28% CSS 2.15% HTML 15.20% Shell 0.63%

kubernetes-rails's Introduction

Kubernetes-Rails

NOTE This is not production ready. The env is set to "production" as a proof of concept to show the asset pipeline is working in prod.

This project is a working example of building a rails app using Docker, and deploying using Kubernetes to GCE. Each Pod consists of an NGINX and Rails container (running unicorn). This allows NGINX to host static files using an emptyDir volume instead of a a more persistent volume.

Server setup diagram

Run locally

  1. docker-machine create --driver virtualbox --virtualbox-disk-size "30000" --virtualbox-memory "8096" kubernetes-rails
  2. docker-machine start kubernetes-rails
  3. eval "$(docker-machine env kubernetes-rails)"
  4. docker-compose build && docker-compose up -d
  5. docker-compose run --rm web rake db:create

Build images

You will need to change foxio-rnd to your GCE project name.

  1. docker build -t gcr.io/foxio-rnd/rails-image:v1 web/.
  2. gcloud docker push gcr.io/foxio-rnd/rails-image:v1 Note pushing can take a long time and use a lot of bandwidth. This actually times out sometimes. Just run it again if it does that.
  3. docker build -t gcr.io/foxio-rnd/nginx-image:v1 nginx/.
  4. gcloud docker push gcr.io/foxio-rnd/nginx-image:v1

GCE deploy

  1. gcloud container clusters create kubernetes-rails --num-nodes 2 --machine-type g1-small
  2. kubectl run db --image=postgres --port=5432
  3. kubectl expose rc db
  4. Update kubernetes/web-controller.yaml to use your GCE project name instead of foxio-rnd
  5. kubectl create -f kubernetes/web-controller.yaml
  6. Using kubectl get pods wait for the 2 pods to change to Running. This can take a few minutes.
  7. kubectl create -f kubernetes/web-service.json

DB Setup

  1. kubectl get pods
  2. kubectl exec -it [pod id] -c web bash
  3. run rake db:create and rake db:migrate

Teardown

  1. gcloud container clusters delete kubernetes-rails
  2. Manually delete the Load balancer from the Network -> Network load balancer

TODO

  1. automate the DB setup
  2. setup DB cluster
  3. Setup to run Kubernetes locally

kubernetes-rails's People

Contributors

joekr avatar mfisher31 avatar

Watchers

Victor Lellis avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.