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.
docker-machine create --driver virtualbox --virtualbox-disk-size "30000" --virtualbox-memory "8096" kubernetes-railsdocker-machine start kubernetes-railseval "$(docker-machine env kubernetes-rails)"docker-compose build && docker-compose up -ddocker-compose run --rm web rake db:create
You will need to change foxio-rnd to your GCE project name.
docker build -t gcr.io/foxio-rnd/rails-image:v1 web/.gcloud docker push gcr.io/foxio-rnd/rails-image:v1Note 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.docker build -t gcr.io/foxio-rnd/nginx-image:v1 nginx/.gcloud docker push gcr.io/foxio-rnd/nginx-image:v1
gcloud container clusters create kubernetes-rails --num-nodes 2 --machine-type g1-smallkubectl run db --image=postgres --port=5432kubectl expose rc db- Update kubernetes/web-controller.yaml to use your GCE project name instead of foxio-rnd
kubectl create -f kubernetes/web-controller.yaml- Using
kubectl get podswait for the 2 pods to change toRunning. This can take a few minutes. kubectl create -f kubernetes/web-service.json
kubectl get podskubectl exec -it [pod id] -c web bash- run
rake db:createandrake db:migrate
gcloud container clusters delete kubernetes-rails- Manually delete the Load balancer from the Network -> Network load balancer
- automate the DB setup
- setup DB cluster
- Setup to run Kubernetes locally
