Building A Microservices Platform With Kubernetes

Transcription

Building a MicroservicesPlatform with KubernetesMatthew Mark Miller@DataMiller

Cloud Native:Microservices running insideContainers on top ofPlatforms on any infrastructure

MicroserviceA software component of a system that is independentlyreleasable and independently scalable from other parts of thesystem.

ContainerA software process whose access has been reduced to thepoint that it thinks it is the only thing running.

PlatformThe parts of your service that you don't build yourself.

But wait.aren’t we supposed to be FullStack?!

A platform’s responsibility is to makeimplicit the link between a service andthe resource it consumes.

Clouds operate because of workload orchestration

Don’t roll your own orchestration.

Integrating workloads requires tinkering at runtimeToken swappingModifications to the host container’s configurationSwapping in binaries

Integrating this way isn’t easyTakes time & testing to get it rightWhat you built and tested isn’t necessarily whatruns in production.Leads to providers offering fewer, more highlyopinionated stacks

A big question for platformengineers:How can we spend more time building usefulservices and less time maintaining the platform?

KubernetesBorg meets Docker; Resistance is futile

(Obligatory architecture slide)

Kubernetes is popular, open and growing

To those of us building platforms, Kubernetes offersReliable cluster & workload managementA stack agnostic hosting abstraction(Docker)Battle-tested fundamental abstractions thatgive rise to powerful deployment patterns

Kubernetes Fundamentals

ControllersLoops that maintain stateRun continuously on MasterEach Kubernetes object getsits own ControllerControllers are pluggable &lightweightRely on declarative manifeststo determine intent

The PodMany containers, working together as a single unitShared IP & localhostShared filesystemScale togetherSeparate hardware limitsCan be tagged with a label,providing scheduling advice

ServicesPermanent, logical addresses for internal servicesExpose a name, port and stable IP for agroup of podsLoad balance between individual podsProvided to pods via DNS orenvironment variableConstructed using a selector onto podlabels (sort of like a database query)

NetworkingRules for all Kubernetes installationsEach Pod gets its own unique IPaddress (which is the same outside andin)All Pods must be able to communicatewith each other without NATAll Pods must be able to communicatewith and participate in Services

IngressSimplifies Layer 7 access to Kubernetes servicesWorks with load balancers, includingcloud load balancers & nginxPresents a single root URL mapping tomultiple servicesPublicly expose private networksTerminates TLS/SSL

Using the fundamentals tobuild a platformPod patterns from Burns & Oppenheimer, USENIX 2016

How can my platform provide availabilityduring workload releases?

Rolling Deployments

Rolling Deployments

Rolling Deployments

Rolling Deployments

How can my platform non-destructivelyadd functionality to a workload?

Sidecars

How can my platform insulate workloadsfrom complexity and state of services?

Ambassador

How can my platform communicate witha workload when I want a differentprotocol than it was built with?

Adapter

How can my platform provide “singleton”behaviors in a scaled-out service?

Leader Elector

How can my platform provide “workqueue” behavior without altering aworkload?

Work Queue

Kubernetes Tweet Bait“Could this be POSIX of distributed systems?!”

How does it all come together?

Scalewhale: A troubled serviceThe output we want but we get overloaded

Initial rollout

Brute force scale-out

Metric-driven Autoscale

Swap in a work queue!

Questions

Get hip to the heptagonA platform is a real developer advantage but must avoid reinvention and beingoverly proscriptive.Kubernetes was built to bring independence from hardware choices.Kubernetes also brings separation of concerns to dev teams.It’s built from simple rules and objects that improve the usefulness and portabilityof containers.

Slides available athttps://is.gd/k8splatform

Bibliography“Design Patterns for Container-base Distributed Systems” -- Burns, OppenheimerUSENIX 2016“Site Reliability Engineering” -- Beyer, Jones, Petoff, Murphy. O’Reilly 2016“From Google to the World: The Kubernetes Origin Story” -- McLuckie, 2016

Building a Microservices Platform with Kubernetes Matthew Mark Miller @DataMiller. Cloud Native: Microservices running inside Containers on top of Platforms on any infrastructure. Microservice A software component of a system that is independently releasable and independently scalable from other parts of the