dotnet <3 K8s

 

War Story, blood, thriller, etc.

Don't look on slides, they are my notes ;)

#0: who am I?

Piotr Stapp

  • Unique name - just sing a song: "Don't Stapp me know" ;)
  • CEO @ Dotnetomaniak
  • VP @ devWarsztaty
  • ex-Head architect @FinAi
  • "Top secret" @ Allegro
  • M.Sc (distction) Oxford Brooks University in Web Tech
  • M.Sc. Warsaw University of Technology in Computer Science
  • And ......

#1: Let the journey begin

Architecture

  • 50-70 micro-services (.NET + Python)
  • .NET == .NET Framework (less) + dotnet core (more)
  • Azure PaaS == Azure Application Service Environment  on Windows (most) and on Linux (less)
  • Azure Stuff == a lot of Azure components

Why K8s?

  • New, shiny, hype, etc.
  • Money (again)
  • Well tested
  • "Easy" to migrate

Why K8s? Why?

#2: dotnet <3 Linux (memory)

Memory

Memory

Before

  • Total 50-60 services
  • App Service Plans (simplified calculation):
    • RAM: 4 x 3.5GB  (in total 14GB)
    • CPU: Dv2-Series compute equivalent (4 x ~2vCPU)
  • 70-90% memory used
  • From time to time reboot needed

After

  • Total 30 services
  • AKS with 4 DS2 v2 machines:
    • RAM: 4 x 7GB (in total 28GB)
    • CPU: 4 x 2vCPU (single machine has 2 virtual CPU)
  • 100% memory used – dying 
  • Cannot install anything new - OutOfMemory

WTF per minute

  • GC is important
  • GC on Linux in docker has problems
  • Java has problems too :)
  • Temporary fix -> GC Server to GC Workstation
  • Fixed (?) in dotNET 3.0

#3: dotnet <3 Linux (time)

The code

    var tzName = "Central Standard Time";
    var tzi = TimeZoneInfo.FindSystemTimeZoneById(name);
    Console.WriteLine(tzi.DisplayName);

The result

(UTC-06:00) Central Time (US & Canada)

Windows

Exception has occurred: CLR/System.TimeZoneNotFoundException
An unhandled exception of type 'System.TimeZoneNotFoundException'
   occurred in System.Private.CoreLib.dll:
'The time zone ID 'Central Standard Time' was not found
   on the local computer.'

Linux

Windows

Time Zones in the Windows registry

 

All can be found at https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones

Linux

Time Zone database curated by the Internet Assigned Numbers Authority (IANA).

 

All can be found at

https://www.iana.org/time-zones

 

Solution?

  • If, if, if - everywhere
  • UTC only! - even for client
  • NuGet - TimeZoneConverter
  • NuGet - NodeTime 

#4: dotnet <3 Linux (WCF+WebServices)

WCF client only

  • WCF Client for dotnet core - works!
  • SOAP Auth (part) - NotImplementedException
  • NuGet - NotFoundExpceptions
  • StackOverflow - .....

What is SOAP?

  • Set of HTTP Requests & Responses
  • XML over HTTP
  • Well described in W3C
  • Java versus .NET == always a problem

How to solve

  • Fiddler
  • Docs
  • HTTPClient
  • XML parsing

Other options?

  • Azure Function/Azure Web App
  • Azure VM
  • Other proxy

#5: dotnet <3 Linux (other)

"Features"

  • System.Drawing:
    •  up to 3.0 #@$#@$@#$@#%
    • in 3.0+ don't know
  • Microsoft Distributed Transaction Coordinator:
    • nope
    • redesign
  • Performance counters:
    • up to 3.0 - only in code
    • in 3.0+ - new tools

#6: dotnet <3 Linux (sum up)

#7: Azure <3 AKS (Cosmos DB)

How to connect?

  • Cosmos DB has 2 connections types:
    • HTTP - slow
    • TCP - fast
  • Cosmos DB client + docker + AKS == NOPE
  • dotnet core 3.0 -> we didn't checked yet

#7: Devs <3 AKS (CPU limits)

Kubernetes features

  • CPU limits
  • RAM limits
  • Other affiliation

Why?

  • Without it one process can starve  others
  • Some apps are important than others
  • Priority can be important

Question: what is the most CPU consuming part of ASP.NET app?

  1. Start
  2. Request processing
  3. GC processing

How?

  • Observe
  • Observe
  • Try
  • Fix
  • Observe
  • Observe
  • Try
  • Fix
  • ....

#7: Functions <3 AKS (Azure)

How to host Azure Func?

  • App Plan - normal
  • App Plan - consumption
  • App Plan in ASE

Something more?

  • Deploy to docker
  • Configure storage
  • Think about triggers

#7: VNET <3 AKS (Azure)

VNET

  • Configure once - use always
  • No way of changing - recreate only
  • Same problem with:
    • VMSS
    • IP Addressees
    • Node pool (VM sizes)

Solution

  • Full AKS deploy in CI/CD
  • Yes full!
  • 20 minutes break to recreate everything
  • In production create "something" like WAF

#8: NGiNX <3 AKS (K8s)

Ingress

  • K8s "reverse proxy"
  • A lot of implementations
  • NGiNX most popular

Problems

  • Origin host header pass - needs configuration
  • Auth cookie size - needs configuration

The end?

Not yet :)

Adv (in Polish)

Dotknij Kubernetes - za DARMO

"Dotknij Kubernetes" to:

  • 3h+ materiałów z teorią
  • 3 x Microsoft MVP
  • 6+ ćwiczeń praktycznych (+ osobno laby z Docker)
  • 12 pełnych lekcji
  • 100% za darmo
  • 1000+ zapisanych uczestników
  • Do tego ebook - 50+ stron jak zacząć pracę z K8s
  • Sporo wiadomości na mailing liście :)
 

dotnet <3 Linux & k8s

By Piotr Stapp

dotnet <3 Linux & k8s

  • 124