Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

82
‹#› @tpryan Terrence Ryan Developer Advocate Containing Chaos with Kubernetes

Transcript of Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

Page 1: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Terrence Ryan Developer Advocate

Containing Chaos with Kubernetes

Page 2: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Who are you?

Page 3: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

01 IntroductionWhy Kubernetes?

Page 4: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

What problem are we trying to solve?

Page 5: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Page 6: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# BACKEND FROM ubuntu:12.04

ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh

EXPOSE 3306

CMD ["/usr/sbin/mysqld"]

Page 7: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 8: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 9: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 10: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Page 11: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

# JUST SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Page 12: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Page 13: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

# FRONTEND FROM nginx COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Page 14: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 15: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 16: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# BACKEND FROM ubuntu:12.04

ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh

EXPOSE 3306

CMD ["/usr/sbin/mysqld"]

Page 17: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

# BACKEND FROM ubuntu:12.04

ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh

EXPOSE 3306

CMD ["/usr/sbin/mysqld"]

# BACKEND FROM ubuntu:12.04

ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh

EXPOSE 3306 VOLUME ["/etc/mysql", "/var/lib/mysql"]

CMD ["/usr/sbin/mysqld"]

Page 18: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 19: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 20: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 21: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 22: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 23: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 24: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 25: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 26: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 27: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 28: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

That’s a lot to manage.

Page 29: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 30: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

4 3 2

Page 31: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

02 ConceptsWhat is Kubernetes?

Page 32: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Desired State

Page 33: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

Page 34: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

Page 35: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

Page 36: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

./launch_services.sh x 2

Page 37: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

./launch_services.sh x 2

./launch_backend.sh x 1

Page 38: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

./launch_services.sh x 2

./launch_backend.sh x 1

Page 39: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

./launch_services.sh x 2

./launch_backend.sh x 1

Page 40: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Build Script

./create_docker_images.sh

./launch_frontend.sh x 3

./launch_services.sh x 2

./launch_backend.sh x 1

Page 41: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Desired State

There should be: 3 Frontends 2 Services 1 Backend

Page 42: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Desired State

There should be: 3 Frontends 2 Services 1 Backend

Page 43: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Desired State

There should be: 3 Frontends 2 Services 1 Backend

Page 44: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Pods

• Atomic component of Kubernetes • Made from one or more containers • It’s okay to have just one container • Share

• IP Address • Namespace

• Examples • Webserver + CMS • All Web available services • Converting an all in one box

Page 45: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Containers

• Subatomic particles of Kubernetes • Dockerfiles just like you are used to.

Page 46: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Controllers

• Handle turning current state into desired state • Example

• Replication Controllers

Page 47: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Controllers

• Handle turning current state into desired state • Example

• Replication Controllers

Observe

Page 48: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Controllers

• Handle turning current state into desired state • Example

• Replication Controllers

Observe

Act

Page 49: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Controllers

• Handle turning current state into desired state • Example

• Replication Controllers

Observe

Diff

Act

Page 50: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Service

• Defines a set of pods that work together for a common purpose

• Gets a virtual IP address • Used for exposing an application to non

Kubernetes clients

Virtual IP address

Page 51: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Labels & Selectors

• Metadata for Objects • Select sections of your infrastructure

App Tier Env

todo frontend stage

App Tier Env

todo frontend prod

App Tier Env

todo frontend dev

App Tier Env

todo frontend test

App Tier Env

todo api prod

App Tier Env

todo backend prod

App Tier Env

todo api stage

App Tier Env

todo api test

App Tier Env

todo api dev

App Tier Env

todo backend stage

App Tier Env

todo backend test

App Tier Env

todo backend dev

Page 52: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Labels & Selectors

• Metadata for Objects • Select sections of your infrastructure

App Tier Env

todo frontend stage

App Tier Env

todo frontend prod

App Tier Env

todo frontend dev

App Tier Env

todo frontend test

App Tier Env

todo api prod

App Tier Env

todo backend prod

App Tier Env

todo api stage

App Tier Env

todo api test

App Tier Env

todo api dev

App Tier Env

todo backend stage

App Tier Env

todo backend test

App Tier Env

todo backend dev

Page 53: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Labels & Selectors

• Metadata for Objects • Select sections of your infrastructure

App Tier Env

todo frontend stage

App Tier Env

todo frontend prod

App Tier Env

todo frontend dev

App Tier Env

todo frontend test

App Tier Env

todo api prod

App Tier Env

todo backend prod

App Tier Env

todo api stage

App Tier Env

todo api test

App Tier Env

todo api dev

App Tier Env

todo backend stage

App Tier Env

todo backend test

App Tier Env

todo backend dev

Page 54: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Labels & Selectors

• Metadata for Objects • Select sections of your infrastructure

App Tier Env

todo frontend stage

App Tier Env

todo frontend prod

App Tier Env

todo frontend dev

App Tier Env

todo frontend test

App Tier Env

todo api prod

App Tier Env

todo backend prod

App Tier Env

todo api stage

App Tier Env

todo api test

App Tier Env

todo api dev

App Tier Env

todo backend stage

App Tier Env

todo backend test

App Tier Env

todo backend dev

Page 55: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Demo: Kubernetes in Action

Page 56: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

There’s More

• Secrets • Rolling Updates • Persistent Volumes

Page 57: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

03 Container EngineHosted Kubernetes

Page 58: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

I’ve mostly talked about developing on Kubernetes

Page 59: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

Page 60: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

Page 61: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

• Choose a node OS: • CoreOS, Atomic, RHEL, Debian, CentOS, Ubuntu, ...

Page 62: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

• Choose a node OS: • CoreOS, Atomic, RHEL, Debian, CentOS, Ubuntu, ...

• Provision machines: • Boot VMs, install and run kube components, ...

Page 63: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

• Choose a node OS: • CoreOS, Atomic, RHEL, Debian, CentOS, Ubuntu, ...

• Provision machines: • Boot VMs, install and run kube components, ...

• Configure networking: • IP ranges for Pods, Services, SDN, ...

Page 64: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

• Choose a node OS: • CoreOS, Atomic, RHEL, Debian, CentOS, Ubuntu, ...

• Provision machines: • Boot VMs, install and run kube components, ...

• Configure networking: • IP ranges for Pods, Services, SDN, ...

• Start cluster services: • DNS, logging, monitoring, ...

Page 65: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Setting up a cluster

• Choose a cloud: • GCE, AWS, Azure, Rackspace, on-premises, …

• Choose a node OS: • CoreOS, Atomic, RHEL, Debian, CentOS, Ubuntu, ...

• Provision machines: • Boot VMs, install and run kube components, ...

• Configure networking: • IP ranges for Pods, Services, SDN, ...

• Start cluster services: • DNS, logging, monitoring, ...

• Manage nodes: • kernel upgrades, OS updates, hardware failures...

Page 66: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Or…

Page 67: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 68: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 69: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Container Engine

Page 70: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Container Engine

• Hosted Kubernetes

Page 71: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Container Engine

• Hosted Kubernetes• A few smart defaults set

Page 72: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Container Engine

• Hosted Kubernetes• A few smart defaults set• Allow for dipping your feet in

Page 73: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

05 ConclusionsBring it home

Page 74: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

Google has been developing and using containers to manage our applications for over 10 years.

Page 75: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Page 76: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Everything at Google runs on Containers: • Gmail, Web Search, Maps, ... • MapReduce, batch, ... • GFS, Colossus, ... • Even Google’s Cloud Platform: VMs run

in containers!

Page 77: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Everything at Google runs on Containers: • Gmail, Web Search, Maps, ... • MapReduce, batch, ... • GFS, Colossus, ... • Even Google’s Cloud Platform: VMs run

in containers!

We launch 2 Billion Containers a week

Page 78: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

We think containers are the way to manage scale.

Page 79: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

You should carefully consider whether running everything on

containers is right for you.

Page 80: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

You should run everything on containers.

Just in case it isn’t clear here. this is not what I am recommending. I’m saying don’t Cherry Pick from the last statements to come to the conclusion that you have to go this way.

Page 81: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Container Engine can make dipping your toes in a little

easier.

Page 82: Containing Chaos with Kubernetes - Terrence Ryan, Google - DevOpsDays Tel Aviv 2015

‹#›@tpryan

Thank Youterrenceryan.com @tpryan This preso: http://bit.ly/tpryan-chaos