DevOps + Infrastructure TRACK SUPPORTED BY About me Nils Peeters - - PowerPoint PPT Presentation

devops infrastructure
SMART_READER_LITE
LIVE PREVIEW

DevOps + Infrastructure TRACK SUPPORTED BY About me Nils Peeters - - PowerPoint PPT Presentation

DevOps + Infrastructure TRACK SUPPORTED BY About me Nils Peeters DevOps Engineer nils@scalecity.io https://www.linkedin.com/in/nilspeeters/ www.scalecity.io Containerized Drupal, Kubernetes and blue/green Down the rabbit


slide-1
SLIDE 1
slide-2
SLIDE 2

DevOps + Infrastructure

TRACK SUPPORTED BY

slide-3
SLIDE 3

About me

  • Nils Peeters
  • DevOps Engineer
  • nils@scalecity.io
  • https://www.linkedin.com/in/nilspeeters/
  • www.scalecity.io
slide-4
SLIDE 4

Containerized Drupal, Kubernetes and blue/green

Down the rabbit hole

slide-5
SLIDE 5

Agenda

  • Kubernetes
  • What, how and why
  • Q&A
  • Drupal 8
  • Containerized
  • Q&A
  • Deploying
  • CI/CD
  • Rolling-update
  • Blue-green
  • Q&A
slide-6
SLIDE 6

Kubernetes

The what, how and why

slide-7
SLIDE 7

What is Kubernetes?

  • Open source
  • Borg
  • 70 000 commits
  • 1800 contributors
  • Google, Microsoft, Red Hat and Huawei
  • Cloud Native Computing Foundation
  • https://www.cncf.io/
slide-8
SLIDE 8

What is Kubernetes?

  • Container orchestrator
  • Automation
slide-9
SLIDE 9

What is Kubernetes?

  • Master
  • API Server
slide-10
SLIDE 10

What is Kubernetes?

  • Nodepool(s)
  • Same machine type
slide-11
SLIDE 11

What is Kubernetes?

  • Node
  • “Machine” (VM)
  • COS
  • Fleeting
  • Pods
slide-12
SLIDE 12

Pods vs Containers

What is this “Pod” you speak of?

slide-13
SLIDE 13

Pods vs Containers

Pod != Container

slide-14
SLIDE 14

Image reference:

Technology X

I’m a container!

Technology X

I’m a pod!

slide-15
SLIDE 15

Pods vs Containers: example

PHP-fpm Nginx

slide-16
SLIDE 16

Pods vs Containers: example

slide-17
SLIDE 17

Pods vs Containers: example

ElasticSearch Kibana

slide-18
SLIDE 18

Pods vs Containers: example

slide-19
SLIDE 19

Pods vs Containers: example

d

slide-20
SLIDE 20

Pod vs Containers

apiVersion: v1 kind: Pod metadata: name: www spec: containers:

  • name: my-nginx

image: docker.example.com/nginx:1.14 ports:

  • containerPort: 8080
  • name: my-php

image: docker.example.com/php:7.1-fpm ports:

  • containerPort: 9000
slide-21
SLIDE 21

Services

Connecting the Pods

slide-22
SLIDE 22

Services

  • Networking component
  • Labels
  • Name = hostname
slide-23
SLIDE 23

Services

kind: Service apiVersion: v1 metadata: name: www spec: ports:

  • protocol: TCP

port: 80 targetPort: 8080

Will resolve as hostname www:80

slide-24
SLIDE 24

Labels & label selectors

Connecting the dots

slide-25
SLIDE 25

Labels & label selectors

  • Services connect pods
  • Key value
  • Get operations by label
slide-26
SLIDE 26

Labels & label selectors

slide-27
SLIDE 27

Labels & label selectors

slide-28
SLIDE 28

Labels & label selectors

slide-29
SLIDE 29

Labels & label selectors

apiVersion: v1 kind: Pod metadata: name: elastic labels: app: elastic role: master spec: containers:

  • name: my-apache

image: docker.example.com/elasticsearch:6.4 ports:

  • containerPort: 8080
slide-30
SLIDE 30

Labels & label selectors

apiVersion: v1 kind: Service metadata: name: elastic labels: name: elastic spec: selector: app: elastic role: master ports:

  • protocol: TCP

port: 80 targetPort: 8080

Watch out here!

slide-31
SLIDE 31

Configmaps & Secrets

You pods act my way, or the highway

slide-32
SLIDE 32

Configmaps

  • Pod configuration
  • Attached by name
  • Deploy
  • = upload to master
slide-33
SLIDE 33

Secrets

  • Configmap + encryption
  • Great for stuff like API keys
slide-34
SLIDE 34

Configmaps / Secrets

apiVersion: v1 kind: ConfigMap metadata: name: my-apache-config data: my.conf: | <VirtualHost *:8080> DocumentRoot "/www/example1" ServerName www.example.com </VirtualHost>

slide-35
SLIDE 35

Configmaps / Secrets

apiVersion: v1 kind: Pod spec: containers:

  • name: my-apache

image: docker.example.com/apache:2.4 ports:

  • containerPort: 8080

volumeMounts:

  • name: sites-enabled-config

mountPath: /etc/apache2/sites-enabled/default.conf subPath: my.conf volumes:

  • name: sites-enabled-config

configMap: name: my-apache-config

slide-36
SLIDE 36

Drupal 8

Containerized

slide-37
SLIDE 37

Component breakdown – D8

slide-38
SLIDE 38

Container breakdown – D8

PHP-fpm Nginx MySQL Varnish

slide-39
SLIDE 39

Container breakdown – D8

Linux cron

slide-40
SLIDE 40

Container buildup: cron

slide-41
SLIDE 41

Pod buildup & dataflow

mysql:3306 varnish:80,443 www:80 cron

https://example.com

slide-42
SLIDE 42

Deploying

All that good stuff

slide-43
SLIDE 43

Jenkins

  • Knowledge in-house
  • Pipeline script
  • Lazy Java
  • Mature
slide-44
SLIDE 44

Rolling update

Default deploy method in Kubernetes

slide-45
SLIDE 45

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.13

slide-46
SLIDE 46

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-47
SLIDE 47

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-48
SLIDE 48

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.14 nginx: 1.14

slide-49
SLIDE 49

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.14 nginx: 1.14

slide-50
SLIDE 50

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-51
SLIDE 51

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-52
SLIDE 52

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-53
SLIDE 53

Rolling update

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-54
SLIDE 54

Blue-green

Not available in vanilla kubernetes

slide-55
SLIDE 55

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.13 nginx: 1.13

slide-56
SLIDE 56

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-57
SLIDE 57

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-58
SLIDE 58

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-59
SLIDE 59

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.13 nginx: 1.14 nginx: 1.14 nginx: 1.13 nginx: 1.13 nginx: 1.14

slide-60
SLIDE 60

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-61
SLIDE 61

Blue-green

  • Use-case: upgrading nginx from 1.13 to 1.14

nginx: 1.14 nginx: 1.14 nginx: 1.14

slide-62
SLIDE 62

Why now

  • Not new
  • Duplicate entire infrastructure
  • Cheaper
  • Stateless
slide-63
SLIDE 63

Advantages

  • Never in a mixed state
  • Less downtime vs classic deployment
slide-64
SLIDE 64

Blue-green

  • Use-case: upgrading drupal

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

slide-65
SLIDE 65

Blue-green

  • Use-case: upgrading drupal

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

slide-66
SLIDE 66

Advantages

  • Never in a mixed state
  • Less downtime vs classic deployment
  • Safety nets
  • Rollback
slide-67
SLIDE 67

Blue-green gone wrong

  • Use-case: fallback on faulty code

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

slide-68
SLIDE 68

Blue-green gone wrong

  • Use-case: fallback on faulty code

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

slide-69
SLIDE 69

Blue-green gone wrong

  • Use-case: fallback on faulty code

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

slide-70
SLIDE 70

Blue-green gone wrong

  • Use-case: fallback on faulty code

Codebase v1 Codebase v1 Codebase v1

slide-71
SLIDE 71

Advantages

  • Never in a mixed state
  • Less downtime vs classic deployment
  • Safety nets
  • Rollback
  • Canary
slide-72
SLIDE 72

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com

slide-73
SLIDE 73

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com

slide-74
SLIDE 74

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com https://internal.example.com

slide-75
SLIDE 75

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com https://internal.example.com

slide-76
SLIDE 76

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com

slide-77
SLIDE 77

Blue-green canary

  • Use-case: canary

Codebase v1 Codebase v2 Codebase v2 Codebase v1 Codebase v1 Codebase v2

https://example.com

slide-78
SLIDE 78

Advantages

  • Never in a mixed state
  • Less downtime vs classic deployment
  • Safety nets
  • Rollback
  • Canary
slide-79
SLIDE 79

Issues

  • Costly
  • Stateful components
  • Can get pretty confusing
  • Communication and teamwork required
slide-80
SLIDE 80

Drupal pitfalls

  • Stateful component
  • Duplication?
  • Content freeze?
  • Deploy commands
  • One or all replica’s?
  • On blue or green stack?
slide-81
SLIDE 81

Thanks!

Nils Peeters DevOps Engineer @ ScaleCity nils@scalecity.io https://www.linkedin.com/in/nilspeeters/

slide-82
SLIDE 82

Become a Drupal contributor Friday from 9am

  • First timers workshop
  • Mentored contribution
  • General contribution
slide-83
SLIDE 83

Thanks!

Nils Peeters DevOps Engineer @ ScaleCity nils@scalecity.io https://www.linkedin.com/in/nilspeeters/