Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Idiomatic Docker & K8s Deployments for Rails apps

Ashwin Murali
September 21, 2019

Idiomatic Docker & K8s Deployments for Rails apps

Slides of talk at Bangalore Ruby User Group Meetup @ Clarisights, Bangalore - September, 2019.

Code for demo from: https://github.com/jamby1100/rails-docker-project

Update to the slide deck done on 18-Oct-2019.

Ashwin Murali

September 21, 2019
Tweet

More Decks by Ashwin Murali

Other Decks in Technology

Transcript

  1. $whoami • Old school sys / network admin • <3

    shell / UNIX • Cloud • IoT • Mail • DNS
  2. Agenda • High-speed intro - Docker and K8s • Starting

    with development • Hitting Staging / UAT / Prod • Who’s around the place • Q & A
  3. Docker is a set of platform-as-a-service (PaaS) products that use

    OS-level virtualization to deliver software in packages called containers.
  4. Kubernetes is a portable, extensible, open-source platform for managing containerized

    workloads and services, that facilitates both declarative configuration and automation.
  5. FROM ruby:2.5-alpine LABEL maintainer="Ashwin Murali <[email protected]>" RUN apk update &&

    apk add build-base nodejs postgresql-dev RUN mkdir /app WORKDIR /app COPY Gemfile Gemfile.lock ./ RUN bundle install COPY . . CMD puma -C config/puma.rb
  6. • Separate network-attached entity • Work with DNS. Not IP

    • Clarify separation of concerns • Understand multiple nodes per service
  7. • No writing inside the container • Be as Read-Only

    as possible • ONE PROCESS PER CONTAINER
  8. # config/application.rb L21 logger = ActiveSupport::Logger.new(STDOUT) Sidecar for centralised logging

    • ELK • Fluentd • Deliver config as env variables - use .env in dev
  9. • Sidecar for monitoring • Integrate monitoring at multiple levels

    - Pod / Application / Service • Use monitoring responses to fail gracefully
  10. PVs and PVCs • Flashy but hard problems • Reclaims,

    Deletes and Recycles are dangerous • Databases are scary to put on PVs
  11. Post Mortem • High-speed intro - Docker and K8s •

    Starting with development • Hitting Staging / UAT / Prod • Who’s around the place • Q & A