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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
380
5分で問診!Composer セキュリティ健康診断
codmoninc
0
1k
源内ハンズオン概要編
hideg
0
190
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
320
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
240
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
670
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
980
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
800
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
260
数百円から始めるRuby電子工作
tarosay
0
160
メールのエイリアス機能を履き違えない
isshinfunada
0
240
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
210
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
410
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
800
Visualization
eitanlees
152
17k
The agentic SEO stack - context over prompts
schlessera
0
860
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
400
Agile that works and the tools we love
rasmusluckow
331
22k
Faster Mobile Websites
deanohume
310
32k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
210
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
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