How-To: Enable preview features

How to specify and enable preview features

Overview

Preview features in Dapr are considered experimental when they are first released. These preview features require explicit opt-in in order to be used. The opt-in is specified in Dapr’s configuration.

Preview features are enabled on a per application basis by setting configuration when running an application instance.

Preview features

The current list of preview features can be found here.

Configuration properties

The features section under the Configuration spec contains the following properties:

PropertyTypeDescription
namestringThe name of the preview feature that is enabled/disabled
enabledboolBoolean specifying if the feature is enabled or disabled

Enabling a preview feature

Preview features are specified in the configuration. Here is an example of a full configuration that contains multiple features:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: featureconfig
  5. spec:
  6. tracing:
  7. samplingRate: "1"
  8. zipkin:
  9. endpointAddress: "http://zipkin.default.svc.cluster.local:9411/api/v2/spans"
  10. features:
  11. - name: Feature1
  12. enabled: true
  13. - name: Feature2
  14. enabled: true

Standalone

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:

  • Windows: %USERPROFILE%\.dapr\config.yaml
  • Linux/macOS: ~/.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:

  1. dapr run --app-id myApp --config ./previewConfig.yaml ./app

Kubernetes

In Kubernetes mode, the configuration must be provided via a configuration component. Using the same configuration as above, apply it via kubectl:

  1. 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. For example:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: nodeapp
  5. labels:
  6. app: node
  7. spec:
  8. replicas: 1
  9. selector:
  10. matchLabels:
  11. app: node
  12. template:
  13. metadata:
  14. labels:
  15. app: node
  16. annotations:
  17. dapr.io/enabled: "true"
  18. dapr.io/app-id: "nodeapp"
  19. dapr.io/app-port: "3000"
  20. dapr.io/config: "featureconfig"
  21. spec:
  22. containers:
  23. - name: node
  24. image: dapriosamples/hello-k8s-node:latest
  25. ports:
  26. - containerPort: 3000
  27. imagePullPolicy: Always

Last modified October 12, 2023: Update config.toml (#3826) (0ffc2e7)