Slide 1

Slide 1 text

Автомасштабирование и управление ресурсами в Kubernetes Дмитрий Столяров И Ленин такой молодой, И юный — Октябрь впереди!

Slide 2

Slide 2 text

Дмитрий Столяров CTO и соучредитель

Slide 3

Slide 3 text

Андрей Климентьев Андрей Сидоров

Slide 4

Slide 4 text

Андрей Климентьев Андрей Половов Андрей Сидоров

Slide 5

Slide 5 text

Антон Климов Андрей Климентьев Андрей Половов Андрей Сидоров

Slide 6

Slide 6 text

flant.ru habr.com/ru/company/flant youtube.com/c/Флант github.com/flant DevOps-профессионалы t.me/flant_ru

Slide 7

Slide 7 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 8

Slide 8 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Повторяемость

Slide 12

Slide 12 text

Повторяемость Изоляция

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

...

Slide 17

Slide 17 text

...

Slide 18

Slide 18 text

...

Slide 19

Slide 19 text

...

Slide 20

Slide 20 text

...

Slide 21

Slide 21 text

...

Slide 22

Slide 22 text

...

Slide 23

Slide 23 text

...

Slide 24

Slide 24 text

...

Slide 25

Slide 25 text

...

Slide 26

Slide 26 text

... Кластер контейнеров

Slide 27

Slide 27 text

... Кластер контейнеров

Slide 28

Slide 28 text

... Кластер контейнеров

Slide 29

Slide 29 text

... 4 Кластер контейнеров Высокоуровневые примитивы

Slide 30

Slide 30 text

... API 4 Кластер контейнеров Высокоуровневые примитивы Декларативное API

Slide 31

Slide 31 text

... API YAML 4 Кластер контейнеров Высокоуровневые примитивы Декларативное API

Slide 32

Slide 32 text

Лучшие практики CI/CD с Docker youtu.be/FVFhqb1CbRc Наш опыт с Kubernetes в небольших проектах youtu.be/CgCLPYJRxbU Лучшие практики CI/CD с Kubernetes и GitLab youtu.be/G3nELxmECd8 Мониторинг и Kubernetes youtu.be/zj6SlzzBRaA Расширяем и дополняем Kubernetes youtu.be/6VHk1R1TNgk youtube.com/c/Флант Подписывайтесь на наш YouTube-канал!

Slide 33

Slide 33 text

... API YAML 4 Кластер контейнеров Высокоуровневые примитивы Декларативное API

Slide 34

Slide 34 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 35

Slide 35 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 36

Slide 36 text

CPU

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

CPU

Slide 39

Slide 39 text

CPU $ htop ==============================

Slide 40

Slide 40 text

CPU $ htop ============================== nginx

Slide 41

Slide 41 text

CPU $ htop ============================== nginx php-fpm

Slide 42

Slide 42 text

CPU $ htop ============================== nginx php-fpm mysql

Slide 43

Slide 43 text

CPU $ htop ============================== nginx php-fpm mysql

Slide 44

Slide 44 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker php-fpm mysql

Slide 45

Slide 45 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker php-fpm mysql

Slide 46

Slide 46 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker mysql

Slide 47

Slide 47 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker mysql 5 71 74 6 205 217 213 209 460

Slide 48

Slide 48 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker mysql 5 71 74 6 205 217 213 209 460

Slide 49

Slide 49 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker 5 71 74 $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 $ htop ============================== mysql 460

Slide 50

Slide 50 text

А что такое Docker?

Slide 51

Slide 51 text

А что такое Docker? контейнер

Slide 52

Slide 52 text

А что такое контейнер?

Slide 53

Slide 53 text

capabilities 2.2 / 1999 А что такое контейнер?

Slide 54

Slide 54 text

capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 А что такое контейнер?

Slide 55

Slide 55 text

capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 А что такое контейнер?

Slide 56

Slide 56 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 А что такое контейнер? overlay2 2015 zfs 2013 btrfs 2013

Slide 57

Slide 57 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 А что такое контейнер? overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 58

Slide 58 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 59

Slide 59 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? docker 2013 overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 60

Slide 60 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? docker 2013 rkt 2014 overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 61

Slide 61 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? docker 2013 rkt 2014 cri-o 2017 overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 62

Slide 62 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? docker 2013 rkt 2014 cri-o 2017 podman 2018 overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 63

Slide 63 text

overlay 2014 capabilities 2.2 / 1999 namespaces 2.6.19 / nov 2006 cgroups 2.6.24 / jan 2008 aufs 2007 kernel А что такое контейнер? docker 2013 rkt 2014 cri-o 2017 podman 2018 overlay2 2015 zfs 2013 btrfs 2013 veth 2007 ipvlan 2014 macvlan 2007

Slide 64

Slide 64 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker 5 71 74 $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 $ htop ============================== mysql 460

Slide 65

Slide 65 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker 5 71 74 $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 $ htop ============================== mysql 460

Slide 66

Slide 66 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker 5 71 74 $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 $ htop ============================== mysql 460 1000

Slide 67

Slide 67 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 1000 150 850 460 5 71 74 6 205 217 213 209 460

Slide 68

Slide 68 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 150 850 460 5 71 74 6 205 217 213 209 460 1000

Slide 69

Slide 69 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 150 850 460 5 71 74 6 205 217 213 209 460 1000 333 333 333

Slide 70

Slide 70 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 333 333 333

Slide 71

Slide 71 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 333 333 333

Slide 72

Slide 72 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 183 333 150 - = 333 333

Slide 73

Slide 73 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 183 333 150 - = 333 333

Slide 74

Slide 74 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 183 333 150 - = 333 91 + 333 91 +

Slide 75

Slide 75 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 183 333 150 - = 333 91 424 + = 333 91 424 + =

Slide 76

Slide 76 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 2 3 5

Slide 77

Slide 77 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 850 460 2 3 5 300 200 500 1000

Slide 78

Slide 78 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 2 3 5 300 200 500

Slide 79

Slide 79 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 200 500 2 3 5 300

Slide 80

Slide 80 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 50 200 150 - = 40 500 460 - = 2 3 5 300

Slide 81

Slide 81 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 50 200 150 - = 300 40 500 460 - = 2 3 5

Slide 82

Slide 82 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 50 200 150 - = 300 40 + 40 500 460 - = 2 3 5 50 +

Slide 83

Slide 83 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 1000 150 850 460 50 200 150 - = 300 40 390 + = 40 500 460 - = 2 3 5 50 +

Slide 84

Slide 84 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3

Slide 85

Slide 85 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3 78 78 78 78 78

Slide 86

Slide 86 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3 6 78 78 78 78 72 78 = -

Slide 87

Slide 87 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3 6 78 78 78 78 72 78 = -

Slide 88

Slide 88 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3 6 96 96 96 96 72 78 = -

Slide 89

Slide 89 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== mysql 5 71 74 460 1000 150 460 50 200 150 - = 300 40 + = 40 500 460 - = 2 5 50 + $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker 6 205 217 213 209 850 390 3 6 96 96 96 96 2.12 2.26 2.21 2.17 100%

Slide 90

Slide 90 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 2 3 5 1000

Slide 91

Slide 91 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 2 3 5 150 390 460 1000

Slide 92

Slide 92 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 2 3 5 150 390 460 1000 6 96 96 96 96 5 71 74 460

Slide 93

Slide 93 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 2 3 5 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100%

Slide 94

Slide 94 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100% 2 3 5

Slide 95

Slide 95 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100% 2 3 5 CFS = Completely Fair Scheduler

Slide 96

Slide 96 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100% 2 3 5 Реквесты

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

nginx mysql php

Slide 100

Slide 100 text

nginx mysql php

Slide 101

Slide 101 text

nginx mysql php

Slide 102

Slide 102 text

15 sec nginx mysql php

Slide 103

Slide 103 text

15 sec nginx mysql php

Slide 104

Slide 104 text

15 sec nginx mysql php

Slide 105

Slide 105 text

nginx mysql php

Slide 106

Slide 106 text

nginx mysql php

Slide 107

Slide 107 text

39 sec nginx mysql php

Slide 108

Slide 108 text

39 sec nginx mysql php

Slide 109

Slide 109 text

39 sec nginx mysql php

Slide 110

Slide 110 text

39 sec nginx mysql php

Slide 111

Slide 111 text

39 sec nginx mysql php

Slide 112

Slide 112 text

39 sec nginx mysql php

Slide 113

Slide 113 text

39 sec nginx mysql php

Slide 114

Slide 114 text

39 sec nginx mysql php

Slide 115

Slide 115 text

39 sec nginx mysql php

Slide 116

Slide 116 text

39 sec nginx mysql php

Slide 117

Slide 117 text

nginx mysql php

Slide 118

Slide 118 text

nginx mysql php

Slide 119

Slide 119 text

nginx mysql php 46 sec

Slide 120

Slide 120 text

nginx mysql php 46 sec

Slide 121

Slide 121 text

nginx mysql php 46 sec

Slide 122

Slide 122 text

nginx mysql php 46 sec

Slide 123

Slide 123 text

nginx mysql php 46 sec

Slide 124

Slide 124 text

nginx mysql php 46 sec

Slide 125

Slide 125 text

nginx mysql php 46 sec

Slide 126

Slide 126 text

nginx mysql php 46 sec

Slide 127

Slide 127 text

nginx mysql php

Slide 128

Slide 128 text

nginx mysql php

Slide 129

Slide 129 text

nginx mysql php

Slide 130

Slide 130 text

nginx mysql php Лимиты

Slide 131

Slide 131 text

nginx mysql php

Slide 132

Slide 132 text

nginx mysql php 46 sec

Slide 133

Slide 133 text

nginx mysql php 46 sec

Slide 134

Slide 134 text

nginx mysql php 46 sec

Slide 135

Slide 135 text

nginx mysql php 46 sec

Slide 136

Slide 136 text

nginx mysql php 46 sec

Slide 137

Slide 137 text

nginx mysql php 46 sec

Slide 138

Slide 138 text

nginx mysql php 46 sec Куплю машину ближе к светофору!

Slide 139

Slide 139 text

nginx mysql php 46 sec Куплю машину поближе к светофору!

Slide 140

Slide 140 text

CPU

Slide 141

Slide 141 text

kernel CPU

Slide 142

Slide 142 text

kernel CPU CFS

Slide 143

Slide 143 text

kernel CPU CFS cgroup

Slide 144

Slide 144 text

kernel CPU CFS cgroup

Slide 145

Slide 145 text

kernel CPU CFS cgroup

Slide 146

Slide 146 text

kernel CPU CFS cgroup quota

Slide 147

Slide 147 text

kernel CPU CFS cgroup quota shares

Slide 148

Slide 148 text

kernel CPU Крутилки CFS cgroup quota shares

Slide 149

Slide 149 text

kernel CPU Крутилки CFS cgroup quota shares Реквест Лимит

Slide 150

Slide 150 text

В чём мерить CPU?

Slide 151

Slide 151 text

в попугаях В чём мерить CPU?

Slide 152

Slide 152 text

в попугаях В чём мерить CPU? в процентах

Slide 153

Slide 153 text

в попугаях в процентах В чём мерить CPU? в весе

Slide 154

Slide 154 text

в попугаях в весе в процентах В чём мерить CPU? в секундах

Slide 155

Slide 155 text

в секундах в попугаях в весе в процентах В чём мерить CPU? в ядрах! N

Slide 156

Slide 156 text

? N

Slide 157

Slide 157 text

? N

Slide 158

Slide 158 text

? N

Slide 159

Slide 159 text

? N

Slide 160

Slide 160 text

? N

Slide 161

Slide 161 text

? N

Slide 162

Slide 162 text

? N 500

Slide 163

Slide 163 text

? N 500 1000

Slide 164

Slide 164 text

? N 500 1000 1500

Slide 165

Slide 165 text

? N 500 1000 1500 ? ? ?

Slide 166

Slide 166 text

? N 500 1000 1500 ? ? ?

Slide 167

Slide 167 text

? N 1000 1500 ? ? ? 500

Slide 168

Slide 168 text

? N 1000 1500 ? ? ? 500 ( )

Slide 169

Slide 169 text

? N ? ? ? 500 ( ) 1000 1500

Slide 170

Slide 170 text

? N ? ? 1000 1500 ? 500 3000

Slide 171

Slide 171 text

? N ? 1000 1500 ? ? 500 3000

Slide 172

Slide 172 text

? N ? 1000 1500 ? ? 500 3000 3 x

Slide 173

Slide 173 text

? N ? 1000 1500 ? 0.5 500 3000 3 x

Slide 174

Slide 174 text

? N ? 1000 1500 ? 0.5 500

Slide 175

Slide 175 text

? N ? 1000 1500 ? 0.5 500

Slide 176

Slide 176 text

? N 1.5 1000 1500 1 0.5 500

Slide 177

Slide 177 text

? N 1.5 1000 1500 1 0.5 500

Slide 178

Slide 178 text

? N 1.5 1000 1500 1 0.5 500 ? 1500 ? 500 1000 ?

Slide 179

Slide 179 text

? N 1000 1500 500 ? 1500 ? 500 1.5 1 0.5 1000 ?

Slide 180

Slide 180 text

? N 1000 1500 500 3 1500 1 500 1.5 1 0.5 1000 2

Slide 181

Slide 181 text

? N 1000 1500 500 1.5 1 0.5 3 1500 1 500 1000 2

Slide 182

Slide 182 text

? N 1000 1500 500 1.5 1 0.5 3 1000 1500 2 1 500 3000 ?

Slide 183

Slide 183 text

? N 1000 1500 500 1.5 1 0.5 3 1000 1500 2 1 500 3000 3

Slide 184

Slide 184 text

? N 1000 1500 500 1.5 1 0.5 3 1000 1500 2 1 500 3000 3

Slide 185

Slide 185 text

? N 1000 1500 500 1.5 1 0.5 1.5 1000 1500 1 0.5 500 3000 3

Slide 186

Slide 186 text

? N 1000 1500 500 1.5 1000 1500 1 0.5 500 1.5 1 0.5 3000 3

Slide 187

Slide 187 text

? N 1 миллиядро = 1 cpu share* *0 миллиядер = 2 cpu share *На самом деле 1000 миллиядер = 1024 cpu shares

Slide 188

Slide 188 text

No content

Slide 189

Slide 189 text

No content

Slide 190

Slide 190 text

allocatable: cpu: "8"

Slide 191

Slide 191 text

allocatable: cpu: "8"

Slide 192

Slide 192 text

allocatable: cpu: "8"

Slide 193

Slide 193 text

allocatable: cpu: "8"

Slide 194

Slide 194 text

allocatable: cpu: "8"

Slide 195

Slide 195 text

allocatable: cpu: "4" allocatable: cpu: "8"

Slide 196

Slide 196 text

allocatable: cpu: "4" allocatable: cpu: "8"

Slide 197

Slide 197 text

allocatable: cpu: "4" allocatable: cpu: "6" allocatable: cpu: "8"

Slide 198

Slide 198 text

allocatable: cpu: "4" allocatable: cpu: "6" allocatable: cpu: "8"

Slide 199

Slide 199 text

No content

Slide 200

Slide 200 text

No content

Slide 201

Slide 201 text

cpu: 2500m

Slide 202

Slide 202 text

cpu: 2500m

Slide 203

Slide 203 text

cpu: 2500m

Slide 204

Slide 204 text

cpu: 2500m

Slide 205

Slide 205 text

А что если мы не указали никакой request?

Slide 206

Slide 206 text

100% ресурсов

Slide 207

Slide 207 text

Request = Limit Request = Limit Guaranteed

Slide 208

Slide 208 text

Request = 100m Limit = 200m Request = Limit Request = Limit Burstable Guaranteed

Slide 209

Slide 209 text

Request = 100m Limit = 200m Request = Limit Request = Limit Burstable Guaranteed

Slide 210

Slide 210 text

Request = 100m Limit = 200m Limit = 200m Request = 100m Request = 100m Limit = 200m Limit = 200m Request = 100m Request = Limit Request = Limit Burstable Guaranteed

Slide 211

Slide 211 text

Request = 100m Limit = 200m Limit = 200m Request = 100m Request = 100m Limit = 200m Limit = 200m Request = 100m Request = Limit Request = Limit Burstable Best Effort Guaranteed

Slide 212

Slide 212 text

No content

Slide 213

Slide 213 text

Memory

Slide 214

Slide 214 text

kernel CPU Крутилки CFS cgroup quota shares Реквест Лимит

Slide 215

Slide 215 text

kernel CPU CFS cgroup quota shares Реквест Лимит

Slide 216

Slide 216 text

kernel CPU CFS cgroup quota shares kernel Memory mm subsystem cgroup limit_in_bytes oom_score_adj Реквест Лимит Реквест Лимит

Slide 217

Slide 217 text

kernel CPU cgroup quota shares kernel Memory cgroup limit_in_bytes oom_score_adj Реквест Лимит Реквест Лимит CFS mm subsystem

Slide 218

Slide 218 text

kernel Memory Крутилки mm subsystem cgroup limit_in_bytes oom_score_adj Реквест Лимит

Slide 219

Slide 219 text

kernel Memory Крутилки mm subsystem cgroup limit_in_bytes oom_score_adj Реквест Лимит

Slide 220

Slide 220 text

No content

Slide 221

Slide 221 text

No content

Slide 222

Slide 222 text

No content

Slide 223

Slide 223 text

No content

Slide 224

Slide 224 text

No content

Slide 225

Slide 225 text

No content

Slide 226

Slide 226 text

No content

Slide 227

Slide 227 text

No content

Slide 228

Slide 228 text

No content

Slide 229

Slide 229 text

No content

Slide 230

Slide 230 text

No content

Slide 231

Slide 231 text

No content

Slide 232

Slide 232 text

No content

Slide 233

Slide 233 text

No content

Slide 234

Slide 234 text

No content

Slide 235

Slide 235 text

No content

Slide 236

Slide 236 text

No content

Slide 237

Slide 237 text

А как же вычисляется oom_score_adj?

Slide 238

Slide 238 text

Request = 100m Limit = 200m Limit = 200m Request = 100m Request = 100m Limit = 200m Limit = 200m Request = 100m Request = Limit Request = Limit Burstable Best Effort Guaranteed

Slide 239

Slide 239 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class

Slide 240

Slide 240 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class oom_score_adj

Slide 241

Slide 241 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class oom_score_adj -998

Slide 242

Slide 242 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class oom_score_adj -998 1000

Slide 243

Slide 243 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class oom_score_adj -998 min(max(2, 1000 - (1000*memoryRequestBytes)/ machineMemoryCapacityBytes), 999) 1000

Slide 244

Slide 244 text

Burstable Best Effort Guaranteed Request = Limit Request = 100m Limit = 200m QoS Class oom_score_adj -998 min(max(2, 1000 - (1000*memoryRequestBytes)/ machineMemoryCapacityBytes), 999) 1000 Обратно пропорционально request ÷ capacity

Slide 245

Slide 245 text

Реквест Лимит kernel Memory mm subsystem cgroup limit_in_bytes oom_score_adj Крутилки

Slide 246

Slide 246 text

Реквест Лимит kernel Memory mm subsystem cgroup limit_in_bytes oom_score_adj Крутилки

Slide 247

Slide 247 text

No content

Slide 248

Slide 248 text

No content

Slide 249

Slide 249 text

No content

Slide 250

Slide 250 text

No content

Slide 251

Slide 251 text

No content

Slide 252

Slide 252 text

No content

Slide 253

Slide 253 text

No content

Slide 254

Slide 254 text

No content

Slide 255

Slide 255 text

No content

Slide 256

Slide 256 text

No content

Slide 257

Slide 257 text

No content

Slide 258

Slide 258 text

No content

Slide 259

Slide 259 text

Итого...

Slide 260

Slide 260 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 261

Slide 261 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 262

Slide 262 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 263

Slide 263 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 264

Slide 264 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 265

Slide 265 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 266

Slide 266 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 267

Slide 267 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 268

Slide 268 text

requests: cpu: 250m memory: 5G limits: cpu: 500m memory: 10G

Slide 269

Slide 269 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 270

Slide 270 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 271

Slide 271 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 272

Slide 272 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 273

Slide 273 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 274

Slide 274 text

Автомасштабирование и управление ресурсами в Kubernetes

Slide 275

Slide 275 text

No content

Slide 276

Slide 276 text

No content

Slide 277

Slide 277 text

No content

Slide 278

Slide 278 text

cpu: 2500m

Slide 279

Slide 279 text

cpu: 2500m Pending...

Slide 280

Slide 280 text

cpu: 2500m Pending...

Slide 281

Slide 281 text

allocatable: cpu: "8" cpu: 2500m Pending...

Slide 282

Slide 282 text

cpu: 2500m Pending...

Slide 283

Slide 283 text

cpu: 2500m Pending...

Slide 284

Slide 284 text

No content

Slide 285

Slide 285 text

No content

Slide 286

Slide 286 text

(Авто)масштабирование кластера

Slide 287

Slide 287 text

No content

Slide 288

Slide 288 text

No content

Slide 289

Slide 289 text

No content

Slide 290

Slide 290 text

No content

Slide 291

Slide 291 text

No content

Slide 292

Slide 292 text

No content

Slide 293

Slide 293 text

No content

Slide 294

Slide 294 text

No content

Slide 295

Slide 295 text

No content

Slide 296

Slide 296 text

No content

Slide 297

Slide 297 text

No content

Slide 298

Slide 298 text

No content

Slide 299

Slide 299 text

No content

Slide 300

Slide 300 text

Но...

Slide 301

Slide 301 text

No content

Slide 302

Slide 302 text

Нельзя так просто взять и...

Slide 303

Slide 303 text

No content

Slide 304

Slide 304 text

No content

Slide 305

Slide 305 text

No content

Slide 306

Slide 306 text

Deployment 6

Slide 307

Slide 307 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms 6 app-d38nl app-vq1g5

Slide 308

Slide 308 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms 6 app-d38nl app-vq1g5

Slide 309

Slide 309 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green 6 app-d38nl app-vq1g5

Slide 310

Slide 310 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green 6 app-d38nl app-vq1g5

Slide 311

Slide 311 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green 6 app-d38nl app-vq1g5

Slide 312

Slide 312 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green app-d38nl app-vq1g5 6

Slide 313

Slide 313 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green app-d38nl app-vq1g5 6

Slide 314

Slide 314 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green app-heb0y app-my9sq 6

Slide 315

Slide 315 text

app-59ptg app-xfvr7 app-ck9cm Deployment app-4ktms $ kubectl drain node-green app-heb0y app-my9sq 6

Slide 316

Slide 316 text

No content

Slide 317

Slide 317 text

No content

Slide 318

Slide 318 text

Statefulset 3

Slide 319

Slide 319 text

Statefulset 3 mongo-1 mongo-3 mongo-2

Slide 320

Slide 320 text

Statefulset 3 mongo-1 mongo-3 mongo-2

Slide 321

Slide 321 text

Statefulset 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff

Slide 322

Slide 322 text

Statefulset 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff

Slide 323

Slide 323 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff

Slide 324

Slide 324 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff

Slide 325

Slide 325 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff

Slide 326

Slide 326 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 mongo-2 CrashLoopBackOff PodDisruptionBudget minAvailable: 2

Slide 327

Slide 327 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2 CrashLoopBackOff

Slide 328

Slide 328 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2 CrashLoopBackOff

Slide 329

Slide 329 text

Statefulset $ kubectl drain node-green 3 CrashLoopBackOff mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2

Slide 330

Slide 330 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2 CrashLoopBackOff

Slide 331

Slide 331 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2 CrashLoopBackOff

Slide 332

Slide 332 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2

Slide 333

Slide 333 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2

Slide 334

Slide 334 text

Statefulset $ kubectl drain node-green 3 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2 mongo-2

Slide 335

Slide 335 text

Statefulset $ kubectl drain node-green 3 mongo-2 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2

Slide 336

Slide 336 text

Statefulset $ kubectl drain node-green 3 mongo-2 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2

Slide 337

Slide 337 text

Statefulset $ kubectl drain node-green $ kubectl uncordon node-green 3 mongo-2 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2

Slide 338

Slide 338 text

Statefulset $ kubectl drain node-green $ kubectl uncordon node-green 3 mongo-2 mongo-1 mongo-3 PodDisruptionBudget minAvailable: 2

Slide 339

Slide 339 text

No content

Slide 340

Slide 340 text

1. Пересоздание

Slide 341

Slide 341 text

1. Пересоздание 2. PodDisruptionBudget

Slide 342

Slide 342 text

... 3-10 backend

Slide 343

Slide 343 text

... 3-10 backend stateful

Slide 344

Slide 344 text

... 3-10 backend stateful frontend

Slide 345

Slide 345 text

... dev ... 3-10 backend stateful frontend 5-20

Slide 346

Slide 346 text

... dev ... 0-30 test ... 3-10 backend stateful frontend 5-20

Slide 347

Slide 347 text

... dev ... 0-30 test ... 3-10 backend stateful frontend 5-20

Slide 348

Slide 348 text

(Авто)масштабирование кластера

Slide 349

Slide 349 text

No content

Slide 350

Slide 350 text

No content

Slide 351

Slide 351 text

3

Slide 352

Slide 352 text

3

Slide 353

Slide 353 text

3

Slide 354

Slide 354 text

3

Slide 355

Slide 355 text

3

Slide 356

Slide 356 text

3

Slide 357

Slide 357 text

3

Slide 358

Slide 358 text

3

Slide 359

Slide 359 text

3

Slide 360

Slide 360 text

3 Ручное масштабирование?

Slide 361

Slide 361 text

3 Ручное масштабирование?

Slide 362

Slide 362 text

3

Slide 363

Slide 363 text

3

Slide 364

Slide 364 text

3

Slide 365

Slide 365 text

3

Slide 366

Slide 366 text

3

Slide 367

Slide 367 text

6

Slide 368

Slide 368 text

6

Slide 369

Slide 369 text

6

Slide 370

Slide 370 text

6

Slide 371

Slide 371 text

6

Slide 372

Slide 372 text

6

Slide 373

Slide 373 text

6

Slide 374

Slide 374 text

6

Slide 375

Slide 375 text

6

Slide 376

Slide 376 text

6

Slide 377

Slide 377 text

6

Slide 378

Slide 378 text

3

Slide 379

Slide 379 text

3

Slide 380

Slide 380 text

3

Slide 381

Slide 381 text

3

Slide 382

Slide 382 text

3

Slide 383

Slide 383 text

3 Горизонтальное (авто) масштабирование

Slide 384

Slide 384 text

Что именно измерять?

Slide 385

Slide 385 text

Что именно измерять? Как интерпретировать полученные значения?

Slide 386

Slide 386 text

CPU Usage CPU Throttling Memory Usage OOM Системные RPS Connections Worker Pool Usage Уровня приложения Queue Length Response Time

Slide 387

Slide 387 text

USE Utilization – потребление Saturation – пресыщение Errors – ошибки

Slide 388

Slide 388 text

(Авто)масштабирование кластера Горизонтальное (авто)масштабирование

Slide 389

Slide 389 text

3

Slide 390

Slide 390 text

3

Slide 391

Slide 391 text

3

Slide 392

Slide 392 text

requests: cpu: 500m 3

Slide 393

Slide 393 text

3 requests: cpu: 500m

Slide 394

Slide 394 text

3 requests: cpu: 500m

Slide 395

Slide 395 text

3 requests: cpu: 500m

Slide 396

Slide 396 text

3 requests: cpu: 1000m

Slide 397

Slide 397 text

requests: cpu: 1000m 3

Slide 398

Slide 398 text

requests: cpu: 1000m 3

Slide 399

Slide 399 text

requests: cpu: 1000m 3

Slide 400

Slide 400 text

requests: cpu: 1000m 3

Slide 401

Slide 401 text

requests: cpu: 1000m 3

Slide 402

Slide 402 text

requests: cpu: 1000m 3

Slide 403

Slide 403 text

requests: cpu: 1000m 3

Slide 404

Slide 404 text

requests: cpu: 1000m 3

Slide 405

Slide 405 text

6 3 requests: cpu: 1000m Вертикальное (авто) масштабирование

Slide 406

Slide 406 text

(Авто)масштабирование кластера Горизонтальное (авто)масштабирование Вертикальное (авто)масштабирование

Slide 407

Slide 407 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100% 2 3 5

Slide 408

Slide 408 text

CPU $ htop ============================== nginx: master nginx: worker nginx: worker $ htop ============================== php-fpm: master php-fpm: worker php-fpm: worker php-fpm: worker php-fpm: worker $ htop ============================== mysql 5 71 74 6 205 217 213 209 460 150 390 460 1000 6 96 96 96 96 2.12 2.26 2.21 2.17 100% 5 71 74 460 100% 100% 100% 100% 2 3 5

Slide 409

Slide 409 text

(Авто)масштабирование кластера Горизонтальное (авто)масштабирование Вертикальное (авто)масштабирование

Slide 410

Slide 410 text

6 3

Slide 411

Slide 411 text

6 3

Slide 412

Slide 412 text

6 3

Slide 413

Slide 413 text

6 3 requests: cpu: 1000m

Slide 414

Slide 414 text

6 3 requests: cpu: 1000m

Slide 415

Slide 415 text

6 3 requests: cpu: 1000m

Slide 416

Slide 416 text

6 3 requests: cpu: 1000m

Slide 417

Slide 417 text

6 3 requests: cpu: 500m

Slide 418

Slide 418 text

6 3 requests: cpu: 500m

Slide 419

Slide 419 text

6 3 requests: cpu: 500m

Slide 420

Slide 420 text

6 3 requests: cpu: 500m

Slide 421

Slide 421 text

6 3 requests: cpu: 500m

Slide 422

Slide 422 text

6 3 requests: cpu: 500m

Slide 423

Slide 423 text

6 3 requests: cpu: 500m

Slide 424

Slide 424 text

6 5 requests: cpu: 500m

Slide 425

Slide 425 text

6 5 requests: cpu: 500m

Slide 426

Slide 426 text

6 5 requests: cpu: 500m

Slide 427

Slide 427 text

(Авто)масштабирование кластера Горизонтальное (авто)масштабирование Вертикальное (авто)масштабирование

Slide 428

Slide 428 text

No content

Slide 429

Slide 429 text

max(utilisation) при min(saturation)

Slide 430

Slide 430 text

Спасибо! Наш блог на Хабре habr.com/company/flant Наш YouTube-канал youtube.com/c/Флант shell-operator github.com/flant/shell-operator addon-operator github.com/flant/addon-operator werf github.com/flant/werf grafana-statusmap github.com/flant/grafana-statusmap kubedog github.com/flant/kubedog Дмитрий Столяров dmitry.stolyarov@flant.com CTO и соучредитель