One. What is Dapr

Official Overview: Dapr is a portable, event-driven runtime, it allows any developer can easily build a flexible, stateless and stateful applications, and can be run on the edge of the cloud platform or calculation, it also supports a variety of programming languages and development framework, Dapr can help you cope with the challenges of building micro service, And make your platform code insensitive.

The overview is a bit abstract, I would like to add:

  1. Dapr, which stands for Distributed Application Runtime, was opened by Microsoft in October 2019.
  2. Dapr uses sidecar architecture to provide services with infrastructure functions such as binding, subscription and publishing, and service discovery. Its API is invoked through HTTP and gRPC.
  3. To help developers get started quickly, the official SDK for major languages such as Go, Java, Python,.net is provided to make Dapr easy to use.

The Sidecar pattern is a design pattern that separates common application functions from applications as separate processes.

In the K8S environment, sidecar means that in the same POD, in addition to the container hosting the main business logic, there is also a secondary container called Sidecar, which provides some general function support.

1.1 What problems are solved

  1. Decouple the infrastructure from the business, providing the infrastructure in the form of delivery sidecars, allowing business-side development to focus on business logic.

  2. Solve the problem that large-scale upgrade of middleware SDK affects the development progress of the business side

  3. Resolve conflicts between infrastructure-related JAR packages and business-side JARS

1.2 Release History

A brief introduction

  1. In October 2019, version 0.1 of Dapr was released.
  2. On February 17, 2021, Dapr V1.0 was announced. From 114 contributors in October 2019 to 700 today, a more than six-fold increase in just 16 months.
  3. So far, release v1.5 is the fifth minor update to Dapr since release v1.0. It is worth noting that many new components were supported during this period, while unit testing, conformance testing, and so on were added to ensure stable components were provided.

For a detailed history, check out the official blog: blog.ddr.io /posts

2. Dapr function

  1. Service-to-service Invocation. Support for calls between services, including retry mechanism, load balancing by resolving component mDNS. The service invocation link is as follows:

  1. State Management. When the application needs to persist data, the corresponding key/value data is saved or updated to the state store component through the API, such as Redis and mysql. The service invocation link is as follows:

  2. Publish and subscribe. It is the process of message consumption by subscription service after publishing service publishes message. The service invocation link is as follows:

  1. Resource Bindings. If we call it event binding, you’ll get the idea. Bindings are divided into input bindings and output bindings. Input and output are relative to application.

    • Input bindings are external events that trigger the invocation of the application. For example, you call the file service for file processing, and when it’s done, you call back. A callback event is an input binding.
    • Output binding is when the application triggers an invocation event. Too many program errors, by sending email notification. Emailing is output binding.
  2. Actors. The Actor pattern states that Actors are the lowest level of “units of computation.” In other words, you write code to a separate unit (called an actor) that receives the message and processes it once, without any kind of parallel or threaded processing. Generally speaking, the performance of explicit locking in concurrent situations is poor, prone to error, resulting in deadlocks. The actor mode adopts the partition single thread mechanism to solve the concurrency problem more efficiently.

  3. Observability. It mainly includes three aspects: link tracing tracing, log management logging, and indicator management metrics.

  4. Secrets Management. Support for integration with public cloud and local Secret storage for retrieval use

  5. Configuration Management. Similar to Apollo, Nacos, Consul configuration center functions. Currently, official Demos based on Redis are as follows:

3. Dapr installation

3.1 Dapr Cli Installation

There are four official installation methods: Linux, Windows, MacOS, and Binaries.

Linux installation mode:

wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
Copy the code

If the Linux installation mode is not selected, the following error occurs during the installation:

How to solve it?

https://raw.githubusercontent.com/dapr/cli/master/install/install.sh - O v1.5.0 wget - q | / bin/bashCopy the code

Add this version number and you won’t get an error.

Of course, you have a choice

Binaries installation:

  1. The download file
Wget HTTP: / / https://github.com/dapr/cli/releases/download/v1.5.0/dapr_linux_amd64.tar.gzCopy the code
  1. Unzip the files
tar -zxvf dapr_linux_amd64.tar.gz
Copy the code
  1. Move a client to bin
mv dapr /usr/local/bin
Copy the code
  1. Init local dapr
dapr init
Copy the code
  1. Cli verification is successful
dapr --version
Copy the code
  1. Uninstall the cli
dapr uninstall && rm /usr/local/bin/dapr
Copy the code

3.2 K8S install DAPR

Select default K8S to install Dapr and run the following command

dapr init -k
Copy the code

But request api.github.com/repos/dapr/… It never worked out.

Select HELM mode to install Dapr

  1. Added HELM’s Dapr repository
helm repo add dapr https://dapr.github.io/helm-charts/
Copy the code
  1. Update helm warehouse
helm repo update
Copy the code
  1. Example Query the version of warehouse Dapr
helm search repo dapr --devel --versions 
Copy the code
  1. Example Create a namespace for the K8S
kubectl create namespace dapr-system
Copy the code
  1. Install the corresponding version of Dapr
Helm Upgrade -- Install DAPR DAPR/dapR --version=1.5.0 -- Namespace dapar-system --waitCopy the code
  1. Verify whether the installation is successful in K8S. All STATUS is Running, indicating that the installation is successful
kubectl get pods --namespace dapr-system
Copy the code

  1. Helm uninstall Dapr
helm uninstall dapr --namespace dapr-system
Copy the code

4. Summary

This is the introduction to Dapr, the functions of Dapr, and the installation of Dapr. In the future, WE will explain Dapr functions in the form of Java demo.

Reference document: docs.dabr.io /

Recommended reading

DS version control core principles revealed

DS 2.0 era API operation posture

Process and optimization of a search performance

Kubernetes Scheduler source code parsing and custom resource scheduling algorithm practice

, recruiting

Zhengcaiyun Technology team (Zero) is a passionate, creative and executive team based in picturesque Hangzhou. The team has more than 300 r&d partners, including “old” soldiers from Alibaba, Huawei and NetEase, as well as newcomers from Zhejiang University, University of Science and Technology of China, Hangzhou Electric And other universities. Team in the day-to-day business development, but also in cloud native, chain blocks, artificial intelligence, low code platform system, middleware, data, material, engineering platform, the performance experience, visualization technology areas such as exploration and practice, to promote and fell to the ground a series of internal technical products, continue to explore new frontiers of technology. In addition, the team is involved in community building, Currently, There are Google Flutter, SciKit-Learn, Apache Dubbo, Apache Rocketmq, Apache Pulsar, CNCF Dapr, Apache DolphinScheduler, and Alibaba Seata and many other contributors to the excellent open source community. If you want to change something that’s been bothering you, want to start bothering you. If you want to change, you’ve been told you need more ideas, but you don’t have a solution. If you want change, you have the power to make it happen, but you don’t need it. If you want to change what you want to accomplish, you need a team to support you, but you don’t have the position to lead people. If you want to change the original savvy is good, but there is always a layer of fuzzy window…… If you believe in the power of believing, believing that ordinary people can achieve extraordinary things, believing that you can meet a better version of yourself. If you want to be a part of the process of growing a technology team with deep business understanding, sound technology systems, technology value creation, and impact spillover as your business takes off, I think we should talk. Any time, waiting for you to write something and send it to [email protected]

Wechat official account

The article is published synchronously, the public number of political cloud technology team, welcome to pay attention to