Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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.

Thorsten Hans

September 26, 2018
Tweet

More Decks by Thorsten Hans

Other Decks in Technology

Transcript

  1. What to expect • Kubernetes • Azure • Containers •

    Terminal What not to expect • .NET Core Introduction • UX / UI Best Practices
  2. The guy who’s talkin’ Consultant @ Thinktecture AG [email protected] [email protected]

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

    • Bring .NET Core Applications to K8S Talking Points
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. Keep sensitive data safe • Use Azure KeyVault for •

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

    • Bring .NET Core Applications to K8S Recap
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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