Learn on your Windows 10 development environment all about Distributed Application Runtime (Dapr)

Learn on your Windows 10 development environment all about Distributed Application Runtime (Dapr)

This article will introduce the recently announced Distributed Application Runtime, a.k.a. Dapr (pronounced “dapper”), and then guide you to both configure it on your local machine and consequently explore some samples to start learning it. 

No alt text provided for this image

As described on the its dedicated web site, Dapr is a portable, event-driven runtime that makes it easy for enterprise developers to build resilient, microservice stateless and stateful applications that run on the cloud and edge. Dapr embraces the diversity of languages and developer frameworks.

See blog post Announcing Distributed Application Runtime (Dapr), an open source project to make it easier for every developer to build microservice applications.

What can Dapr bring you as a developer?

For a first glimpse, you can watch Dapr, Rudr, OAM | Mark Russinovich presents next gen app development & deployment.

As well as:

To elaborate a little bit more, today, as a developer, you may be not comfortable with microservice application architectures which are distributed.

It’s unrealistic to expect from everyone to become a distributed systems expert, nor should he or she has to. (By the way, the free e-book Designing Distributing Systems is worth reading to start investing how to develop reliable, distributed systems with adequate patterns and paradigms.)

You may indeed rather prefer – or you have as per your day-to-day job - to focus on application business logic, while leaning on platforms to imbue their applications with scale, resiliency, maintainability, elasticity and the other attributes of cloud-native architectures.

As such, Dapr codifies the best practices for building microservices applications into open, independent building blocks that enables you and all developers to build portable applications with the language and framework of your or their choice.

No alt text provided for this image

Moreover, there are many considerations to architect and build microservices applications. And Dapr can seamlessly solve many problems.

Interestingly enough, Dapr provides best practices for common capabilities when building microservice applications that you can use in a standards way and deploy to any environment.

Each of these capabilities are independent, meaning that you can use one, some or all of them in your application.

In the current release of Dapr, the capabilities include:

  • Resilient service-to-service method invocation to call and retry methods on services wherever they are located in the hosting environment (see article Designing interservice communication for microservices).
  • Distributed tracing between services to easily diagnose and observe inter-service calls in production using the W3C Trace Context  proposed recommendation standard (see article Distributed tracing challenge).
  • Stateless and stateful services. With state management for key/value pairs, long running, highly available stateful services as well as shorter lived, stateless services can be easily written in the same application (see article Data considerations for microservices).
  • Publish and subscribe messaging between services. Publishing events and subscribing to topics between services enables event-driven architectures to simplify horizontal scalability and make them more resilient to failure (see article Publisher-Subscriber pattern).
  • Event driven bindings further builds on event-driven architectures for scale and resiliency by receiving and sending events to and from external systems such as databases and queues.
  • Actors as the simple pattern for stateless and stateful objects that make concurrency simple with method/state encapsulation when building distributed applications.

As outlined above, Dapr empowers you to build microservice applications for the public cloud and the edge, and is platform agnostic. This makes your application more portable, since you are no longer bound to the specifics of that environment, by using an open standard API.

For that purpose, and as of today, Dapr can be run either in standalone mode on a local developer machine or elsewhere, or in Kubernetes (K8s) mode.

Running Dapr runtime in standalone mode enables you to develop Dapr applications in your Windows 10 local development environment and then deploy and run them in other Dapr supported environments. For example, you can develop Dapr applications in Standalone mode and then deploy them to any Kubernetes cluster.

Interestingly enough, while Kubernetes runs on Linux, various options exist on Windows 10 to allow you to also run Kubernetes locally. This was specifically the purpose of my previously published article Install a complete, single node cluster of Kubernetes on Windows 10.

Isn’t is convenient to learn & demo Dapr, and consequently do some practices and testing, do local development, or even demo it?

So, as the title of this article suggest, let’s now see how to setup on Windows 10 a suitable development environment so that you can develop on Windows, and deploy to Linux! ;-)

Setting up your local development environment on Windows 10

Now that you have a (very) first outlook of Dapr, you may want to make a try on your Windows 10 local machine. (Linux is also a great target for such a purpose!)

To prepare your development environment, you will have to:

  • Configure Dapr (CLI) on Windows 10 and thus ensure that some (few) prerequisites are fulfilled.
  • Install Dapr runtime in standalone mode
  • Configure Dapr for Kubernetes on Windows 10. Sounds like familiar!?
  • Clone the Dapr samples’ repo on GitHub.
  • Configure Visual Studio Code to explore these samples for learning Dapr.

To go smoothly through that above list, I prepare complete step-by-step instructions: Set up on Windows 10 a development environment for Dapr.

You can download the walkthrough and configure your environment accordingly.

If you do so, you should now be fully equipped to start exploring the various Dapr samples and thus to better grasp the value of Dapr.

Let’s consider the standalone mode.

A first touch with the standalone mode

In standalone mode, each running service has a Dapr runtime process which is configured to use state stores, pub/sub and binding components.

No alt text provided for this image

To explore this first mode, I prepare complete step-by-step instructions for the first sample Hello-World that comes with Dapr:

  1. Explore Dapr Hello World sample (Part 1).
  2. Explore Dapr Hello World sample (Part 2).

Likewise, you can download this walkthrough in two parts and play with the related sample.

Now that you've gotten Dapr running locally on your Windows 10 machine, you can continue your exploration with the Kubernetes mode.

A second touch with the Kubernetes mode

In Kubernetes mode, the dapr-sidecar-injector and dapr-operator services provide first class integration to launch Dapr as a sidecar container in the same pod as the service and provides notifications of Dapr component updates provisioned into the cluster.

No alt text provided for this image

Dapr can be used alongside any service mesh such as istio or linkerd. A service mesh is a dedicated network infrastructure layer designed to connect services to one another and provide insightful telemetry. A service mesh doesn’t introduce new functionality to the to an application runtime. That is where Dapr comes along and provide asynchronous pub-sub, binding and triggers to external system, stateful services, actors and distributed tracing.

Same can be said with auto-scalers such as Kubernetes-based Event Driven Autoscaling (KEDA), which provides event-driven scaling for containers running in Kubernetes (see blog post Kubernetes-based event-driven autoscaling (KEDA) 1.0 release). Dapr and KEDA work wonderfully together in a Kubernetes environment.

To explore this second mode, I also prepare complete step-by-step instructions to cope with the second sample Hello Kubernetes that comes with Dapr: Explore Dapr Hello Kubernetes sample.

It may now sound like a “ritual” with yet another walkthrough. Feel free to download it to dig into the related sample.

Once completed, you can theb explore on your own the additional samples Available. Each subsequent sample will cover more advanced concepts, such as service invocation, pub/sub, and state management. It includes instructions for running in both standalone and Kubernetes modes.

Last but not least, you can also follow on the repo the How To guides to understand how Dapr solves specific problems.

This concludes this article. I hope you’ve enjoyed this (short) "guided tour"!

Thanks, Philippe

2020-02-05 update: You can now download the guide Understanding and leveraging the Distributed Application Runtime (Dapr) – A starter guide for developers. This guide is part of the series New perspectives for cloud-native applications with the Open Application Model (OAM), and the Distributed Application Runtime (Dapr) I published on the Microsoft Download Center (https://aka.ms/CloudNativeAppsFuture).

2020-02-14 update: As you know, Dapr is currently under community development in alpha phase. (Dapr is thus NOT expected to be used for production workloads until its 1.0 stable release.) Consequently, you can thus expect continuous releases of new versions of the Dapr runtime as well as the Dapr Command Line Interface (CLI). As a direct illustration, Dapr 0.4.0 has been released yesterday. As stated on the Dapr repo, "this release of Dapr not only includes new components, security improvements, API level enhancements, new CLI features, stability and bug fixes, a richer Java SDK, docs and samples updates, but it also contains breaking changes." To upgrade from an older version of Dapr to 0.4.0, follow the instructions as per following walk-through: https://bit.ly/2SrZBcg.

要查看或添加评论,请登录

Philippe Beraud的更多文章

社区洞察

其他会员也浏览了