48
Kubernetes 101

Kubernetes 101

Embed Size (px)

Citation preview

Page 1: Kubernetes 101

Kubernetes 101

Page 2: Kubernetes 101

whoamiDevOps Engineer @ Spreaker

h"p://twi"er.com/jnardiello

Page 3: Kubernetes 101

What to expect

Page 4: Kubernetes 101

A Kubernetes primer

Page 5: Kubernetes 101

Tips, tricks, sweat and bloodreal life experience bringing k8s to produc5on

Page 6: Kubernetes 101
Page 7: Kubernetes 101

High-load system

Distributed architecture

Our whole infrastructure is on AWS

Page 8: Kubernetes 101

Our pain points

Page 9: Kubernetes 101

Underused machines

Page 10: Kubernetes 101

Autoscaling would take minutes

Page 11: Kubernetes 101

Non-athomic provisioning makes it difficult to roll-out upgrades or migrate services

Page 12: Kubernetes 101

The solu)on: Docker!Perfectly determinis/c, ephemeral, light-

weight

Page 13: Kubernetes 101

Unfortunately containers are just half

of the equa3on

Real costs will emerge as you try to make containers work

together

Page 14: Kubernetes 101

Kubernetes

Page 15: Kubernetes 101

def.

(Opinionated) Orchestra1on framework to organise and deploy container-based

applica1ons

Page 16: Kubernetes 101

Agnos&c sandbox where you provide the desired state of your

services/apps. Kubernetes aims to take care of everything else

Page 17: Kubernetes 101

Disclaimer!

From the outside Kubernetes is a black box

Page 18: Kubernetes 101

But inner mechanisms makes it a complex beast to master

Page 19: Kubernetes 101
Page 20: Kubernetes 101

We got the cookies!a.k.a. features

Page 21: Kubernetes 101

Self-healing servicesHealth checks on your containers,

rescheduling failing jobs

Page 22: Kubernetes 101

Dynamic scalingEnsure current state and scale your pods (but

it's s4ll on you to scale the nodes)

Page 23: Kubernetes 101

Networking and rou/ngRoute traffic to your containers

Page 24: Kubernetes 101

Efficient physical resources usageScheduling containers on physical/vms nodes

according to their effec7ve needs

Page 25: Kubernetes 101

Enough talking

Page 26: Kubernetes 101

Crea%ng a clusterMULTIZONE=1 KUBERNETES_PROVIDER=aws \KUBE_AWS_ZONE=eu-west-1b NON_MASQUERADE_CIDR="172.16.0.0/14" \SERVICE_CLUSTER_IP_RANGE="172.16.0.0/16" DNS_SERVER_IP="172.16.0.10" \MASTER_IP_RANGE="172.17.0.0/24" CLUSTER_IP_RANGE="172.18.0.0/16" \MASTER_SIZE=m3.medium NODE_SIZE=m3.medium NUM_NODES=1 \./cluster/kube-up.sh

Page 28: Kubernetes 101

$ kubectl get nodes

NAME STATUS AGEip-172-20-0-209.eu-west-1.compute.internal Ready 47mip-172-20-0-210.eu-west-1.compute.internal Ready 47mip-172-20-0-211.eu-west-1.compute.internal Ready 47mip-172-20-0-212.eu-west-1.compute.internal Ready 47mip-172-20-0-213.eu-west-1.compute.internal Ready 47m

Page 29: Kubernetes 101

kubectl is your local CLI command center.

You can issue commands to the cluster either by kubectl or directly calling REST APIs exposed by the master

Page 30: Kubernetes 101

We got the nodes, we are ready

Our first container on kubernetes!

Page 31: Kubernetes 101

YAML all the things!

Page 32: Kubernetes 101

PodsA pod is a group of one or more containers. Pods are the smallest

deployable units that can be created and managed in Kubernetes.

Page 33: Kubernetes 101

Replica(on ControllersA replica*on controller ensures that a specified number of pod

“replicas” are running at any one *me

Page 34: Kubernetes 101

DeploymentsPod + Replica-onController

Page 35: Kubernetes 101

apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: dummy-workerspec: replicas: 1 template: metadata: labels: app: dummy-worker spec: containers: - name: dummy-worker image: jnardiello/forever env: - name: SOME_ENV_VAR value: envvarvalue resources: limits: cpu: "256m" memory: "128Mi" requests: cpu: "5m" memory: "8Mi"

Page 36: Kubernetes 101

ServicesA Kubernetes Service is an abstrac0on which defines a logical set

of Pods and a policy by which to access them.

Page 37: Kubernetes 101

kind: Servicemetadata: name: dummy-worker-servicespec: ports: - port: 80· targetPort: 8000 protocol: TCP selector: app: dummy-worker externalIPs: [53.8.3.2]

Page 38: Kubernetes 101

There are different types of servicesNodePorts, proxied by the master

LoadBalancer, crea'ng an actual ELB on AWS

Ingress [beta] - WARNING, do not use

Page 39: Kubernetes 101

Deploy the containerh"ps://asciinema.org/a/7c42c8itmyz3982p6fmo9ecvi

Page 40: Kubernetes 101

Resilient applica,onsh"ps://asciinema.org/a/2bxo51ond7ac4haaguneingmv

Page 41: Kubernetes 101

Kubernetes is truly amazing(for POCs)

Page 42: Kubernetes 101

Ba#le-tested clusterA long way before reaching produc4on ready

There will be blood!

Page 43: Kubernetes 101

Opinionated Logging

Page 44: Kubernetes 101

Opinionated Monitoring

Page 45: Kubernetes 101

Master skynet, then implement your own solu4on

Page 46: Kubernetes 101

Custom metrics-based AutoscalingOpsFactory/Kappa

Page 47: Kubernetes 101

These topics are for another /me(We should probably do Kubernetes102)

Page 48: Kubernetes 101

Ques%ons?@jnardiello