74
@stillinbeta // #SREcon Americas 2019 While you’re waiting... http://bit.ly/srecon-cake0

While you’re waiting - USENIX

  • Upload
    others

  • View
    18

  • Download
    0

Embed Size (px)

Citation preview

Page 1: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

While you’re waiting... http://bit.ly/srecon-cake0

Page 2: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes FromA Cake Mix

Liz Frost

Page 3: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Who am I?

Liz Frost

Twitter: @stillinbeta

slack.k8s.io: @liz

Page 4: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Who am I?

Page 5: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Who am I?

Page 6: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Who am I?

It’s pronounced “kube-cuddle”

Page 7: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Why should you listen to me?

● sig-cluster-lifecycle member

● kubernetes contributor

● kubeadm developer

Page 8: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

What is Kubernetes?

Page 9: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Page 10: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Page 11: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Page 12: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Node

Pod Pod Pod

Node

Pod Pod Pod User

Page 13: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Node

Pod Pod Pod

Node

Pod Pod Pod User

Page 14: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes APIUser

Page 15: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes APIConformance Tests

Page 16: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes APIConformance Tests

Page 17: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes APIConformance Tests

Page 18: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes APIConformance Tests

Page 19: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubernetes API A wizard did itConformance Tests

Page 20: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

We got Opinions

Page 21: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubeadm™ brand Kubernetes

Page 22: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubeadm init

Page 23: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

$ kubeadm init --helpRun this command in order to set up the Kubernetes master.

The "init" command executes the following phases:```preflight Run master pre-flight checkskubelet-start Writes kubelet settings and (re)starts the kubeletcerts Certificate generation /etcd-ca Generates the self-signed CA to provision identities for etcd /etcd-server Generates the certificate for serving etcd /etcd-healthcheck-client Generates the client certificate for liveness probes to healtcheck etcd /apiserver-etcd-client Generates the client apiserver uses to access etcd /etcd-peer Generates the credentials for etcd nodes to communicate with each other /ca Generates the self-signed Kubernetes CA to provision identities for other Kubernetes components /apiserver Generates the certificate for serving the Kubernetes API /apiserver-kubelet-client Generates the Client certificate for the API server to connect to kubelet /front-proxy-ca Generates the self-signed CA to provision identities for front proxy /front-proxy-client Generates the client for the front proxy /sa Generates a private key for signing service account tokens along with its public keykubeconfig Generates all kubeconfig files necessary to establish the control plane and the admin kubeconfig file /admin Generates a kubeconfig file for the admin to use and for kubeadm itself /kubelet Generates a kubeconfig file for the kubelet to use *only* for cluster bootstrapping purposes /controller-manager Generates a kubeconfig file for the controller manager to use /scheduler Generates a kubeconfig file for the scheduler to usecontrol-plane Generates all static Pod manifest files necessary to establish the control plane /apiserver Generates the kube-apiserver static Pod manifest /controller-manager Generates the kube-controller-manager static Pod manifest /scheduler Generates the kube-scheduler static Pod manifestetcd Generates static Pod manifest file for local etcd. /local Generates the static Pod manifest file for a local, single-node local etcd instance.upload-config Uploads the kubeadm and kubelet configuration to a ConfigMap /kubeadm Uploads the kubeadm ClusterConfiguration to a ConfigMap /kubelet Uploads the kubelet component config to a ConfigMapmark-control-plane Mark a node as a control-planebootstrap-token Generates bootstrap tokens used to join a node to a clusteraddon Installs required addons for passing Conformance tests /coredns Installs the CoreDNS addon to a Kubernetes cluster /kube-proxy Installs the kube-proxy addon to a Kubernetes cluster

Page 24: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

$ kubeadm init --helpRun this command in order to set up the Kubernetes master.

The "init" command executes the following phases:```preflight Run master pre-flight checkskubelet-start Writes kubelet settings and (re)starts the kubeletcerts Certificate generationkubeconfig Generates all kubeconfig files necessarycontrol-plane Generates all static Pod manifest files necessary to establish the /apiserver Generates the kube-apiserver static Pod manifest /controller-manager Generates the kube-controller-manager static Pod manifest /scheduler Generates the kube-scheduler static Pod manifestetcd Generates static Pod manifest file for local etcd. /local Generates the static Pod manifest file for a local etcd instance.upload-config Uploads the kubeadm and kubelet configuration to a ConfigMap /kubeadm Uploads the kubeadm ClusterConfiguration to a ConfigMap /kubelet Uploads the kubelet component config to a ConfigMapmark-control-plane Mark a node as a control-planebootstrap-token Generates bootstrap tokens used to join a node to a clusteraddon Installs required addons for passing Conformance tests /coredns Installs the CoreDNS addon to a Kubernetes cluster /kube-proxy Installs the kube-proxy addon to a Kubernetes cluster

Page 25: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

preflightkubelet-startcertskubeconfigcontrol-plane /apiserver /controller-manager /scheduleretcd /localupload-config /kubeadm /kubeletmark-control-planebootstrap-tokenaddon /coredns /kube-proxy

Page 26: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

What are we making?

● kubelet

● etcd

● kube-apiserver

● kube-contoller-manager

● kube-scheduler

Page 27: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

master

kubelet

etcd kube-apiserver

kube-scheduler

kube-controller-manager

docker process

container

Node (VM / physical

Machine)

https

IPC

Page 28: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubelet

etcd

docker

kube-apiserver

kube-scheduler

kube-controller-manager

process

container

Node (VM / physical

Machine)

Page 29: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubelet

etcd

docker

kube-apiserver

kube-scheduler

kube-controller-manager

process

Kubernetespod

Node (VM / physical

Machine)

Page 30: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubelet

etcd

docker

kube-apiserver

kube-scheduler

kube-controller-manager

process

container

Node (VM / physical

Machine)

Page 31: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubelet

Page 32: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

What will we need locally?

● kubelet

● kubeadm

● docker

Page 33: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubelet connects to API server...

...but the API server is run by the kubelet

Page 34: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Page 35: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubelet boot

Start static podsTry to connect to

API server

Page 36: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubelet boot

Start static podsTry to connect to

API server

Page 37: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Kubelet boot

Start static pods

Page 38: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 1! http://bit.ly/srecon-cake1

Page 39: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubeadm

Page 40: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubeadm

REMOVE BEFORE FLIGHT

Page 41: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Preflight Checks

● Avoid common problems

● Handy guard-rails

● Ignore at your own peril!

Page 42: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 2! http://bit.ly/srecon-cake2

Page 43: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Page 44: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

From the Website

● Simple: well-defined, user-facing API (gRPC)

● Secure: automatic TLS with optional client cert authentication

● Fast: benchmarked 10,000 writes/sec

● Reliable: properly distributed using Raft

Page 45: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

What you care about

● Key/value store

● Optionally distributed

● Only stateful part of kubernetes

● Secured by client certificates

Page 46: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Where do we put it?

● External?

● HA?

● Self-Hosted

● Single Node

Page 47: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Setting up etcd

Generate Certificates Create Pod Manifest Run Healthcheck

Page 48: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 3! http://bit.ly/srecon-cake3

Page 49: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

apiserver

Page 50: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

master

kubelet

etcd kube-apiserver

kube-scheduler

kube-controller-manager

docker process

container

Node (VM / physical

Machine)

https

IPC

User

Page 51: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

The centre of everything

Page 52: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kube-apiserver

Page 53: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kube-apiserver

● Exclusive control of etcd

● Handles all access control

● Stores some (but not all!) APIs

● Proxies everything

Page 54: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

API Groups?

GET /apis/apps/v1/namespaces/default/deployments/myapp

API Group API Version Namespace ResourceResource

Name

Page 55: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Custom Resource Definitions

API Request

MyCRD Watch NotificationMyCRD Response

User (kubectl, curl) kube-apiserver CRD controller

Page 56: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kubectl exec

Command

Command

Command output

User (kubectl, curl) kube-apiserver Running Pod

Command Output

Page 57: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 4! http://bit.ly/srecon-cake4

Page 58: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kube-controller-manager

Page 59: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

...that could mean anything

Page 60: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Controller

State Changes

Desired State

Reactions

Page 61: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

ReplicaSetController

Pod Created / Destroyed

List of ReplicaSets

Create / Destroy Pods

Page 62: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

NodeController

Node Health Changes

List of Pods

Destroy Pods

Page 63: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kube-controller-manager

Controller goroutineController

goroutineController goroutineController

goroutineController goroutine

Controller goroutineController

goroutineController goroutineController

goroutineController goroutine

Controller goroutineController

goroutineController goroutineController

goroutineController goroutine

Controller goroutineController

goroutineController goroutineController

goroutineController goroutine

Page 64: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 5! http://bit.ly/srecon-cake5

Page 65: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Scheduler

Page 66: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

kube-schedulerPods Nodes

Assignm

ents

Page 67: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

I need a GPU

I’m out of disk

I’m running Solaris

I’m in Europe

I can’t be on Node17

I want to be in us-east-1c

Page 68: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

I prefer Europe

I prefer not to run on the same node as pod17

Page 69: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Bin Packing

Page 70: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Tutorial 6! http://bit.ly/srecon-cake6

Page 71: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

What would be next?

● DNS

● Container Networking

● Proxying

● Multiple Nodes

Page 72: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

Your Cluster is Not:

● Secure

● Production-Ready

● Resilient

● High-Availability

● Certified Kubernetes

Page 73: While you’re waiting - USENIX

@stillinbeta // #SREcon Americas 2019

But it is yours.

Page 74: While you’re waiting - USENIX

@stillinbeta / #Kubecon Seattle 2018

Questions? Concerns?

Come find me! I’m the one with pink hair!

Twitter: @stillinbeta

slack.k8s.io: @liz

Github: github.com/stillinbeta