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

MicroservicesOnKube.pdf

Shahid Iqbal
September 18, 2018
830

 MicroservicesOnKube.pdf

Developing microservices based applications is a hot trend in our industry.
Sometimes this decision is based not on trying solving the specific problems that microservices solve but unfortunately a desire to use the latest techniques or, even worse, a desire to adopt trendy new platforms such as Kubernetes and service meshes.

However, let's assume that our audience on the other hand have clearly identified how microservices will benefit them.
This talk introduces a "journey" to microservices and highlights some new problems that are created by adopting such an architecture.

We then step through how we can leverage cloud native technologies such as Kubernetes and the even trendier topic of service meshes such as Istio to try and address some of these new problems.

This talk along with demos will cover many topics in an area which is rapidly evolving however we'll try and focus on the fundamental problems, and demonstrate tools that can help make the experience better or simply easier to manage.

Some knowledge of microservices, containers and Kubernetes is useful but not essential we'll cover the basic topics

Shahid Iqbal

September 18, 2018
Tweet

Transcript

  1. @shahiddev Very brief intro Freelance hands-on consultant working on Azure,

    .NET & Kubernetes .NET developer/Architect for 10+ yrs & Microsoft MVP Based in the UK and working globally Co-organiser of the MK.net meetup in the UK @shahiddev on Twitter https://www.linkedin.com/in/shahiddev/ https://blog.headforcloud.com https://sessionize.com/shahid-iqbal
  2. @shahiddev Agenda Technical challenges introduced by moving to microservices Addressing

    those challenges with various cloud native technologies
  3. @shahiddev Not covering How to decompose your monolith to microservices

    Deep dive into creating containers Deep dive into Kubernetes concepts
  4. @shahiddev Microservices “ Microservice architecture, is an approach to application

    development in which a large application is built as a suite of modular components or services. ... These services are built around business capabilities and independently deployable by fully automated deployment machinery.” https://searchmicroservices.techtarget.com/definition/microservices
  5. @shahiddev Benefits of microservices architecture Independent scaling of services Smaller/less

    risky deployments Reduced cognitive load for development teams Easier to distribute work across dev teams …
  6. @shahiddev New problems we’ve introduced Multiple deployments – consistency Added

    infrastructure and environment complexity Multiple points of failure/latency Debugging applications Networking & traffic routing Difficulty tracing/logging across those services Security concerns – multiple services
  7. @shahiddev What are containers? Package encapsulating your application and it’s

    dependencies Artefact from your CI system instead of binaries/deployment packages Provide isolation and consistent behaviour across environments “Lightweight VMs” – quick start up times Portable – work anywhere that supports the container runtime
  8. @shahiddev What is Kubernetes? Open source container orchestrator Helps you

    run container based applications by managing the containers across multiple nodes
  9. @shahiddev Kubernetes features Container orchestration Config and secrets management Self

    healing Autoscaling Service discovery & load balancing Basic traffic management (Ingress) Many more….
  10. @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
  11. @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
  12. @shahiddev Scaling our applications in Kubernetes 2 types of application

    level scaling Horizontal scaling (adding more instances) - HPA Vertical scaling (increasing resources allocated to existing instance) – VPA Cluster autoscaler (CA) Increase number of nodes in your cluster to increase compute capacity Virtual Node “serverless” scaling of Kubernetes
  13. @shahiddev Auto scaling triggers Horizontal scaling can be based on

    metrics from application V1 HPA uses CPU/Memory V2 HPA (beta) can scale from almost any metric including external metrics (e.g. queue depth) VPA CPU/Memory usage of application Cluster autoscaler based on applications waiting to be scheduled due to insufficient cluster resources
  14. @shahiddev Azure Container Instances “Serverless” containers No infrastructure required Per

    sec billing for running container Good for: Testing images Short lived containers Bursting for sudden spikes Price reductions -> competitive price vs PaaS/VMs
  15. @shahiddev Bursting load using virtual node Bursting to ACI to

    continue scaling beyond cluster capacity ACI
  16. @shahiddev Scale to zero Out of the box Kubernetes unable

    to scale applications to zero instances Desirable to scale certain microservices to zero instances Message handlers “functions” style applications
  17. @shahiddev KEDA – Kubernetes Event Driven Autoscaler Open source project

    led by Microsoft and RedHat Allows for Kubernetes deployments to be auto scaled based on events Scale up from zero -> n instances Scale down from n -> zero instances Deploy functions (e.g. Azure Functions) and replicate behaviour found in managed cloud platforms Combine with Virtual node to utilise FaaS alongside traditional microservices using consistent platform for managing
  18. @shahiddev Operating Kubernetes Cluster Managed Kubernetes providers help reduce the

    operational complexity of running Kubernetes yourself Google Kubernetes Engine Azure Kubernetes Service
  19. @shahiddev Problem checklist ☹ ☹ Multiple deployments – consistency More

    infrastructure and environment complexity Multiple points of failure Debugging applications Networking & traffic routing Tracing/logging across those services Security concerns – multiple services
  20. @shahiddev From code to Kubernetes Write code Push code to

    repository Build containers Push container to registry Create/update deployment “package” Deploy “package” to K8s Continuous Integration Deployment Local development
  21. @shahiddev Working with dependent services Frontend Service A Service B

    1. Mock/stub out dependent services 2. Run all dependent services on my local machine 3. Run everything on remote cluster 4. Run dependent services on remote cluster
  22. @shahiddev AKS cluster Azure Dev Spaces Frontend Service A Service

    B laptop app.mydomain.com Service A V2 Shahid.s.app.mydomain.com
  23. @shahiddev Shahid dev space Default dev space Azure Dev Spaces

    Frontend Service A Service B app.mydomain.com Service A V2 shahid.s.app.mydomain.com AKS cluster
  24. @shahiddev Azure Dev Spaces Works with VS Code and Visual

    Studio First class support for .NET Core, NodeJS & Java Limited support for other languages Use it to dev/test applications on AKS even if you deploy prod to other Kubernetes clusters GA as of May 6th 2019 https://docs.microsoft.com/en-us/azure/dev-spaces/
  25. @shahiddev Problem checklist ☹ Multiple deployments – consistency More infrastructure

    and environment complexity Multiple points of failure Debugging applications Networking & traffic routing Tracing/logging across those services Security concerns – multiple services
  26. @shahiddev What is a Service mesh? “A service mesh is

    a dedicated infrastructure layer for handling service-to-service communication. It’s responsible for the reliable delivery of requests through the complex topology of services that comprise a modern, cloud native application.” https://blog.buoyant.io/2017/04/25/whats-a-service-mesh-and-why-do-i-need-one/
  27. @shahiddev What is Istio? Open source project being led by

    Lyft, IBM & Google Runs on top of Kubernetes (and other platforms) to extend capabilities Provides: • Network error handling (retry, circuit breakers, timeouts) • Rate limiting • Traffic shifting • Fault injection • Service to service communication security & policies • Distributed tracing of requests
  28. @shahiddev Deploying Istio to your cluster and applications Cluster •

    Istio can be installed in Kubernetes using Helm • Using a number of Custom Resource Definitions (CRDs) to extend behaviour Application • Envoy proxy can be automatically injected into your applications during deployment • Generate updated manifest files using Istioctl
  29. @shahiddev Observability and metrics • Metrics collected in Prometheus •

    Built in Grafana dashboards to display service level metrics • Distributed tracing using Jaegar
  30. @shahiddev Problem checklist Multiple deployments – consistency More infrastructure and

    environment complexity Multiple points of failure Debugging applications Networking & traffic routing Tracing/logging across those services Security concerns – multiple services
  31. @shahiddev Summary Cloud native technologies can help alleviate technical complexity

    caused by adopting microservices Complexity is rarely removed, just shifted (and hopefully becomes someone else's problem) Don’t be peer pressured into adopting microservices Developer tooling for Kubernetes is an area of rapid innovation Service meshes can help with service to service communications But you don’t always need them!
  32. @shahiddev Shahid Iqbal | Freelance consultant @shahiddev Thank you! Slides:

    https://bit.ly/k8s-microservices Video: https://bit.ly/k8s-microservices-video @shahiddev on Twitter https://www.linkedin.com/in/shahiddev/ https://blog.headforcloud.com