.NET-Core-Anwendungen skalierbar betreiben mit Kubernetes und Microsoft Azure

6848c06ef647ab606c668cc5264c0fc9?s=47 Thorsten Hans
September 26, 2018

.NET-Core-Anwendungen skalierbar betreiben mit Kubernetes und Microsoft Azure

Sie möchten Ihre Docker-basierten .NET-Core-Anwendungen effizient betreiben und dynamisch – entsprechend Ihren Anforderungen – skalieren? Dann benötigen Sie einen so genannten Orchestrator. Ein Orchestrator übernimmt die wichtigen Aufgaben im Lebenszyklus einer containerbasierten Anwendung und unterstützt Sie bei alltäglichen Problemstellungen wie Updates oder dem Outscaling einzelner Anwendungsartefakte. Das Open-Source-Projekt Kubernetes ist aktuell der wohl populärste Orchestrator. Microsoft Azure bietet mit Azure Container Services (AKS) einen komplett verwalteten Kubernetes-Dienst an. Doch wie stellen Sie Ihre Anwendung in Kubernetes bereit? Was sind die Vorteile von AKS? Wie lassen Sie Ihre Anwendung automatisch basierend auf der aktuellen Auslastung skalieren? Diese und viele weitere Fragen beantwortet Thorsten Hans in seinem Vortrag anhand von vielen praktischen Beispielen.

6848c06ef647ab606c668cc5264c0fc9?s=128

Thorsten Hans

September 26, 2018
Tweet

Transcript

  1. .NET-Core-Anwendungen skalierbar betreiben Mit Kubernetes und Microsoft Azure Thorsten Hans

    @ThorstenHans Consultant @ Thinktecture AG
  2. What to expect • Kubernetes • Azure • Containers •

    Terminal What not to expect • .NET Core Introduction • UX / UI Best Practices
  3. The guy who’s talkin’ Consultant @ Thinktecture AG thorsten.hans@thinktecture.com thorsten.hans@gmail.com

    thinktecture.com thorsten-hans.com @ThorstenHans Thorsten Hans
  4. • What is Kubernetes (K8S) • Azure Kubernetes Services (AKS)

    • Bring .NET Core Applications to K8S Talking Points
  5. Kubernetes k8s

  6. Open-Source Container Orchestrator § Initially founded by Google / now

    maintained by CNCF (Cloud Native Computing Foundation) § Successor of Google’s Borg § Original Codename Seven (https://en.wikipedia.org/wiki/Seven_of_Nine) § Greek for pilot or helmsman of a ship § Written in go § https://kubernetes.io/ Kubernetes
  7. What is k8s § Container platform § Runs Docker containers

    § Takes care about Networking / Isolation of applications § Abstracting hardware from the developer § Cloud-Agnostic § Container Lifecycle Management § Deployment, Rolling Upgrades, Scaling, Load-Balancing Kubernetes
  8. The concept of desired state In Kubernetes you describe your

    deployment by using code. You define a desired state like “I want 5 instances of this Docker image”. Kubernetes ensures that actual state is always matching your desired state. So there will always be 5 instances of the requested Docker image. If the cluster is facing hardware issues, k8s spins up new instances of the Docker image on a different node till the actual state is again matching the desired state. Kubernetes
  9. 10.000 foot view Kubernetes architecture

  10. Namespaces

  11. Pods and Services

  12. Deployment as Code § All Kubernetes building blocks are created

    using code § YAML or JSON can be used § YAML is almost industry standard for Kubernetes § Deployment Code goes to Source Control § Continuous Deployment triggered by Source Control hooks § git push webhook Kubernetes
  13. Azure Kubernetes Services AKS

  14. AKS § Fully managed Kubernetes cluster § Easy to scale-out,

    upgrade, replicate § Seamless integration with other Azure resources § Self healing for k8s Masters § Cost efficient – you pay ONLY for your Nodes § https://azure.microsoft.com/en-us/services/kubernetes-service/ Azure Kubernetes Services
  15. AKS § Service quotas and limits* § Max 100 nodes

    per cluster § Max 110 pods per node § Max 100 clusters per subscription * Limits can be increased by creating an Azure Service Request Azure Kubernetes Services
  16. Azure ! AKS § k8s Load-Balancer will spin up an

    Azure Load Balancer § Easily mount Azure Files Shares and Disks as Volumes § Consume Docker Images from Azure Container Registry (ACR) § Communicate with other Azure Resources like Redis, SQL Azure § Traffic inside the same region is always free AKS Azure Integration
  17. Bring .NET Core Applications to k8s

  18. What is required • Obviously a .NET Core Application •

    Packaged as Docker Image • Windows Containers are possible but way bigger in size • Docker Image needs to be published to a registry • Docker Hub • Azure Container Registry (ACR) • Consider refactoring application configuration stack • https://12factor.net/ Bring .NET Core Applications to k8s
  19. Architectural decisions • Don’t put everything into a container •

    Use PaaS offerings if possible • Azure Redis Cache • CosmosDB • Azure Storage Bring .NET Core Applications to k8s
  20. Keep sensitive data safe • Use Azure KeyVault for •

    Secrets • Connection Strings • Certificates Bring .NET Core Applications to k8s
  21. • What is Kubernetes (K8S) • Azure Kubernetes Services (AKS)

    • Bring .NET Core Applications to K8S Recap
  22. Code https://github.com/ThorstenHans/aks-demo-app Slides https://speakerdeck.com/thorstenhans Code & Slides

  23. Using Azure CLI # Create a resource group az group

    create --name thh-demo --location westeurope --tags @{resp="THH"} # Create a Service Principal az ad sp create-for-rbac --name thh-demo-aks-sp --skip-assignment # Will print something like { "appId": "7248f250-0000-0000-0000-dbdeb8400d85", # --> identifier ($SP-ID) "displayName": "thh-demo-aks-sp", "name": "http://thh-demo-aks-sp", "password": "77851d2c-0000-0000-0000-cb3ebc97975a", # --> client secret ($SP_PWD) "tenant": "72f988bf-0000-0000-0000-2d7cd011db47“ } Prepare a new AKS Cluster
  24. Using Azure CLI # Create a AKS Cluster az aks

    create --name thh-demo-aks --resource-group thh-demo --location westeurope --service-principal $SP-ID --client-secret $SP_PWD --node-count 3 --node-vm-size Standard_DS1_v2 --tags @{resp="THH"} Create a new AKS Cluster
  25. Using Azure CLI # Scale-Out an AKS Cluster (increase Node

    count to 5) az aks scale --name thh-demo-aks --resource-group thh-demo --node-count 5 Scale-Out an AKS Cluster
  26. Using Azure CLI # Scale-In an AKS Cluster (reduce Node

    count to 1) az aks scale --name thh-demo-aks --resource-group thh-demo --node-count 1 Scale-In an AKS Cluster
  27. Using Azure CLI # Get current k8s version az aks

    get-upgrades --name thh-demo-aks --resource-group thh-demo --output table # Name ResourceGroup MasterVersion NodePoolVersion Upgrades # ------- --------------- --------------- ----------------- -------------- # thh... thh-demo 1.9.1 1.9.1, 1.9.2, 1.9.6 Get AKS Cluster Upgrades
  28. Using Azure CLI # Start k8s upgrade az aks upgrade

    --name thh-demo-aks --resource-group thh-demo --kubernetes-version 1.9.6 Upgrade an AKS Cluster
  29. Q&A If you’ve further questions later on: shoot me a

    mail at thorsten.hans@thinktecture.com / thorsten.hans@gmail.com or tweet at @ThorstenHans