Some features in Dapr are considered experimental when they are first released. These features require explicit opt-in in order to be used. The opt-in is specified in Dapr’s configuration.
Currently, preview features are enabled on a per application basis when running on Kubernetes. A global scope may be introduced in the future should there be a use case for it.
Below is a list of existing preview features:
The features
section under the Configuration
spec contains the following properties:
属性 | 数据类型 | 说明 |
---|---|---|
name | string | The name of the preview feature that will be enabled/disabled |
enabled | bool | Boolean specifying if the feature is enabled or disabled |
Preview features are specified in the configuration. Here is an example of a full configuration that contains multiple features:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: featureconfig
spec:
tracing:
samplingRate: "1"
zipkin:
endpointAddress: "http://zipkin.default.svc.cluster.local:9411/api/v2/spans"
features:
- name: Feature1
enabled: true
- name: Feature2
enabled: true
To enable preview features when running Dapr locally, either update the default configuration or specify a separate config file using dapr run
.
The default Dapr config is created when you run dapr init
, and is located at:
%USERPROFILE%\.dapr\config.yaml
~/.dapr/config.yaml
Alternately, you can update preview features on all apps run locally by specifying the --config
flag in dapr run
and pointing to a separate Dapr config file:
dapr run --app-id myApp --config ./previewConfig.yaml ./app
In Kubernetes mode, the configuration must be provided via a configuration component. Using the same configuration as above, apply it via kubectl
:
kubectl apply -f previewConfig.yaml
This configuration component can then be referenced in any application by modifying the application’s configuration to reference that specific configuration component via the dapr.io/config
element. 例如:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodeapp
labels:
app: node
spec:
replicas: 1
selector:
matchLabels:
app: node
template:
metadata:
labels:
app: node
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "nodeapp"
dapr.io/app-port: "3000"
dapr.io/config: "featureconfig"
spec:
containers:
- name: node
image: dapriosamples/hello-k8s-node:latest
ports:
- containerPort: 3000
imagePullPolicy: Always