Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Creating a fast Kubernetes Development Workflow
Search
Bastian Hofmann
May 26, 2019
Programming
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Creating a fast Kubernetes Development Workflow
Bastian Hofmann
May 26, 2019
More Decks by Bastian Hofmann
See All by Bastian Hofmann
Monitoring in Kubernetes with Prometheus and Grafana
bastianhofmann
0
370
Creating a fast Kubernetes Development Workflow
bastianhofmann
0
150
Highly available cross-region deployments with Kubernetes
bastianhofmann
1
170
From source to Kubernetes in 30 minutes
bastianhofmann
0
200
Introduction to Kubernetes
bastianhofmann
1
140
CI/CD with Kubernetes
bastianhofmann
0
250
Creating a fast Kubernetes Development Workflow
bastianhofmann
1
290
Deploying your first Micro-Service application to Kubernetes
bastianhofmann
2
210
Dive-In-Workshop: Kubernetes
bastianhofmann
0
450
Other Decks in Programming
See All in Programming
yield再入門 #phpcon
o0h
PRO
0
710
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
500
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.6k
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
130
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
100
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
370
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
160
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
190
霧の中の代数的エフェクト
funnyycat
1
420
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
350
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
180
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
The Spectacular Lies of Maps
axbom
PRO
1
870
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Transcript
@BastianHofmann Creating a fast Kubernetes Development Workflow Bastian Hofmann
None
Container orchestration platform
Deploy, run and scale your services in isolated containers
Very Powerful
Large community
Lot’s of large company backers
No vendor lock in
Standardized APIs
Runs on
Your laptop
None
Bare metal
Cloud Providers
AWS
Azure
Google Cloud Platform
And if you don't want to install and maintain Kubernetes
yourself
Managed Kubernetes
None
Easy setup
Easy upgrades
Easy scaling
Features
Load Balancing
Distributed Persistent Storage
Backups
Monitoring
Support
You can focus on what is important
But this talk is about how to use Kubernetes
Not only for production workloads
But in your development workflows
Kubernetes has standardized apis
More and more integrations
Great tools
Agenda
Introduction to Kubernetes
Deployment of a simple application
Deployment of a micro-service application
Some tools for development with Kubernetes
But first
Why containers?
Services run in isolation
Everything needed to run a service in one image
Make things …
Easier to develop
Easier to deploy
Easier to upgrade system dependencies
Easier to scale
Better resource usage
#safeThePlanet
Kubernetes helps you to deploy, run and scale containers
Let’s define some core concepts and terminology first
Kubernetes Cluster
• A docker image built from a Dockerfile that contains
everything a service needs to run Image
• A container runs a docker image. • Only 1
process can run inside of a container Container
• A group of 1 or more containers • Same
port space • Within a Pod: communication over localhost • Every Pod has it's own IP • All Pods can talk with each other • IPs change all the time Pod
• Defines and manages how many instances of a pod
should run • ReplicaSet is tied to a specific definition of a Pod which is tied to specific image versions of the container • Image versions in ReplicaSets can't be updated Replica Set
• Manages updates and rollbacks of replica sets Deployment
• Internal LoadBalancer • Makes all pods matching a set
of labels accessible through a stable, internal IP address • You can attach external IP address through an cloud LoadBalancer Service
• Makes a service accessible to the outside of Kubernetes
through an ingress controller (e.g. nginx) • Traffic is routed by routing rules, usually Host header Ingress
• A physical server • Containers get distributed automatically Node
• Key/Value storage for configuration ConfigMap
• Key/Value storage for configuration, usually passwords. Secret
• Volumes can be mounted into a container to access
a ConfigMap, Secret, persistent volumes with network storage or a folder on the node Volumes
• Dedicated environment to deploy services in Namespaces
CronJobs, DaemonSets, StatefulSets, ...
Everything is a resource
You interact with Kubernetes by creating, receiving, updating and deleting
resources
Kubernetes has controllers to listen on these interactions and get
the cluster in the desired state
The Kubernetes API can be extended with additional Resources and
Controllers
CustomResourceDefinitions
Certificate, Backup, Restore, MySQLCluster, Function, ...
kind: Deployment apiVersion: extensions/v1beta1 metadata: name: symfony-demo spec: template: spec:
containers: - name: symfony-demo image: symfony-demo:1.1.0 ports: - containerPort: 80
$ kubectl apply -f deployment.yaml
$ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
symfony-demo 1 1 1 1 21h
$ kubectl get deployment symfony-demo -o yaml apiVersion: extensions/v1beta1 kind:
Deployment metadata: annotations: ... spec: ... template: ... spec: containers: - name: symfony-demo image: symfony-demo:1.1.0
$ kubectl delete deployment symfony-demo
Practical example
We need a cluster
Let’s deploy an application
DEMO
What did just happen?
None
Deployment created
Sees new Deployment And creates new ReplicaSet with 1 desired
replica
Sees new ReplicaSet and Creates Pod for ReplicaSet
Sees new unscheduled Pod and Schedules it to Node
Sees it is supposed to start a Pod And starts
its Containers
Service created
Sees the new Service And configures IP Table Rules and
DNS entries
Sees the new Service has the Type LoadBalancer and creates
An External LB at the Cloud Provider
What about Configuration
DEMO
What about TLS and DNS
You don't want to implement TLS certificate handling in every
public service
Ingress Controller and cert-manager
The ingress controller (nginx) listens on Ingress Resources and configures
itself to route incoming traffic based on the host header to the correct running pods
Cert-manager listens on Ingresses and if they want TLS, requests
a certificate from LetsEncrypt
External-DNS listens on Ingresses and creates DNS entries at DigitalOcean
How is traffic routed to the Pod
OpenStack LoadBalancer
DEMO
What about Persistent Storage and Databases
DEMO
Writing this YAML files is tedious
YAML files are tied to a specific version and a
specific environment
Production
Staging
Development
Per Development team
Per branch
Per developer
Built-in
Namespaces
Still we'd need to maintain multiple very similar YAML files
with slightly different versions and configuration.
"Templating"
Great tools because of standardized Kubernetes API
Helm
None
Allows to install applications
So called "charts"
Writing your own charts if fairly easy
Charts can depend on other charts
Multiple deployments of one chart possible
Different namespaces
Different release names
Configuration over values
None
Different versions
Different ingress urls
$ helm install stable/wordpress --namespace bastian --name my-wordpress --values dev.yaml
--values bastian.yaml
Still:
Make a code change
Build docker image
Push docker image
Run helm install/upgrade with new image version
Can this be quicker?
Tilt
Watches for changes
Rebuilds docker image
Deploys to Kubernetes
You can use your helm templates
$ tilt up
Demo application
web quote-svc hello-svc
Not all services have an ingress
Accessing Kubernetes from the outside
web quote-svc hello-svc
Getting a shell in a running container
$ kubectl exec $POD_NAME -i -t -- /bin/bash
Port forwarding through kubectl
$ kubectl port-forward pod/$POD_NAME 8080:80
$ kubectl port-forward service/$SERVICE_NAME 8080:80
What about step debugging?
Of course you can run everything locally
But you develop only on one service
There may be lots of services
You don't want to expose all services publicly
Port-forwarding all services is also work
Telepresence
None
Creates a two-way proxy between the Kubernetes cluster and you
$ telepresence T: Starting proxy with method 'vpn-tcp'... @fhgbvx65xg|bash-3.2$ curl
http://quote-svc/quote | jq '.' [ { "ID": 503, "title": "stefan sagmeister", "content": "<p>...</p>\n", "link": "https://quotesondesign.com/stefan- sagmeister-2/" } ]
Swap a running deployment in the cluster with a local
process
... or a locally running docker container
$ 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!
Demo
Summary
Powerful
Helpful
Great tooling because of common APIs
Especially great if you have multiple services and don't want
to run everything locally
I just picked helm, tilt and telepresence. There is more
for different use-cases.
http:/ /speakerdeck.com/ u/bastianhofmann
https:/ /github.com/bashofmann/ kubernetes-dev-flow-demo
[email protected]
https:/ /twitter.com/BastianHofmann