ci/cd with kubernetes, helm & wercker (#madscalability)

32
CI/CD with Kubernetes, Helm & Wercker #madScalability Madrid 30/11/2016

Upload: diacode

Post on 16-Apr-2017

1.394 views

Category:

Software


4 download

TRANSCRIPT

Page 1: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

CI/CD with Kubernetes, Helm & Wercker

#madScalabilityMadrid

30/11/2016

Page 2: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

About me: Javier Cuevas @javier_dev

AIRBNB FOR DOGS “MAJESTIC” RAILS 3.2 MONOLITH

RUBY ON RAILS SHOP WHO EMBRACED ELIXIR

previously now full time!

Page 3: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

First things first:My review of the new

MacBook Pro with Touch Bar:

Meh 😔

Page 4: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Disclaimers

1. I learned Docker while learning Kubernetes. I ain’t no expert.

2. Gudog is not at unicorn scale. We’re just at dog scale.

Page 5: CI/CD with Kubernetes, Helm & Wercker (#madScalability)
Page 6: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

NOW LET’S GET STARTED

Page 7: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

A LOOK BACK TO DEVOPS

@ Gudog

Page 8: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Hosting / Cloud ProvisioningContinuos

Integration Deployments

2013 DigitalOcean SSH all the things 🙀 Jenkins Capistrano

2014 AWS EC2 Rubber Shippable Capistrano

2015 AWS EC2 (OpsWorks) Chef (OpsWorks) Shippable Chef (OpsWorks)

2016Google Container Engine

(GKE)Kubernetes 💙 Wercker Kubernetes + Helm

Page 9: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Why we choseGoogle Cloud

😱 Because we ran out of AWS credits and we got new credits for Google Cloud.

💸 Because (now that we’re paying for it) is cheaper than AWS.

👌 Because it has the best integration available with Kubernetes.

Page 10: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Why we choseKubernetes

' Because the guy from Google Cloud told us it was super cool.

🤔 Because we had no idea what that Docker thing was about and we were wondering.

Page 11: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Why we choseWercker

🚀 Because it was way faster than Shippable running our Slow Rails Test Suite™ .

🤑 Because, as Shippable, it’s free.

✨ Because the UX/UI is so pretty.

Page 12: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

KUBERNETES 101 (IN 3 MINS)

Page 13: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

What is Kubernetes?

• Open-source system for container orchestration and more.

• Works with many cloud providers (Google Cloud, AWS, etc.) and bare metal.

Page 14: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Basic Kubernetes concepts• Node: a VM or bare metal machine running

Kubernetes.

• Cluster: a bunch of nodes.

• Pod: a group of one or more containers.

• Deployment: defines how many replicas of a Pod you want and how to perform updates (deploys).

• Service: exposes some pods in a given port.

Page 15: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

More about Kubernetes

https://www.youtube.com/watch?v=K_Kh4LMiiqQ

Page 16: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

HOW WE USE KUBERNETES

Page 17: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Worker Deployment

WebService

DB Service

Redis Service

Memcached Service

Memcached Deployment

Memcached Podmemcached

Worker Podresque

Worker Podresque

Web Deployment

…Web Podnginx + unicorn

Web Podnginx + unicorn

Cron Deployment

Cron Podcron -f

Redis Deployment

Redis Podredis

DB Deployment

DB Podpostgres

WebIngress ☁Internet

Page 18: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

HELM 101 (IN 3 MINS)

Page 19: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

What is Helm?• It’s a package manager for Kubernetes 🤔

• Charts are packages of pre-configured Kubernetes resources.

• You can use public Charts to easily install apps into your cluster (eg: postgresql, wordpress).

• … Or you can create a private Chart for your application.

Page 20: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

What is Helm?• You can use templates to define your Charts 🙌

• Helm has two parts:

- helm: a CLI client

- tiller: A server (tiller) than runs in your Kubernetes cluster as another pod. You can install tiller in your cluster with: $ helm init

Page 22: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

HOW WE USE HELM

Page 23: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

File structure & code!"" app!"" config!"" db!"" deploy!"" lib!"" log!"" public!"" script!"" spec!"" vendor!"" Gemfile!"" Gemfile.lock!"" Procfile!"" Rakefile!"" config.ru#"" wercker.yml

deploy!"" kubernetes-chart$   !"" templates$   $   !"" _helpers.tpl$   $   !"" cron.yaml$   $   !"" db.yaml$   $   !"" memcached.yaml$   $   !"" redis.yaml$   $   !"" secrets.yaml$   $   !"" web.yaml$   $   #"" worker.yaml$   !"" Chart.yaml$   !"" README.md$   !"" production-values.yaml$   !"" rails_env.yaml$   !"" staging-values.yaml$   #"" values.yaml!"" nginx.conf#"" unicorn.rb

https://gist.github.com/javiercr/fa4335e6bc67147b1e12523b0282a18a

Page 24: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

WERCKER 101 (IN 3 MINS)

Page 25: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

What is Wercker?• It’s a Docker-Native CI/CD Automation platform for

Kubernetes & Microservice Deployments.

• With Wercker you define your CI/CD process as Workflow composed by multiple Pipelines.

• Each Pipeline is defined by multiple Steps. Wercker offers a Registry of shared steps (eg: to install kubectl)

Page 26: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

HOW WE USE WERCKER

Page 27: CI/CD with Kubernetes, Helm & Wercker (#madScalability)
Page 28: CI/CD with Kubernetes, Helm & Wercker (#madScalability)
Page 29: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

install nodejs, phantomjs

bundle install

rake db:create

rspec

install nodejs, nginx, cron

copy nginx.conf

copy unicorn.rb

bundle install

rake assets:precompilehipchat notification

install kubectl

install helm

helm upgrade

hipchat notification

buildbuild-container

deploy-staging

Gudog’s Wercker Workflow

note that we decided to only automate deployments to staging. env. however deploying to production it’s just one click

(executing the deploy-production pipeline from wercker ui)

docker push to GCR

Page 30: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

Gudog’s Wercker Workflow

Our wercker.yml: https://gist.github.com/javiercr/fa4335e6bc67147b1e12523b0282a18a#file-wercker-yml

Page 31: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

http://blog.wercker.com/Dockerfiles-considered-harmful

Page 32: CI/CD with Kubernetes, Helm & Wercker (#madScalability)

THANK YOU Questions?

Special thanks to @LachlanEvenson from Deis for helping me get started with Helm and the k8s community.