Continuous Delivery the hard way with Kubernetes Luke Marsden, - - PowerPoint PPT Presentation

continuous delivery the hard way with kubernetes
SMART_READER_LITE
LIVE PREVIEW

Continuous Delivery the hard way with Kubernetes Luke Marsden, - - PowerPoint PPT Presentation

Continuous Delivery the hard way with Kubernetes Luke Marsden, Developer Experience @lmarsden Agenda 1. Why should I deliver continuously? 2. Kubernetes primer 3. GitLab primer 4. OK, so weve got these pieces, how are we going to put


slide-1
SLIDE 1

Continuous Delivery the hard way with Kubernetes

Luke Marsden, Developer Experience @lmarsden

slide-2
SLIDE 2

Agenda

  • 1. Why should I deliver continuously?
  • 2. Kubernetes primer
  • 3. GitLab primer
  • 4. “OK, so we’ve got these pieces, how are we

going to put them together?”

  • 5. Let’s iterate on a design!
  • 6. Conclusions
slide-3
SLIDE 3

Agenda

  • 1. Why should I deliver continuously?
  • 2. Kubernetes primer
  • 3. GitLab primer
  • 4. “OK, so we’ve got these pieces, how are we

going to put them together?”

  • 5. Let’s iterate on a design!
  • 6. Conclusions
slide-4
SLIDE 4

Why should I continuously deliver?

  • Microservices
  • Conway’s law
  • Scaling project, scaling team
  • Velocity!
slide-5
SLIDE 5

Kubernetes: all you need to know

Pods

containers

Services

Deployments

Container Image Docker container image, contains your application code in an isolated environment. Pod A set of containers, sharing network namespace and local volumes, co-scheduled on one machine. Mortal. Has pod IP. Has labels. Deployment Specify how many replicas of a pod should run in a cluster. Then ensures that many are running across the cluster. Has labels. Service Names things in DNS. Gets virtual IP. Two types: ClusterIP for internal services, NodePort for publishing to outside. Routes based on labels.

slide-6
SLIDE 6

GitLab primer

  • Or you can use GitHub, Travis, Circle,

Docker Hub, Quay.io, GCR…

CI system Docker registry GitLab Version controlled code Version controlled code

slide-7
SLIDE 7

Version controlled code

These are the things that we’ve got

Version controlled code CI system Docker registry Kubernetes cluster Code Docker image Kubernetes YAML

slide-8
SLIDE 8

Version controlled code

These are the things that we’ve got

Version controlled code CI system Docker registry Kubernetes cluster Code Docker image Kubernetes YAML git git + shell docker registry API kubernetes API

slide-9
SLIDE 9

These are the things that we’ve got

Version controlled code CI system Docker registry Kubernetes cluster Code Docker image Kubernetes YAML

slide-10
SLIDE 10

V1 Initial deploy (manually)

slide-11
SLIDE 11

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster

slide-12
SLIDE 12

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster kubectl apply -f service.yaml

slide-13
SLIDE 13

V1 Deploy update (with CI system)

slide-14
SLIDE 14

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster Code Docker image

slide-15
SLIDE 15

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster git push

master

slide-16
SLIDE 16

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster docker build

:a1b2c3

slide-17
SLIDE 17

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster docker push

:a1b2c3

slide-18
SLIDE 18

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster kubectl set image

:a1b2c3

slide-19
SLIDE 19

V1 Rollback

slide-20
SLIDE 20

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster

slide-21
SLIDE 21

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster git checkout master git revert HEAD
 git push

slide-22
SLIDE 22

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster docker build

:b2c3d4

slide-23
SLIDE 23

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster docker push

:b2c3d4

slide-24
SLIDE 24

Version controlled code

V1 architecture

Version controlled code CI system Docker registry Kubernetes cluster kubectl set image

:b2c3d4

slide-25
SLIDE 25

Demo!

slide-26
SLIDE 26

Downsides

  • Building & pushing containers is slow (disk I/O,

network), shouldn’t need to this when rolling back

  • Branch per environment required per microservice

(explosion of branches, hard to manage & scale)

  • Only a matter of time until you get a git merge mess
  • Better to decouple version of code at HEAD from

version deployed…

slide-27
SLIDE 27

Version controlled configuration

  • users service
  • code for users service
  • Kubernetes YAML
  • orders service
  • code for orders

service

  • Kubernetes YAML
  • config repo
  • Kubernetes YAML

for users

  • Kubernetes YAML

for orders

  • Version controlled config should be the source of truth for your whole

app (all the microservices)

slide-28
SLIDE 28

V2 Put all the yamels in one place

slide-29
SLIDE 29

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-30
SLIDE 30

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-31
SLIDE 31

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-32
SLIDE 32

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-33
SLIDE 33

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-34
SLIDE 34

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-35
SLIDE 35

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-36
SLIDE 36

Version controlled code

V2 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Code Docker image Kubernetes YAML Have the CI system update the yamels automatically for you

slide-37
SLIDE 37

Now you can recreate your production environment from the central YAML repository even if your entire production cluster gets deleted

slide-38
SLIDE 38

Demo!

slide-39
SLIDE 39

Downsides

  • The CI system is responsible for a lot now (design smell – overloaded)
  • You can only trigger the CI system by pushing code (we wanted to be able

to rollback without pushing code)

  • If you rollback out of band (directly with kubectl), you have to

remember to update the central configuration repo as well

  • Parallel builds can tread on eachothers’ toes, not atomic: race between git

checkout and git push (need a global lock)

  • Scripting updates of yamels can be a pain… it mangles your yamels
  • Developers start asking for more release management features (rollback,

pinning, automation for some envs and manual gating for others, and your

  • nce-simple script keeps growing…)
slide-40
SLIDE 40

Decoupling versions from releases

Code versions (branches, tags) Environments & releases

  • users service
  • master
  • feature_A
  • feature_B
  • orders service
  • master
  • feature_A
  • feature_B
  • production
  • users -> master @ t1
  • orders -> master @ t1
  • staging
  • orders -> master @ t2
  • orders -> master @ t2

conflating per- service code branches with environments in each repo is a hack, and doesn’t scale well

slide-41
SLIDE 41

V3 Refactor architecture Add “release manager”

slide-42
SLIDE 42

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-43
SLIDE 43

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-44
SLIDE 44

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-45
SLIDE 45

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-46
SLIDE 46

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-47
SLIDE 47

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-48
SLIDE 48

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-49
SLIDE 49

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

slide-50
SLIDE 50

V3 Rollback doesn’t go via CI

slide-51
SLIDE 51

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

rollback!

slide-52
SLIDE 52

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

rollback!

slide-53
SLIDE 53

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

rollback!

slide-54
SLIDE 54

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

rollback!

slide-55
SLIDE 55

Version controlled code

V3 architecture

Version controlled code CI system Docker registry Kubernetes cluster Version controlled config Release manager Code Docker image Kubernetes YAML

p u s h i m a g e push config pull image list images p u l l , m

  • d

i f y , p u s h c

  • n

f i g push code

policy

rollback!

slide-56
SLIDE 56

What does the release manager do?

  • Watches for changes in a container registry (output of CI

system)

  • Makes commits for you to version controlled configuration

(understands Kubernetes YAML)

  • Depending on release policy (per environment), either push

changes continuously or permit manually gated releases

  • Allows releases to be rolled back by changing a pointer
  • Releases can be “locked” as a social cue
slide-57
SLIDE 57

Different environments can have different release policies (no tight coupling between individual microservices repos and what’s released)

slide-58
SLIDE 58

Demo!

slide-59
SLIDE 59

This is how we deploy Weave Cloud Weave Cloud helps devops iterate faster with:

  • observability &

monitoring

  • continuous delivery
  • container networks &

firewalls Weave Flux is a release manager for Kubernetes

slide-60
SLIDE 60

Other topics

  • Kubernetes 101
  • How do I monitor this stuff? (Prometheus)
  • Network policy for isolating & firewalling different

microservices We have talks & trainings on all these topics in the Weave user group!

slide-61
SLIDE 61

Join the Weave user group! meetup.com/pro/Weave/
 Come hang out on Slack! weave.works/help

slide-62
SLIDE 62

Thanks! Questions? We are hiring! DX in San Francisco Engineers in London & SF weave.works/weave-company/hiring

Check out Flux on GitHub: github.com/weaveworks/flux