Slide 1

Slide 1 text

Idiomatic Docker & K8s Deployments for Rails apps Ashwin aka @cruisemaniac

Slide 2

Slide 2 text

$whoami ● Old school sys / network admin ● <3 shell / UNIX ● Cloud ● IoT ● Mail ● DNS

Slide 3

Slide 3 text

Agenda ● High-speed intro - Docker and K8s ● Starting with development ● Hitting Staging / UAT / Prod ● Who’s around the place ● Q & A

Slide 4

Slide 4 text

Docker / Kubernetes

Slide 5

Slide 5 text

Docker is a set of platform-as-a-service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.

Slide 9

Slide 9 text

Starting with development

Slide 10

Slide 10 text

Considerations ● Dockerfiles ● Docker-compose ● Service segmentation ● Design patterns

Slide 11

Slide 11 text

Dockerfiles

Slide 12

Slide 12 text

FROM ruby:2.5-alpine LABEL maintainer="Ashwin Murali " 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

Slide 13

Slide 13 text

YOUR CONTAINER IS A RUNTIME. IT IS NOT AN ECOSYSTEM!!!

Slide 14

Slide 14 text

Docker-compose

Slide 15

Slide 15 text

● Orchestrated Local development ● Same as above, but mount volume using -v to /myapp

Slide 16

Slide 16 text

DO NOT USE UBUNTU:16.04

Slide 17

Slide 17 text

Work with alpine linux! It does everything you can think of!

Slide 18

Slide 18 text

Service segmentation

Slide 19

Slide 19 text

● Separate network-attached entity ● Work with DNS. Not IP ● Clarify separation of concerns ● Understand multiple nodes per service

Slide 20

Slide 20 text

Design Patterns

Slide 21

Slide 21 text

● Sidecar ● Ambassador ● Adapter ● Work Queue ● Scatter / Gather

Slide 22

Slide 22 text

Scaling to Staging / Prod

Slide 23

Slide 23 text

Ideal scenario - Just go X * n

Slide 24

Slide 24 text

● Statelessness ● Logging ● Monitoring ● Storage & Persistence

Slide 25

Slide 25 text

● No writing inside the container ● Be as Read-Only as possible ● ONE PROCESS PER CONTAINER

Slide 26

Slide 26 text

# config/application.rb L21 logger = ActiveSupport::Logger.new(STDOUT) Sidecar for centralised logging ● ELK ● Fluentd ● Deliver config as env variables - use .env in dev

Slide 27

Slide 27 text

● Sidecar for monitoring ● Integrate monitoring at multiple levels - Pod / Application / Service ● Use monitoring responses to fail gracefully

Slide 28

Slide 28 text

Persistence is a problem!

Slide 29

Slide 29 text

Prefer managed services

Slide 30

Slide 30 text

PVs and PVCs ● Flashy but hard problems ● Reclaims, Deletes and Recycles are dangerous ● Databases are scary to put on PVs

Slide 31

Slide 31 text

Providers

Slide 32

Slide 32 text

● GKE ● EKS ● AKS ● Fargate ● Vanilla

Slide 33

Slide 33 text

Post Mortem ● High-speed intro - Docker and K8s ● Starting with development ● Hitting Staging / UAT / Prod ● Who’s around the place ● Q & A

Slide 34

Slide 34 text

Thank You!

Slide 35

Slide 35 text

Slides at https://speakerdeck.com/cruisemaniac