Alm dos Containers na Nuvem QConSP - Containers & Devops 26 - - PowerPoint PPT Presentation

al m dos containers na nuvem
SMART_READER_LITE
LIVE PREVIEW

Alm dos Containers na Nuvem QConSP - Containers & Devops 26 - - PowerPoint PPT Presentation

Alm dos Containers na Nuvem QConSP - Containers & Devops 26 April 2017 Guilherme Rezende Globo.com About me Software Engineer at Globo.com/Tsuru @guilhermebr (GitHub) in/guilhermebr (LinkedIn) @gbrezende (Twitter) Agenda Cloud Native


slide-1
SLIDE 1

Além dos Containers na Nuvem

QConSP - Containers & Devops 26 April 2017

Guilherme Rezende Globo.com

slide-2
SLIDE 2

About me

Software Engineer at Globo.com/Tsuru @guilhermebr (GitHub) in/guilhermebr (LinkedIn) @gbrezende (Twitter)

slide-3
SLIDE 3

Agenda

Cloud Native App Containers CaaS Swarm Kubernetes PaaS Tsuru ❤ FaaS

slide-4
SLIDE 4

Cloud Native App

Born to be Containerized 12Factor Manifesto Ephemeral File System Endpoint for Healthcheck Endpoint for Metrics Resilient Stateless Horizontal Scalable Better use of Resources Smaller Bills Culture Change

slide-5
SLIDE 5

Our App

Thumbor ❤ github.com/thumbor/thumbor Smart Imaging Service Crop, Resizing, Filters on-demand Thumbnail Service by globo.com

slide-6
SLIDE 6

Containers

10+y/o (2000 Jails - FreeBSD) Kernel namespaces (ipc, uts, mount, pid, network and user) Linux control Groups (cgroups) - memory, cpu, i/o Chroot LXC by IBM 2008 Docker 2013 - focus on developers OCI (image-spec, runtime-spec, runC, containerd) Market: 2016: $762m | 2020: $20b in revenue

slide-7
SLIDE 7

Overview of *aaS

slide-8
SLIDE 8

CaaS

Between IaaS and PaaS Manage Containers using API's and Web Interface Pay only for Container Resources (compute instances, LB, Schedulling) Basically the Orchestration Platform

slide-9
SLIDE 9

CaaS Providers

Azure Container Service (DC/OS, Swarm, Kubernetes) Google Container Engine (Kubernetes) IBM Bluemix Container Service (Kubernetes) Amazon ECS

slide-10
SLIDE 10

Orchestrators

Swarm Kubernetes Apache Mesos Docker Cluster by Tsuru

slide-11
SLIDE 11

Swarm

Docker, Inc SwarmKit Docker Engine embedded >/ Swarm Mode Services Tasks Compose File Written in Go :)

slide-12
SLIDE 12

Demo

slide-13
SLIDE 13

Demo: Compose File

docker-compose.yml

version: '3.1' services: thumbor: image: apsl/thumbor:latest environment:

  • ALLOW_UNSAFE_URL=True
  • DETECTORS=['thumbor.detectors.face_detector','thumbor.detectors.feature_detector']
  • LOG_LEVEL=debug

deploy: replicas: 2 restart_policy: condition: on-failure restart: always ports:

  • "80:8000"
slide-14
SLIDE 14

Demo: Google Cloud Compute and Docker Machine

$ gcloud config set project qconsp-demo $ gcloud auth application-default login $ docker-machine create --driver google \

  • -google-project qconsp-demo \
  • -google-open-port 80/tcp \

swarm-master $ docker-machine create --driver google \

  • -google-project qconsp-demo \
  • -google-open-port 80/tcp \

swarm-node1 $ gcloud compute instances list

slide-15
SLIDE 15

Demo: Swarm Cluster

$ eval $(docker-machine env swarm-master) $ docker swarm init --advertise-addr {SWARM_MASTER_PRIVATE_IP} * Copy the join command $ eval $(docker-machine env swarm-node1) * Paste the join command $ eval $(docker-machine env swarm-master) $ docker node ls

slide-16
SLIDE 16

Demo: Deploy

$ docker stack deploy --compose-file=docker-compose.yml qconsp $ docker stack ps qconsp $ open http://{SWARM_EXTERNAL_IP}/unsafe/200x300/smart/https://goo.gl/yudmrQ

slide-17
SLIDE 17

Kubernetes

Google, RedHat, Microsoft, CoreOS, ... Google Borg - Cluster Manager 10+y/o Stable API Deployments Pods Services Written in Go :)

slide-18
SLIDE 18

Demo

slide-19
SLIDE 19

Demo: deployment.yml

kind: Deployment apiVersion: extensions/v1beta1 metadata: name: thumbor spec: replicas: 2 selector: matchLabels: app: thumbor version: "latest" template: metadata: name: thumbor labels: app: thumbor version: "latest" spec:

(cont...)

slide-20
SLIDE 20

Demo: deployment.yml

(...cont) containers:

  • name: thumbor

image: apsl/thumbor:latest env:

  • name: LOG_LEVEL

value: "DEBUG"

  • name: ALLOW_UNSAFE_URL

value: "True"

  • name: DETECTORS

value: "['thumbor.detectors.face_detector', 'thumbor.detectors.feature_detector']"

  • name: THUMBOR_PORT

value: "8000" imagePullPolicy: Always

slide-21
SLIDE 21

Demo: service.yml

kind: Service apiVersion: v1 metadata: name: thumbor labels: app: thumbor spec: ports:

  • port: 8000

nodePort: 30000 selector: app: thumbor type: NodePort

slide-22
SLIDE 22

Demo: Google Container Engine

$ gcloud container clusters create qconsp --num-nodes=2 $ gcloud compute instances list |grep gke

slide-23
SLIDE 23

Demo: Deploy

$ kubectl create -f . $ kubectl get all $ open http://{GKE_NODE_IP}:30000/unsafe/200x300/smart/https://goo.gl/yudmrQ

slide-24
SLIDE 24

PaaS

Zero Downtime Deploy Application Healing Auto-scaling LB Focus on Developer Experience Deploy from Source Code

slide-25
SLIDE 25

Some Paas

Heroku Google App Engine OpenShift CloudFoundry Tsuru

slide-26
SLIDE 26

Tsuru ❤

slide-27
SLIDE 27

Premisses

Reduce Time to Market Open Source Simplicity No Vendor Lock-in Deploy Safe Multi-Cluster Written in Go :)

slide-28
SLIDE 28

At Globo.com

Cartola GloboPlay APIs Feed WebMedia

slide-29
SLIDE 29

At Globo.com

slide-30
SLIDE 30

Out of Globo.com

JusBrasil eduK Nuveo Filmow Rivendel Stone Hotel Urbano EF.com (London) École nationale supérieure d'informatique pour l'industrie et l'entreprise

slide-31
SLIDE 31

Demo

docs.tsuru.io github.com/tsuru/tsuru

slide-32
SLIDE 32

Demo: tsuru-gce.yml

name: tsuru-qconsp components: tsuru: version: latest driver: name: google private-ip-interface: ens4

  • ptions:

google-project: qconsp-demo google-tags: tsuru google-open-port:

  • 8080/tcp
  • 80/tcp
slide-33
SLIDE 33

Demo: Tsuru Installer

Install client from: https://github.com/tsuru/tsuru-client/releases $ tsuru install -c tsuru-gce.yml

slide-34
SLIDE 34

Demo: Deploy

$ tsuru app-create qconsp python $ tsuru env-set LOG_LEVEL="DEBUG" ALLOW_UNSAFE_URL="True" DETECTORS="['thumbor.detectors.face_detector', 'thumbor.detectors.feature_detector']" -a qconsp $ tsuru app-deploy -i apsl/thumbor:latest -a qconsp $ tsuru app-list # get app url $ open http://{APP_URL}/unsafe/200x300/smart/https://goo.gl/yudmrQ

slide-35
SLIDE 35

FaaS

Serverless for the Dev Events, Workers, Custom Code CGI (request in, start process to handle it, return something) HotFunctions Nano-services...? Why the Hype?

slide-36
SLIDE 36

Case Globo.com

Backstage/Functions ❤ github.com/backstage/functions Writen in ... NodeJS =\ Sandbox Support: JS, Ruby Publication Platform Custom Code

slide-37
SLIDE 37

Enterprise

Lambda Google Cloud Functions IBM OpenWhisky

slide-38
SLIDE 38

Open Source

IronFunctions - github.com/iron-io/functions GoFn - github.com/nuveo/gofn Fission - github.com/ssion/ssion (Kubernetes Only) Funktion - github.com/funktionio/funktion (Kubernetes Only) faas - github.com/ssion/ssion (Swarm Only)

slide-39
SLIDE 39

Demo

slide-40
SLIDE 40

Demo: Deploy on Tsuru

# redis $ tsuru app-create functions-redis static $ tsuru app-deploy -i redis:latest -a functions-redis

slide-41
SLIDE 41

Demo: Deploy on Tsuru

functions

$ tsuru platform-add nodejs $ tsuru app-create functions nodejs $ tsuru app-info -a functions-redis ... Units [web]: 1 +--------------+---------+------------+-------+ | Unit | State | Host | Port | +--------------+---------+------------+-------+ | 10843bf6fba3 | started | 10.128.0.6 | 32789 | +--------------+---------+------------+-------+ ... $ tsuru env-set REDIS_ENDPOINT=redis://10.128.0.6:32789/0 -a functions $ git clone https://github.com/backstage/functions $ cd functions/ $ tsuru app-deploy -a functions .

slide-42
SLIDE 42

Demo: Using Functions

hello.js

function main(req, res) { const name = (req.body && req.body.name) || "World" res.send({ say: `Hello ${name}!` }) }

Create function route

$ curl -i -X POST http://{FUNCTIONS_APP_URL}/functions/example/hello \

  • H 'content-type: application/json' \
  • d '{"code":"function main(req, res) \

{\n const name = (req.body && req.body.name) || \"World\"\n \ res.send({ say: `Hello ${name}!` })\n}\n"}'

Testing

$ curl -i -X PUT http://{FUNCTIONS_APP_URL}/functions/example/hello/run \

  • H 'content-type: application/json'

$ curl -i -X PUT http://{FUNCTIONS_APP_URL}/functions/example/hello/run \

  • H 'content-type: application/json' \
  • d '{"name": "QconSP"}'
slide-43
SLIDE 43

Demo: Using Functions

qconsp.js

function main(req, res) { const say = (req.body && req.body.say) res.send({ say: `${say} I hope you enjoyed this talk at QconSP! Thank you ;)` }) }

Create function route

$ curl -i -X POST http://{FUNCTIONS_APP_URL}/functions/example/qconsp \

  • H 'content-type: application/json' \
  • d '{"code":"function main(req, res) \

{\n const say = (req.body && req.body.say)\n \ res.send({ say: `${say}! I hope you enjoyed this talk! Thank you ;)` })\n}\n"}'

Running Pipeline

$ curl -g -i \

  • X PUT 'http://{FUNCTIONS_APP_URL}/functions/pipeline?steps[0]=example/hello&steps[1]=example/qconsp' \
  • H 'content-type: application/json' \
  • d '{"name": "Galera"}'
slide-44
SLIDE 44

Thank you

Guilherme Rezende Globo.com @gbrezende (http://twitter.com/gbrezende)

slide-45
SLIDE 45