44
Kubernetes & CoreOS Athens Docker Meetup

Kubernetes and CoreOS @ Athens Docker meetup

  • Upload
    mistio

  • View
    1.517

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Kubernetes and CoreOS @ Athens Docker meetup

Kubernetes & CoreOSAthens Docker Meetup

Page 2: Kubernetes and CoreOS @ Athens Docker meetup

1. What is your name?

Chris Loukas

Dimitris Moraitis

Page 3: Kubernetes and CoreOS @ Athens Docker meetup

2. What is your quest?

● Self-healing services

● Auto-scaling

● 1-click deployments/rollbacks

● More vacations

To find the holy grail of DevOps.

Page 4: Kubernetes and CoreOS @ Athens Docker meetup

3. What is your favorite systems

architecture?

It usually goes like this ...

For early or later stage products?

Page 5: Kubernetes and CoreOS @ Athens Docker meetup

Begin with a bunch of monoliths

Page 6: Kubernetes and CoreOS @ Athens Docker meetup

Turn it into a solid stack of reusable components

Page 7: Kubernetes and CoreOS @ Athens Docker meetup

Keep iterating until you end up with mosaics of micro-services

Page 8: Kubernetes and CoreOS @ Athens Docker meetup

Chapter 1the container

A lightweight VM?

A chrooted process?

An application packaging technology?

Page 9: Kubernetes and CoreOS @ Athens Docker meetup

Containers kick ass despite limitations

● Great for dev on a single node.

● Ideal for CI.

● It gets tricky in multi-node

production environments.

● A lot of hacking required to

orchestrate deployments,

rollback, scale, monitor,

migrate.

Page 10: Kubernetes and CoreOS @ Athens Docker meetup

Chapter 2CoreOS

A lightweight Linux distro for clustered

deployments that uses containers to

manage your services at a higher level

of abstraction, instead of installing

packages via yum or apt.

Page 11: Kubernetes and CoreOS @ Athens Docker meetup

etcd● A distributed key-value store that

provides a reliable way to store data

across a cluster of machines.

● Values can be watched, to trigger

app reconfigurations when they

change.

● Odd sized clusters guaranteed to

reach consensus.

● JSON/REST API.

Page 12: Kubernetes and CoreOS @ Athens Docker meetup

flannel● An etcd backed network

fabric for containers.

● A virtual network that

gives a subnet to each

host for use with

container runtimes.

Page 13: Kubernetes and CoreOS @ Athens Docker meetup

fleet● An etcd backed,

distributed init system

(distributed systemd).

● Treat CoreOS cluster as if

it shared an init system.

● Graceful updates of

CoreOS across the cluster.

● Handles machine failures.

fleet

Page 14: Kubernetes and CoreOS @ Athens Docker meetup

rkt● Container runtime by

CoreOS

● rkt is an implementation

of the App Container Spec

● rkt features native support

for fetching and running

Docker container images

Page 15: Kubernetes and CoreOS @ Athens Docker meetup

Chapter 3Kubernetes

Kubernetes is an open source

orchestration system for containers.

Page 16: Kubernetes and CoreOS @ Athens Docker meetup

● kube-apiserver

● kube-scheduler

● kube-controller-manager

● kube-kubelet

● kube-proxy

Master

Nodes

Page 17: Kubernetes and CoreOS @ Athens Docker meetup

Pods● A collocated group of containers

with shared volumes. Always

executed on the same node.

● The smallest deployable units.

● Correspond to a colocated group of

applications running with shared

context.

Page 18: Kubernetes and CoreOS @ Athens Docker meetup

Replication controllers● Ensure that a specific

number of pod replicas are

running at any one time.

● Replace pods that are

deleted or terminated.

● Get rid of excess pods.

Page 19: Kubernetes and CoreOS @ Athens Docker meetup

Labels● Key-value pairs attached to

pods and other resources.

● Specify identifying

properties of resources.

● Sets of objects can be

identified by label selectors

(e.g. version=2).

Page 20: Kubernetes and CoreOS @ Athens Docker meetup

Services● An abstraction that uses a

selector to map an incoming

port to a set of pods.

● Needed to keep stable front-

ends since pods are mortal

and each pod gets its own ip

address.

Page 21: Kubernetes and CoreOS @ Athens Docker meetup

Self-healing● The user declares the

target state e.g. “I need 5

uwsgi & 10 celery servers

active at all times”.

● Kubernetes will re-start,

replicate & re-schedule

containers to ensure that

this is met.

Page 22: Kubernetes and CoreOS @ Athens Docker meetup

Scaling● By increasing or decreasing the

replication factor of each pod,

respective services will scale up

or down.

● Auto-scaling of services

depending on pod CPU

utilization.

● New nodes can be added to

increase cluster capacity.

Page 23: Kubernetes and CoreOS @ Athens Docker meetup

And there was much rejoicing !

Page 24: Kubernetes and CoreOS @ Athens Docker meetup

What’s the catch?

Page 25: Kubernetes and CoreOS @ Athens Docker meetup

High availability of Kubernetes can

be achieved with CoreOS (e.g. fleet),

but not without some serious effort...

High availability of Kubernetes

Page 26: Kubernetes and CoreOS @ Athens Docker meetup

Used to be an issue, promised to be

resolved in Kubernetes v1.1.1

“included option to use native IP

tables offering an 80% reduction in

tail latency, an almost complete

elimination of CPU overhead “

Network performance

Page 27: Kubernetes and CoreOS @ Athens Docker meetup

Stateful services and Kubernetes do

not fit well. There are some “exotic”

ways to solve the problem, but they

are either still in beta or under heavy

development (e.g. flocker)

Stateful services

Page 28: Kubernetes and CoreOS @ Athens Docker meetup

Kubernetes is configured to work out

of the box only for GCE and EC2. In

any other case manual configuration

of load-balancers and external DNS

services is to be expected.

Public Load Balancer

External DNS

Page 29: Kubernetes and CoreOS @ Athens Docker meetup

Kubernetes on top of CoreOS is a

completely new way of doing things...

operation workflows for DevOps

should be heavily adjusted to this new

way of things…

You could end up building your own

tools around Kubernetes...

Operational Management

Page 30: Kubernetes and CoreOS @ Athens Docker meetup

Chapter 4Developing your app

for Kubernetes

Page 31: Kubernetes and CoreOS @ Athens Docker meetup

● One click deployment!

● Replicate as much of the production setup as possible

● Everything pre-configured for the developer (e.g. add-ons)

Goals for the development process:

Our experience so far...

Page 32: Kubernetes and CoreOS @ Athens Docker meetup

-Ended up building our own

internal tools

aka mistctl

everything is ctl nowadays…

does anyone remember tail -f ???

Page 33: Kubernetes and CoreOS @ Athens Docker meetup

+Works locally but not in prod???

Not the case anymore...at least

most of the times

Page 34: Kubernetes and CoreOS @ Athens Docker meetup

Local devwith

Kubernetes in place

● Higher demands on developer’s

laptop power!

● Allows us to get rid of distro specific

dependencies.

● Adds new dependencies: vagrant &

virtualbox.

● Local dev environment is very close

to production.

Page 35: Kubernetes and CoreOS @ Athens Docker meetup

Chapter 5CI

Pre-production workflow

Page 36: Kubernetes and CoreOS @ Athens Docker meetup

CI workflow

Page 37: Kubernetes and CoreOS @ Athens Docker meetup

CI Workflow explanation1. Developer opens a PR against the staging

branch on Github, triggers Jenkins job.

2. Jenkins setups the env runs the tests and

posts the results back to the PR.

3. Reviewer merges to staging branch after

manual code review.

4. Jenkins builds pre-production containers

and pushes them to the registry.

5. Jenkins triggers deploy on pre-production

cluster.

6. Jenkins runs stress tests against pre-

production cluster.

7. Reviewer compares stress test results with

previous results.

...

Page 38: Kubernetes and CoreOS @ Athens Docker meetup

Chapter XDemo

Page 39: Kubernetes and CoreOS @ Athens Docker meetup

Follow along?

cloud-init: goo.gl/mtF5az

Vagrantfile: goo.gl/HBcqh3

kubectl linux: goo.gl/EZUB3k

kubectl OSX: goo.gl/KUJIOI

Page 40: Kubernetes and CoreOS @ Athens Docker meetup

Next steps

Page 41: Kubernetes and CoreOS @ Athens Docker meetup

Monitoring● Locally using cAdvisor, heapster,

influxDB & Grafana.

● Externally using 3rd party

service.

● Enhance Mist.io to monitor

Kubernetes clusters and to

trigger actions based on rules.

Page 42: Kubernetes and CoreOS @ Athens Docker meetup

High Availability● For the cluster services

through fleet: multiple

masters.

● For our own services,

especially the stateful

ones (e.g. MongoDB).

Page 43: Kubernetes and CoreOS @ Athens Docker meetup

Disaster Recovery● Deploy Kubernetes cluster on

another provider or region.

● Deploy our apps on the new

cluster.

● Restore data from latest

backup or perform live

migration, depending on the

type of disaster.

Page 44: Kubernetes and CoreOS @ Athens Docker meetup

Thank you!