当前位置:网站首页>Dapr source code analysis | project overview

Dapr source code analysis | project overview

2022-06-09 16:09:00 Wind god Shura envoy

Source code selection of this article dapr 1.4.3 https://github.com/zcong1993/dapr-1/tree/learn-1.4.3

Concepts

 Insert picture description here
overall , dapr It can be divided into several concepts :

Building blocks Building blocks

dapr Provide users with HTTP/gRPC API, By one or more component form .

for example : Secrets Modules provide access to users secrets Of API.

#  Get a single  secret
GET http://localhost:<daprPort>/v1.0/secrets/<secret-store-name>/<name>
#  Batch acquisition 
GET http://localhost:<daprPort>/v1.0/secrets/<secret-store-name>/bulk

Components modular

dapr Generalized modules abstracted for building blocks and applications .

for example : Secret Stores Components are provided externally secret Read service .

type SecretStore interface {
    
  // Init authenticates with the actual secret store and performs other init operation
  Init(metadata Metadata) error
  // GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
  GetSecret(req GetSecretRequest) (GetSecretResponse, error)
  // BulkGetSecrets retrieves all secrets in the store and returns a map of decrypted string/string values
  BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
}

Support Kubernetes, Hashicorp Vault, Azure KeyVault Many other kinds provider.

Configuration

organization dapr Various configurations required for operation , It is mainly divided into : Global configuration , Module configuration and runtime configuration .

Observability Observability

dapr Observability module , External provision logging, metrics, tracing Equal index .

Security

dapr Safety related , for example : Service room mTLS encryption .

Services

dapr Provided by the project cli app. From project entrance cmd Folders can also be seen :

cmd
├── daprd //  The core  runtime,  Key points for subsequent source code reading 
├── injector // k8s dapr sidecar  injector 
├── operator // k8s operator
├── placement // actor  relevant 
└── sentry // mTLS   relevant 

Running environment

dapr Two operation modes are supported , Namely : Independent operation and k8s function .

Self-hosted

In this mode , daprd As a sidecar The process runs in each of your app side , Yours app Can pass HTTP/gRPC Interact with it . The configuration file will be stored locally . Runtime configuration requires the use of flag Pass on .
 Insert picture description here

Kubernetes

stay k8s in , daprd As a sidecar The container runs on your app pod in , And all this is dapr-sidecar-injector and dapr-operator Help you automatically complete . The configuration file also uses k8s crd Form management , The running configuration can be configured through k8s annonation To configure the .
 Insert picture description here

原网站

版权声明
本文为[Wind god Shura envoy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091540398473.html