Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
@BastianHofmann Creating a fast Kubernetes Development Workflow Bastian Hofmann
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
Container orchestration platform
Slide 4
Slide 4 text
Deploy, run and scale your services in isolated containers
Slide 5
Slide 5 text
No vendor lock in
Slide 6
Slide 6 text
Runs on
Slide 7
Slide 7 text
Your laptop
Slide 8
Slide 8 text
Bare metal
Slide 9
Slide 9 text
Cloud Providers
Slide 10
Slide 10 text
And if you don't want to install and maintain Kubernetes yourself
Slide 11
Slide 11 text
Managed Kubernetes
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
Standardized APIs
Slide 14
Slide 14 text
It works the same everywhere*
Slide 15
Slide 15 text
It works the same everywhere* *mostly
Slide 16
Slide 16 text
This talk is about how to use Kubernetes
Slide 17
Slide 17 text
Not only for production workloads
Slide 18
Slide 18 text
But in your development workflows
Slide 19
Slide 19 text
Goal: Development environment as close to production as possible
Slide 20
Slide 20 text
Kubernetes' standardized API makes this easier
Slide 21
Slide 21 text
Agenda
Slide 22
Slide 22 text
Deployment of a micro-service application
Slide 23
Slide 23 text
Some tools to help with local development of this application on Kubernetes
Slide 24
Slide 24 text
Let's have a look at the sample application
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
OpenStack Cloud LoadBalancer NGINX Ingress Controller NGINX Ingress Controller NGINX Ingress Controller web-application web-application MySQL Primary MySQL Secondary quote-svc quote-svc hello-svc hello-svc
Slide 27
Slide 27 text
external-dns to create DNS entries automatically
Slide 28
Slide 28 text
cert-manager to retrieve Let's Encrypt certificates automatically
Slide 29
Slide 29 text
Database is managed by an Operator
Slide 30
Slide 30 text
MySQL Operator MySQLCluster MySQL pods MySQL statefulset Kubernetes controller manager Discovers Creates Creates Discovers Monitors and manages
Slide 31
Slide 31 text
If you are interested in the code and how to set it up: https:/ /github.com/syseleven/ golem-workshop
Slide 32
Slide 32 text
Demo
Slide 33
Slide 33 text
Writing this YAML files is tedious
Slide 34
Slide 34 text
YAML files are tied to a specific version and a specific environment
Slide 35
Slide 35 text
Production
Slide 36
Slide 36 text
Staging
Slide 37
Slide 37 text
Development
Slide 38
Slide 38 text
Per Development team
Slide 39
Slide 39 text
Per branch
Slide 40
Slide 40 text
Per developer
Slide 41
Slide 41 text
We need to maintain multiple, very similar YAML files with slightly different versions and configuration
Slide 42
Slide 42 text
"Templating"
Slide 43
Slide 43 text
Great tools because of standardized Kubernetes API
Slide 44
Slide 44 text
Helm
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
Allows to install applications
Slide 47
Slide 47 text
So called "charts"
Slide 48
Slide 48 text
$ helm install stable/wordpress \ --name my-blog \ --namespace blog
Slide 49
Slide 49 text
Charts can depend on other charts
Slide 50
Slide 50 text
Multiple deployments of one chart possible
Slide 51
Slide 51 text
Different release names
Slide 52
Slide 52 text
Different namespaces
Slide 53
Slide 53 text
Configuration with values
Slide 54
Slide 54 text
No content
Slide 55
Slide 55 text
$ helm install stable/wordpress \ --name my-blog \ --namespace blog \ -f my-config-values.yaml
Slide 56
Slide 56 text
Demo
Slide 57
Slide 57 text
Writing your own charts is fairly easy
Slide 58
Slide 58 text
Scaffolding to get started
Slide 59
Slide 59 text
$ helm create quote-svc
Slide 60
Slide 60 text
Helm lint
Slide 61
Slide 61 text
Helm kubeval
Slide 62
Slide 62 text
Helm test
Slide 63
Slide 63 text
Demo
Slide 64
Slide 64 text
Alternatives: Kustomize
Slide 65
Slide 65 text
This works now great for production or staging or CI
Slide 66
Slide 66 text
Still, for development:
Slide 67
Slide 67 text
Make a code change
Slide 68
Slide 68 text
Build docker image
Slide 69
Slide 69 text
Push docker image
Slide 70
Slide 70 text
Run helm install/upgrade with new image version
Slide 71
Slide 71 text
Can this be quicker?
Slide 72
Slide 72 text
Run everything locally
Slide 73
Slide 73 text
docker-compose
Slide 74
Slide 74 text
Duplication of the definition of how to run a container
Slide 75
Slide 75 text
Inconsistencies
Slide 76
Slide 76 text
If you have a lot of services, you have to run a lot locally
Slide 77
Slide 77 text
Some services locally, some remote
Slide 78
Slide 78 text
Service Discovery
Slide 79
Slide 79 text
Not every service is exposed to the Internet
Slide 80
Slide 80 text
Shared resources with other developers?
Slide 81
Slide 81 text
Other options?
Slide 82
Slide 82 text
Tilt
Slide 83
Slide 83 text
$ tilt up
Slide 84
Slide 84 text
Watches for code changes
Slide 85
Slide 85 text
Rebuilds docker image
Slide 86
Slide 86 text
Deploys to Kubernetes
Slide 87
Slide 87 text
Sets up port-forwarding
Slide 88
Slide 88 text
Can sync changed files directly into a running container
Slide 89
Slide 89 text
Demo
Slide 90
Slide 90 text
Alternatives: Skaffold Garden
Slide 91
Slide 91 text
Debugging containers
Slide 92
Slide 92 text
Most containers do not have all the debugging tools included
Slide 93
Slide 93 text
Kubectl debug
Slide 94
Slide 94 text
Debugging network traffic between containers
Slide 95
Slide 95 text
Kubectl sniff
Slide 96
Slide 96 text
Demo
Slide 97
Slide 97 text
Another approach
Slide 98
Slide 98 text
No content
Slide 99
Slide 99 text
Creates a two-way proxy between the Kubernetes cluster and you
Slide 100
Slide 100 text
$ telepresence T: Starting proxy with method 'vpn-tcp'... @fhgbvx65xg|bash-3.2$ curl http://quote-svc/quote | jq '.' [ { "ID": 503, "title": "stefan sagmeister", "content": "
...
\n", "link": "https://quotesondesign.com/stefan- sagmeister-2/" } ]
Slide 101
Slide 101 text
Swap a running deployment in the cluster with a local process
Slide 102
Slide 102 text
... or a locally running docker container
Slide 103
Slide 103 text
$ telepresence --swap-deployment quote-svc --namespace dev-flow-demo --expose 3000 --run npm run debug T: Starting proxy with method 'vpn-tcp',... T: Forwarding remote port 3000 to local port 3000.... >
[email protected]
debug /Users/bhofmann/forge_test/quote- svc > nodemon --inspect quote-svc.js [nodemon] watching: *.* [nodemon] starting `node --inspect quote-svc.js` Debugger listening on ws://127.0.0.1:9229/83aa27ac- d879-4b50-a228-440354cca791 quote svc listening on port 3000!
Slide 104
Slide 104 text
Demo
Slide 105
Slide 105 text
Summary
Slide 106
Slide 106 text
Powerful
Slide 107
Slide 107 text
Great tooling because of common APIs
Slide 108
Slide 108 text
Especially great if you have multiple services and don't want to run everything locally
Slide 109
Slide 109 text
Test it 30 days For free Visit us at our booth
Slide 110
Slide 110 text
[email protected]
https:/ /twitter.com/BastianHofmann http:/ /speakerdeck.com/u/bastianhofmann https:/ /github.com/syseleven/golem-workshop