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
460
Other Decks in Programming
See All in Programming
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
230
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
110
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.6k
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
160
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
500
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
920
Android CLI
fornewid
0
220
Google Apps Script で Ruby を動かす
kawahara
0
220
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
680
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
510
FDEが実現するAI駆動経営の現在地
gonta
2
280
プロポーザルを書いてもらう
pvcresin
0
500
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Code Review Best Practice
trishagee
74
20k
The Cost Of JavaScript in 2023
addyosmani
55
10k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
470
Ruling the World: When Life Gets Gamed
codingconduct
0
300
The Pragmatic Product Professional
lauravandoore
37
7.4k
The Curse of the Amulet
leimatthew05
2
14k
Automating Front-end Workflow
addyosmani
1369
210k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
Code Reviewing Like a Champion
maltzj
528
40k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
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