Shahid Iqbal | Freelance consultant
@shahiddev
Kubernetes, Azure & .NET
What’s it all about?
Slide 2
Slide 2 text
@shahiddev
Very brief intro
Freelance hands-on consultant working on .NET, Azure & Kubernetes
Developer/Architect in .NET for +10yrs based in the UK
Microsoft MVP
Co-organiser of the MK.net meetup in the UK
@shahiddev on Twitter
https://www.linkedin.com/in/shahiddev/
https://sessionize.com/shahid-iqbal
https://blog.headforcloud.com
Slide 3
Slide 3 text
@shahiddev
Agenda
Kubernetes overview
Creating clusters and deploying apps
Demos
Managed Kubernetes providers
Demos
Hybrid clusters
Planning for Kubernetes
Slide 4
Slide 4 text
@shahiddev
Key takeaways
A good understanding of the Kubernetes architecture and key concepts
Confidence to create clusters and deploy applications
Launching pad to go away and learn more
Caveat:
Not a Docker tutorial – won’t go into details of creating containers
Slide 5
Slide 5 text
@shahiddev
What is Kubernetes?
Slide 6
Slide 6 text
@shahiddev
Quick tangent!
K8s
K ubernete s
Slide 7
Slide 7 text
@shahiddev
Why do I need it?
Application per VM/physical host
Slide 8
Slide 8 text
@shahiddev
Why do I need it?
Multiple applications per VM/physical host
Slide 9
Slide 9 text
@shahiddev
Why do I need it?
Slide 10
Slide 10 text
@shahiddev
Where to run Kubernetes?
On premise
Cloud IaaS
AKS
GKE
Managed providers
@shahiddev
Kubernetes features
Container orchestration
Horizontal scaling
Rolling deployments and rollbacks
Self healing
Service discovery and load balancing
Batch execution (jobs)
…
@shahiddev
Control
plane
Node(s)
Worker
Node
Worker
Node
Worker
Node
API
High-level architecture
Management/Control
plane
UI/CLI
Windows nodes GA! (K8s 1.14)
Slide 17
Slide 17 text
@shahiddev
Anatomy of a control plane node
etcd
API Server Scheduler
Controller
manager
Cloud
Controller
manager
Kubectl
UI
Slide 18
Slide 18 text
@shahiddev
Anatomy of a worker node
Kubelet
Kube-proxy
supervisord fluentd
Pod
Pod
Pod
Pod
Container runtime
Slide 19
Slide 19 text
@shahiddev
Pods
Localhost
Node
Pod
Pod
• Containers within a
pod that share
resources
• Can communicate
over localhost
• Are deployed/scaled
as a unit
Slide 20
Slide 20 text
@shahiddev
Developing locally
Slide 21
Slide 21 text
@shahiddev
DEMO
RUNNING K8S LOCALLY
Slide 22
Slide 22 text
@shahiddev
Kubernetes Manifest files
YAML or JSON files
Defines application structure/resources
Desired state
Containers = application
Manifest = “infrastructure/configuration as code”
Should be in source control
@shahiddev
Service types
LoadBalancer
Expose service publicly (relies on hosting infrastructure)
ClusterIP
Assign it an internal cluster IP only – not public
NodePort
Port on each node which can route to service
ExternalName
Maps to a CNAME record (i.e. external service)
Slide 29
Slide 29 text
@shahiddev
Ingress
Allows for routing using a single entry point into the cluster
Routing to different applications based on rules
Single SSL termination point (depending on SSL cert type)
May be preferable vs multiple LoadBalancer services
Implemented by variety of providers – ngnix, haproxy etc
More advanced control -> Service Mesh
Slide 30
Slide 30 text
@shahiddev
Host name based routing using Ingress
Node 1 Node 2 Node 3
app1 svc
app:app1 app:app1
app:app2
cluster
app:app2
Load
Balancer
app2 svc
Ingress controller
Public IP
app1.mydomain.com
Host: app1.mydomain.com
Slide 31
Slide 31 text
@shahiddev
Host name based routing using Ingress
Node 1 Node 2 Node 3
app1 svc
app:app1 app:app1
app:app2
cluster
app:app2
Load
Balancer
app2 svc
Ingress controller
Public IP
app2.mydomain.com
Host: app2.mydomain.com
Slide 32
Slide 32 text
@shahiddev
Host based routing Ingress file
Slide 33
Slide 33 text
@shahiddev
Helm
De facto application package manager for Kubernetes
“Apt-get/chocolatey of Kubernetes”
Parameterise settings and re-use settings
Packages == Charts
Kubeapps Hub – repository of public charts for common apps/services
Package your applications as Helm charts
Slide 34
Slide 34 text
@shahiddev
Quick feature tour
HEALTH, READINESS, DEPLOYMENTS
Slide 35
Slide 35 text
@shahiddev
Health checks
HTTP
TCP
Exec
Pod
Slide 36
Slide 36 text
@shahiddev
Readiness checks
HTTP
TCP
Sockets
Pod
Slide 37
Slide 37 text
@shahiddev
Rolling updates
Zero downtime rolling updates
Blue/Green updates
Rollback
*Rolling updates with complex data/schema changes still challenging.
Slide 38
Slide 38 text
@shahiddev
Speed of rollout vs service capacity
Max unavailable
number of old pods taken offline during update
Max surge
number of new pods created alongside existing pods
during update
*(number or %)
Slide 39
Slide 39 text
@shahiddev
Rolling updates
v1
v1 v1
v2
Max unavailable: 0
Max surge: 1
v2
v2
Service
Slide 40
Slide 40 text
@shahiddev
Blue/Green deployment
v1
v1
v1
v2
Max unavailable: 0
Max surge: 100%
v2
v2
Service
Slide 41
Slide 41 text
@shahiddev
Managed Kubernetes Providers
Azure
Kubernetes
Service
• Control plane is handled
by provider
• Removes significant
overhead of running
K8s cluster
• Free control plane
node(s) – except EKS
Google
Kubernetes
Engine
Slide 42
Slide 42 text
@shahiddev
Azure Kubernetes Service - AKS
Management nodes not visible (and not charged)
Lose flexibility to run feature flags/startup params
Supports multiple K8s versions with option to upgrade clusters
Integration into existing Vnets
RBAC using Azure AD*
Cluster autoscaling*
Nodes are auto-patched (but not restarted)
Windows node pools (private preview)
*preview features
Slide 43
Slide 43 text
@shahiddev
Azure Kubernetes Service - AKS
//create resource group
az group create -n hfck8sRG -l westeurope
//create cluster
az aks create -n hfck8s -g hfck8sRG /
-k 1.12.6 //k8s version /
-c 3 //node count
Slide 44
Slide 44 text
@shahiddev
DEMO
AKS & DEPLOYING
Slide 45
Slide 45 text
@shahiddev
Microsoft support for Kubernetes
Contribute to K8s project
Acquisition of Deis
Brendan Burns - K8s co-founder works there
More tooling for .NET developers coming
Helm, Draft, Brigade, Azure Dev Spaces
Slide 46
Slide 46 text
@shahiddev
Single platform for all .NET apps
Hybrid clusters (linux + windows worker nodes)
“Legacy” full .NET framework apps & .NET core apps on single
platform
Single CI/CD approach
Simplify evolving architecture to microservices by removing
complexity around “plumbing”
Slide 47
Slide 47 text
@shahiddev
Single CI/CD approach
CI Build
containers
@shahiddev
Hybrid clusters
Windows nodes in private preview on AKS
Expect public preview soon
AKS-Engine on Azure can create hybrid clusters (not managed)
Slide 51
Slide 51 text
@shahiddev
Planning for Kubernetes
Don’t get sucked into the K8s hype
Focus on basics
Develop 12-factor style apps (logging/readiness/health-checks)
Clear plan for architecture/microservices
Writing/migrating to .NET core
CI/CD pipelines
Containerise “legacy” .NET applications into Windows Containers
Don’t forget container and cluster security
Consider GitOps – beware of “pet” clusters
Slide 52
Slide 52 text
@shahiddev
What alternatives are there?
Slide 53
Slide 53 text
@shahiddev
Summary
Kubernetes is mature and feature rich container orchestration
platform
Many large organisations are betting on it as their platform of the
future
Windows support is gaining traction
Microsoft is heavily invested in it
Tooling/support for .NET developers will make the adoption even
easier
Slide 54
Slide 54 text
@shahiddev
Where can I go to learn more?
http://www.katacoda.com
https://kubernetes.io/docs/home
Kubernetes up & running
By Kelsey Hightower, Brendan
Burns, Jo Beda