Slide 1

Slide 1 text

@BastianHofmann CI/CD with Kubernetes Bastian Hofmann [email protected]

Slide 2

Slide 2 text

Continuous Integration

Slide 3

Slide 3 text

Continuous Delivery

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Container orchestration platform

Slide 6

Slide 6 text

Deploy, run and scale your services in isolated containers

Slide 7

Slide 7 text

No vendor lock in

Slide 8

Slide 8 text

Standardized APIs

Slide 9

Slide 9 text

Runs on

Slide 10

Slide 10 text

Your laptop

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Bare metal

Slide 13

Slide 13 text

Cloud Providers

Slide 14

Slide 14 text

And if you don't want to install and maintain Kubernetes yourself

Slide 15

Slide 15 text

Managed Kubernetes

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

So we have code, how do we get this into Kubernetes?

Slide 19

Slide 19 text

Lot's of tools

Slide 20

Slide 20 text

Example for this talk

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Example application

Slide 23

Slide 23 text

https:/ /gitlab.com/bashofmann/ angular-test-app

Slide 24

Slide 24 text

https:/ /gitlab.com/bashofmann/ angular-test-app-finished

Slide 25

Slide 25 text

Pipeline with multiple stages, each stage can have multiple jobs

Slide 26

Slide 26 text

Stage 1: Preparing

Slide 27

Slide 27 text

Stage 2: Linters and Tests

Slide 28

Slide 28 text

Stage 3: Building an image

Slide 29

Slide 29 text

Stage 4: On master: Deploying to Kubernetes into a stage namespace

Slide 30

Slide 30 text

Stage 5: On master: Testing if stage works

Slide 31

Slide 31 text

Stage 6: On tag: Tag the docker image

Slide 32

Slide 32 text

Stage 7: On tag: Deploying to Kubernetes into a prod namespace

Slide 33

Slide 33 text

Stage 8: On tag: Testing if prod works

Slide 34

Slide 34 text

In detail

Slide 35

Slide 35 text

Stage 1: Preparing

Slide 36

Slide 36 text

Only do slow operations once and cache and re-use results

Slide 37

Slide 37 text

Stage 2: Linters and Tests

Slide 38

Slide 38 text

Add linters for everything

Slide 39

Slide 39 text

Unit tests

Slide 40

Slide 40 text

Integration tests

Slide 41

Slide 41 text

Browser tests

Slide 42

Slide 42 text

Stage 3: Building an image

Slide 43

Slide 43 text

Make the build as fast as possible

Slide 44

Slide 44 text

Make the image as small as possible

Slide 45

Slide 45 text

Stage 4: On master: Deploying to Kubernetes into a stage namespace

Slide 46

Slide 46 text

Stage 5: On master: Testing if stage works

Slide 47

Slide 47 text

Stage 6: On tag: Tag the docker image

Slide 48

Slide 48 text

Stage 7: On tag: Deploying to Kubernetes into a prod namespace

Slide 49

Slide 49 text

Stage 8: On tag: Testing if prod works

Slide 50

Slide 50 text

Use a versioning scheme

Slide 51

Slide 51 text

Never deploy "latest"

Slide 52

Slide 52 text

Use Kubernetes namespaces

Slide 53

Slide 53 text

Use Helm or similar tools

Slide 54

Slide 54 text

Make use of Kubernetes "magic"

Slide 55

Slide 55 text

Sealed Secrets

Slide 56

Slide 56 text

Secrets are stored encrypted in Git and encrypted inside of the cluster

Slide 57

Slide 57 text

LoadBalancers

Slide 58

Slide 58 text

Automatically creates a highly available LoadBalancer with a public IP address

Slide 59

Slide 59 text

Ingress controller

Slide 60

Slide 60 text

The ingress controller (nginx) listens on routing rules in Ingress Resources and configures itself to route incoming traffic to the correct running and healthy pods

Slide 61

Slide 61 text

cert-manager

Slide 62

Slide 62 text

Cert-manager listens on Ingress Resources and if they need TLS, requests a certificate from LetsEncrypt

Slide 63

Slide 63 text

external-dns

Slide 64

Slide 64 text

External-DNS listens on Ingress Resources and creates DNS entries

Slide 65

Slide 65 text

Prometheus

Slide 66

Slide 66 text

Kubernetes and Node metrics are automatically included

Slide 67

Slide 67 text

Kubernetes and Node alerts are automatically included

Slide 68

Slide 68 text

Kubernetes and Node dashboards are automatically included

Slide 69

Slide 69 text

Scraping targets can be automatically discovered

Slide 70

Slide 70 text

Service Meshes

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Alternatives

Slide 73

Slide 73 text

Flux

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Knative

Slide 76

Slide 76 text

Kubernetes-based platform to deploy and manage modern serverless workloads

Slide 77

Slide 77 text

Tekton CD

Slide 78

Slide 78 text

CI that runs completely within Kubernetes with Kubernetes Custom Resources

Slide 79

Slide 79 text

[email protected] https:/ /twitter.com/BastianHofmann http:/ /speakerdeck.com/u/bastianhofmann