Minimal sample application to demonstrate Rails application development with Docker, Kubernetes and Helm.
See blog for details.
Prerequisites
- Docker, Docker Compose
$ git clone https://github.com/kwhrtsk/rails-k8s-demoapp.git
$ cd rails-k8s-demoapp
# Start mysql and redis container, and build rails app image and start.
$ docker-compose -f docker-compose-preview.yml up -d
# Open top page in your browser
$ open http://localhost:3000/
# Stop all containers and cleanup volumes
$ docker-compose -f docker-compose-preview.yml down
Prerequisites
- Docker, Docker Compose
- Ruby 2.5.1
- Node.js 6.0.0+
- Yarn 0.25.2+
- foreman
$ git clone https://github.com/kwhrtsk/rails-k8s-demoapp.git
$ cd rails-k8s-demoapp
# Start mysql and redis container
$ docker-compose up -d
# Install rubygems
$ bundle install
$ gem install foreman
# Install npm
$ yarn install
# Initialize database
$ ./bin/rails db:setup
# Start puma, sidekiq and webpack-dev-server
$ foreman start -f Procfile
# In another terminal, open top page in your browser.
$ open http://localhost:3000/
Tested with:
Name | Version |
---|---|
minikube | 0.27.0 (k8s 1.10.0) |
kubectl | 1.10.2 |
helm | 2.9.1 |
hyperkit | v0.20171204-60-g0e5b6b |
stern | 1.6.0 |
Example manifests to deploy to minikube instance.
- step1
- Use only these API Object:
Deployment
,Service
,ConfigMap
,Secret
- Use only these API Object:
- step2
- Add
Job
from step1's constitution to executerails db:setup
. - Supports multiple puma containers.
- Add
- step3
- Add
PersistentVolumeClaim
from step2's constitution to persistent data of mysql and redis.
- Add
- step4
- Add
Ingress
from step3's constitution to expose application with custom TLS certificate and fixed URL.
- Add
Helm Chart example and operation scripts for setup, deploy, and rolling update rails containers. This chart based on manifests-step4.