google cloud platform and kubernetes

92
Cloud Platform and Kubernetes Google Developer Group Aarhus Meet-up Thursday, 28th April 2016 Martin Jensen & Kasper Nissen www.rpi-cloud.com @mrjensens @phennex

Upload: kasper-nissen

Post on 14-Jan-2017

748 views

Category:

Technology


10 download

TRANSCRIPT

Page 1: Google Cloud Platform and Kubernetes

Cloud Platform and KubernetesGoogle Developer Group Aarhus Meet-up Thursday, 28th April 2016

Martin Jensen & Kasper Nissen

www.rpi-cloud.com

@mrjensens @phennex

Page 2: Google Cloud Platform and Kubernetes

Views and opinions are our own. We do not work for, nor do we speak on behalf of .

Page 3: Google Cloud Platform and Kubernetes

So, who are these people then?

Page 4: Google Cloud Platform and Kubernetes

Bachelor: B.Eng ICT Master: M.Eng. Computer Engineering (specialization Distributed Systems and Software Engineering)

Experience: Software Developer @ IT Minds

Technologies: Java, C#, iOS (Objective-C/Swift), Android, JavaScript (jQuery/Ember.JS), ASP.Net MVC, SQL Server, Postgres, MongoDB, Docker, Kubernetes ...

Interests: Cloud computing/architecture, technology evolution, distributed systems, mobile development

Martin Jensen

foto: Lars Kruse, Aarhus Universitet

Bachelor: B.Eng ICT Master: M.Eng. Computer Engineering (specialization Distributed Systems and Software Engineering)

Experience: Software Developer @ IT Minds, Partner @ Drivelogger, Founder @ Let’s Talk Apple Aarhus

Technologies: Java, C#, iOS (Objective-C/Swift), Android, JavaScript (jQuery/Ember.JS), ASP.Net MVC, SQL Server, Postgres, MongoDB, Docker, Kubernetes ...

Interests: Cloud computing/architecture, technology evolution, distributed systems, mobile development

Kasper Nissen

Pervasive Systems group, Section of Electrical and Computer Engineering, Department of Engineering, Aarhus University

Page 5: Google Cloud Platform and Kubernetes

Let’s get started with a short introduction to Cloud Computing…

Page 6: Google Cloud Platform and Kubernetes

What is Cloud Computing?

Page 7: Google Cloud Platform and Kubernetes
Page 8: Google Cloud Platform and Kubernetes

- “Cloud computing refers to applications and services that run on a distributed network using virtualized resources and accessed by common Internet protocols and networking standards.” - B. Sosinsky, The Cloud Computing Bible

- Key enabling concepts

- Abstraction: Cloud computing abstracts the details of system implementation from users and developers

- Virtualization: Cloud computing virtualizes systems by pooling and sharing resources

- Cloud types

- Deployment models: Public, Private, Hybrid, Community

- Service models: IaaS, PaaS, SaaS, (CaaS)

What is Cloud Computing?

Source: “The Cloud Computing Bible”, B.Sosinsky, page 10

Page 9: Google Cloud Platform and Kubernetes

- On-demand self-service

- Broad network access

- Resource pooling

- Rapid elasticity

- Measured service

- Lower costs

- Ease of utilization

- Quality of Service

- Reliability

- Outsourced IT Management

Benefits of Cloud Computing?

Source: “The Cloud Computing Bible”, B.Sosinsky, page 17

Page 10: Google Cloud Platform and Kubernetes

- More suitable for large organizations

- Less customizable

- Latency

- Privacy and security

Disadvantages of Cloud Computing?

Source: “The Cloud Computing Bible”, B.Sosinsky, page 17

Page 11: Google Cloud Platform and Kubernetes

What about Software Architecture?

Page 12: Google Cloud Platform and Kubernetes

Source: http://reiserobby.de/norwegen-trauer-um-todesopfer-von-oslo-und-utoya-mindestens-87-tote/os_monolith/ Source: https://thirdeyemom.com/2015/07/07/the-great-american-road-trip-mount-rushmore/

Monolithic architecture

“A monolith application, in layman terms, is where entire functionality of the application is packaged together as a single unit or application” - Arun Gupta, 2015

Page 13: Google Cloud Platform and Kubernetes

Source: http://reiserobby.de/norwegen-trauer-um-todesopfer-von-oslo-und-utoya-mindestens-87-tote/os_monolith/

Microservice architecture

“Small Autonomous services that work together, modelled around a business domain” - Sam Newman, 2015

Source: http://d195zpdxad0ld.cloudfront.net/media/W1siZiIsIjIwMTIvMDUvMjUvMTVfMDVfMjhfNjkwX1N0b25laGVuZ2VfYXRfZGF3bi5qcGciXSxbImUiLCJqcGciLCItcXVhbGl0eSA2MCJdLFsicCIsInN0cmlwIl1d/Stonehenge%20at%20dawn.jpg

Page 14: Google Cloud Platform and Kubernetes

Monolithic vs Microservice architecture

Source: http://martinfowler.com/articles/microservices.html

Page 15: Google Cloud Platform and Kubernetes

Design for failure - Resilience in a distributed system?

Page 16: Google Cloud Platform and Kubernetes

resilience or resiliency

[ri-zil-yuh ns, -zil-ee-uh ns]

noun 1. the power or ability to return to the original form, position, etc., after being bent,

compressed, or stretched: elasticity. 2. ability to recover readily from illness, depression, adversity, or the like; buoyancy

Source: http://www.dictionary.com/browse/resilience

Page 17: Google Cloud Platform and Kubernetes
Page 18: Google Cloud Platform and Kubernetes

THINGS WILL GO WRONG EMBRACE FAILURES

Page 19: Google Cloud Platform and Kubernetes

The fallacies of distributed computing

1. The network is reliable 2. Latency is zero 3. Bandwidth is infinite 4.The network is secure 5. Topology doesn’t change 6. There is one administrator 7. Transport cost is zero 8. The network is homogeneous

Page 20: Google Cloud Platform and Kubernetes

- Application level

- Synchronous/Asynchronous architecture (request/response, message queues)

- Apply circuit breakers at integration points

- Rather degradation of service than failures

- Manage timeouts

- Bulkheads

- Health checks

- Infrastructure level

- Fault tolerance

- Infrastructure that detects failures

What can we do?

Page 21: Google Cloud Platform and Kubernetes

What is a Container?

Page 22: Google Cloud Platform and Kubernetes
Page 23: Google Cloud Platform and Kubernetes

The challenges

Source: http://pointful.github.io/docker-intro/

Page 24: Google Cloud Platform and Kubernetes

Intermodal shipping container

Source: http://pointful.github.io/docker-intro/

Page 25: Google Cloud Platform and Kubernetes

Docker is a container system for code

Source: http://pointful.github.io/docker-intro/

Page 26: Google Cloud Platform and Kubernetes

What is Continuous Delivery?

Page 27: Google Cloud Platform and Kubernetes

Source: https://www.robots.com/images/Robot%20Integration.jpg

Page 28: Google Cloud Platform and Kubernetes

What is Service Discovery?

Page 29: Google Cloud Platform and Kubernetes
Page 30: Google Cloud Platform and Kubernetes

A little tour of the

Page 31: Google Cloud Platform and Kubernetes

cloud.google.com

Page 32: Google Cloud Platform and Kubernetes

Who uses Google Cloud Platform?

Page 33: Google Cloud Platform and Kubernetes
Page 34: Google Cloud Platform and Kubernetes
Page 35: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 36: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 37: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 38: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 39: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 40: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 41: Google Cloud Platform and Kubernetes

An overview of all the goodies

Page 42: Google Cloud Platform and Kubernetes

Google Cloud Compute

Page 43: Google Cloud Platform and Kubernetes

Google Container Engine

Fully Managed Container Engine is fully managed by Google reliability engineers, ensuring your cluster is available and up-to-date.

Private Container Registry Google Container Registry makes it easy to store and access your private Docker images.

Scalable Easily adjust the cluster resources allocated to your containers, or the size of your container cluster, as your application's requirements change.

Docker Support Container Engine supports the common Docker container format.

Logging Enable Google Cloud Logging with a single checkbox, making it easy to gain insight into how your application is running

Hybrid Networking Reserve an IP address range for your container cluster, allowing your cluster IPs to coexist with private network IPs via Google Cloud VPN.

Source: https://cloud.google.com/container-engine/

Page 44: Google Cloud Platform and Kubernetes

Google Container Registry

Container Engine Use container images with Container Engine with no authentication setup.

Advanced Authentication Easily integrate with your favorite continuous integration, continuous delivery, and container orchestration systems with native Docker Login support.

Container Tags Add and remove image tags with a simple click in the web UI.

Docker V2 Registry API Support Push and pull Docker images to your private Container Registry using the V2 API.

Docker CLI Integration Pull container images from Container Registry using the standard Docker command line interface.

Regional Repositories Get the fastest possible pull times by storing your images close to your Compute Engine instances in Europe, Asia, or US regional Cloud Storage buckets.

Search Images Quickly search for images by name and tag.

Nearline Storage Integration Archival storage of images in Cloud Storage Nearline buckets.

Source: https://cloud.google.com/container-registry/

Page 45: Google Cloud Platform and Kubernetes

Kubernetes - Infrastructure For Everyone ElseKubernetes is an open-source system for automating deployment, operations, and scaling of containerized applications.

#GIFEE

Page 46: Google Cloud Platform and Kubernetes
Page 47: Google Cloud Platform and Kubernetes

How to manage all these containers?

Page 48: Google Cloud Platform and Kubernetes
Page 49: Google Cloud Platform and Kubernetes

How to utilize the resources we have?

Page 50: Google Cloud Platform and Kubernetes

Machine utilization

- Machine shapes

- Workload shapes

- Bin packing problem

Where should we deploy this workload?2.5GB 1Core

Source: bit.ly/1PrkwoN

Page 51: Google Cloud Platform and Kubernetes

Let’s play some tetris

Page 52: Google Cloud Platform and Kubernetes

“Containerization transforms the data center from being machine-oriented to being application-oriented”

Burns et al., Borg, Omega, and Kubernetes, 2016

Source: research.google.com/pubs/pub44843.html

Page 53: Google Cloud Platform and Kubernetes

- Greek for “pilot” or “helmsman of a ship”

- Runs and manages containers

- Builds on Googles experiences running a hyper-scale webplatform for more than 10 years.

- Inspired by Googles internal Cluster Management and scheduling platform, “Borg”

- Supports multiple cloud and bare-metal environments

- 100% Open source, written in Go

What is Kubernetes?

Source: https://youtu.be/_xNFt7FsWaA

Page 54: Google Cloud Platform and Kubernetes

Velocity

Source: https://youtu.be/_xNFt7FsWaA

Page 55: Google Cloud Platform and Kubernetes

Community

Source: https://youtu.be/_xNFt7FsWaA

Page 56: Google Cloud Platform and Kubernetes

Everything at Google runs in containers - Gmail, Web search, …

- MapReduce, batch, …

- GFS, Colossus, …

- Even Google’s Cloud Platform:VMs run in containers

In fact, launches over 2 billion containers per week.

Google and Containers

Page 57: Google Cloud Platform and Kubernetes

How does it work?

Page 58: Google Cloud Platform and Kubernetes

Let’s have a look a some of the concepts

Page 59: Google Cloud Platform and Kubernetes

Pods

Page 60: Google Cloud Platform and Kubernetes

Pods

- Kubernetes uses nested containers

- The outer-most one provides a pool of resources, and is called a pod

- The inner ones provide deployment isolation

- Kubernetes regularizes things and always run an application container inside a top-level pod, even if the pod contains a single container

- “A pod is a collection of containers that are tightly bound”, Brian Dorsey

- The atom of scheduling for containers

- Runs on the same virtual/physical host

Page 61: Google Cloud Platform and Kubernetes

Pods

Pod

Web server

Container

Pod

Web server

Consumers

Container

Git sync

Container

Git repoConsumers

Inspiration: http://bit.ly/1rmC0cz

Page 62: Google Cloud Platform and Kubernetes

Pod networking

Page 63: Google Cloud Platform and Kubernetes

Pod networking

- Pods have IPs which are routable

- Pods can communicate directly with each other

- Even across nodes

- No brokering of Port Numbers

- Many solutions

- Flannel (what we use in the Raspberry Pi Cluster)

- Cloud Providers

Page 64: Google Cloud Platform and Kubernetes

Pod networking

Pod

Container

10.1.2.106

10.1.2.0/24

Pod

Container

10.1.1.211

10.1.1.0/24

Pod

Container

10.1.3.175

10.1.3.0/24

Node

Node

Node

Inspiration: http://bit.ly/1rmC0cz

Page 65: Google Cloud Platform and Kubernetes

Services

Page 66: Google Cloud Platform and Kubernetes

Services

- A service has a static IP and a DNS entry

- Acts as a load-balancer and knows how to route traffic to pods

- Load balances incoming request across constituent pods

Page 67: Google Cloud Platform and Kubernetes

Services

Pod

Web server

Container

Pod

Web server

Container

Pod

Web server

Container

type=FE type=FE type=FE

Consumers

Service

VIP

Label selector: type=FE

Inspiration: http://bit.ly/1rmC0cz

Page 68: Google Cloud Platform and Kubernetes

Labels

Page 69: Google Cloud Platform and Kubernetes

Labels

- Labels are simple key/value pairs

- Kubernetes connects things together with labels

- Only grouping mechanism in Kubernetes

- Reduces coupling

Web server

Container

track=staging

app=webserver

tier=frontend

Pod

Page 70: Google Cloud Platform and Kubernetes

Labels

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

version=2

version=2

Dashboard Dashboard

show: type=FE show: version=v2

Inspiration: http://bit.ly/1rmC0cz

Page 71: Google Cloud Platform and Kubernetes

Replica Sets

Hey! You always wear the same as I do

Page 72: Google Cloud Platform and Kubernetes

ReplicaSets

- A Replica Set ensures that a specified number of pods “replicas” are running at any given time.

- Replica Set is the next-generation Replication Controller

- The only difference right now is the selector support (set-based support)

- Use deployments to control your Replica Sets

Page 73: Google Cloud Platform and Kubernetes

Replica Sets

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

type=FE

Dashboard Dashboard

Current: 3 Desired: 3

Deployment

Page 74: Google Cloud Platform and Kubernetes

Source: http://imgur.com/tjD4L

DeploymentsOH F*CK! Not again! Whyyyyyy…

Page 75: Google Cloud Platform and Kubernetes

Deployments

- Deployment is a higher-level concept that manages replica sets, pods and provides declarative updates to pods along with a lot of other useful features

- You only need to describe the desired state in a Deployment object, and the Deployment controller will change the actual state to the desired state at a controlled rate for you

- Deploying a new version will result in a rolling-update, where Kubernetes will replace one pod at a time until all are running the latest version.

Page 76: Google Cloud Platform and Kubernetes

Deployments

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

type=FE

Dashboard

Current: 3 Desired: 3

version=2 version=2 version=2

Pod

Container

type=FE

version=3

New version

Deployment

Page 77: Google Cloud Platform and Kubernetes

Deployments

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

type=FE

Dashboard

version=3 version=2 version=2

Deployment

Current: 3 Desired: 3

Page 78: Google Cloud Platform and Kubernetes

Deployments

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

type=FE

Dashboard

version=3 version=3 version=2

Deployment

Current: 3 Desired: 3

Page 79: Google Cloud Platform and Kubernetes

Deployments

Pod

Container

type=FE

Pod

Container

type=FE

Pod

Container

type=FE

Dashboard

version=3 version=3 version=3

Deployment

Current: 3 Desired: 3

Page 80: Google Cloud Platform and Kubernetes

Source: http://imgur.com/tjD4L

Canary

WHAZZZAH! I’m the new kid

on the stick!

Page 81: Google Cloud Platform and Kubernetes

Canary

- Running different versions at the same time

- Testing new features with a subset of your users

Page 82: Google Cloud Platform and Kubernetes

Canary

Pod

Container

type=BE

Pod

Container

type=BE

Pod

Container

type=BE

Dashboard Dashboard

Deployment

version=1 type=BE

Current: 2 Desired: 2

Deployment

version=2version=1version=1

version=2 type=BE

Current: 1 Desired: 1

Consumers

Service

VIP

name=backend Label selector: type=BE

Inspiration: http://bit.ly/1rmC0cz

Page 83: Google Cloud Platform and Kubernetes

Source: http://imgur.com/tjD4L

Scaling

I feel inflated today!

Page 84: Google Cloud Platform and Kubernetes

Scale (auto)

- Horizontal Pod Autoscaler allows you to automatically scale the number of pods in a deployment based on observed CPU utilization.

- The autoscaler is implemented as a Kubernetes API resource and controller.

- The resource describes behavior of the controller

- The controller periodically adjusts the number of replicas in a deployment to match the observed average CPU utilization to the target specified by the user.

Page 85: Google Cloud Platform and Kubernetes

Scale (auto)

Pod 1

Container

type=FE

Pod 2

Container

type=FE

Pod N

Container

type=FE

version=3 version=3 version=3

Deployment

Scale…

Horizontal Pod

Autoscaler

kubectl autoscale deployment foo --max=5 --cpu-percent=80

Page 86: Google Cloud Platform and Kubernetes

Demo application

UI/Gateway

Cat-service Dog-serviceconfi

g-se

rvice

Page 87: Google Cloud Platform and Kubernetes

Demo on Raspberry Pi Kubernetes cluster

Page 88: Google Cloud Platform and Kubernetes

How can I get started with Kubernetes?

Page 89: Google Cloud Platform and Kubernetes

cloud.google.com

- kubernetes.io

- Documentation, great samples, etc.

- Slack: http://slack.k8s.io

- Github: https://github.com/kubernetes/kubernetes

- Pricing:

60 days free trial. You get $300 in credit.

https://cloud.google.com/free-trial/

Page 90: Google Cloud Platform and Kubernetes

Demo on Google Container Engine

Page 91: Google Cloud Platform and Kubernetes

Thank you

Google Developer Group Aarhus Meet-up Thursday, 28th April 2016

Martin Jensen & Kasper Nissen

www.rpi-cloud.com

@mrjensens @phennex

Page 92: Google Cloud Platform and Kubernetes

References

- Book: “The Cloud computing bible”, Sosinsky, B.

- Link: “Microservices - a definition of this new architectural term”, Fowler, M., Lewis, J.

- martinfowler.com/articles/microservices.html

- Link: “Borg, Omega, and Kubernetes”, Burns, B. et al.

- http://research.google.com/pubs/pub44843.html

- Link: “Introduction to Docker”

- pointful.github.io/docker-intro/