Integrate Dapr with OSM
Dapr OSM Walkthrough
This document walks you through the steps of getting Dapr working with OSM on a Kubernetes cluster.
-
Install Dapr on your cluster with mTLS disabled:
-
Dapr has a quickstart repository to help users get familiar with dapr and its features. For this integration demo we will be leveraging the hello-kubernetes quickstart. As we would like to integrate this Dapr example with OSM, there are a few modifications required and they are as follows:
-
The hello-kubernetes demo installs Dapr with mtls enabled (by default), we would not want mtls from Dapr and would like to leverage OSM for this. Hence while installing Dapr on your cluster, make sure to disable mtls by passing the flag :
--enable-mtls=false
during the installation -
Further hello-kubernetes sets up everything in the default namespace, it is strongly recommended to set up the entire hello-kubernetes demo in a specific namespace (we will later join this namespace to OSM’s mesh). For the purpose of this integration, we have the namespace as
dapr-test
-
The redis state store, redis.yaml, node.yaml and python.yaml need to be deployed in the
dapr-test
namespace -
Since the resources for this demo are set up in a custom namespace. We will need to add an rbac rule on the cluster for Dapr to have access to the secrets. Create the following role and role binding:
-
-
Ensure the sample applications are running with Dapr as desired.
-
-
Install OSM:
-
Enable permissive mode in OSM:
This is necessary, so that the hello-kubernetes example works as is and no SMI policies are needed from the get go.
-
Exclude kubernetes API server IP from being intercepted by OSM’s sidecar:
- Get the kubernetes API server cluster IP:
- Add this IP to the MeshConfig so that outbound traffic to it is excluded from interception by OSM’s sidecar
It is necessary to exclude the Kubernetes API server IP in OSM because Dapr leverages Kubernetes secrets to access the redis state store in this demo.
Note: If you have hardcoded the password in the Dapr component file, you may skip this step.
-
Globally exclude ports from being intercepted by OSM’s sidecar:
-
Get the ports of Dapr’s placement server (
dapr-placement-server
): -
Get the ports of your redis state store from the redis.yaml,
6379
incase of this demo -
Add these ports to the MeshConfig so that outbound traffic to it is excluded from interception by OSM’s sidecar
It is necessary to globally exclude Dapr’s placement server (
dapr-placement-server
) port from being intercepted by OSM’s sidecar, as pods having Dapr on them would need to talk to Dapr’s control plane. The redis state store also needs to be excluded so that Dapr’s sidecar can route the traffic to redis, without being intercepted by OSM’s sidecar.Note: Globally excluding ports would result in all pods in OSM’s mesh from not interceting any outbound traffic to the specified ports. If you wish to exclude the ports selectively only on pods that are running Dapr, you may omit this step and follow the step mentioned below.
-
-
Exclude ports from being intercepted by OSM’s sidecar at pod level:
-
Get the ports of Dapr’s api and sentry (
dapr-sentry
anddapr-api
): -
Update the pod spec in both nodeapp (node.yaml) and pythonapp (python.yaml) to contain the following annotation:
openservicemesh.io/outbound-port-exclusion-list: "80"
Adding the annotation to the pod excludes Dapr’s api (
dapr-api
) and sentry (dapr-sentry
) port’s from being intercepted by OSM’s sidecar, as these pods would need to talk to Dapr’s control plane. -
-
Make OSM monitor the namespace that was used for the Dapr hello-kubernetes demo setup:
-
Delete and re-deploy the Dapr hello-kubernetes pods:
The pythonapp and nodeapp pods on restart will now have 3 containers each, indicating OSM’s proxy sidecar has been successfully injected
-
Verify the Dapr hello-kubernetes demo works as expected:
-
Applying SMI Traffic Policies:
The demo so far illustrated permissive traffic policy mode in OSM whereby application connectivity within the mesh is automatically configured by
osm-controller
, therefore no SMI policy was required for the pythonapp to talk to the nodeapp.In order to see the same demo work with an SMI Traffic Policy, follow the steps outlined below:
-
Disable permissive mode:
-
Verify the pythonapp documented here no longer causes the order ID to increment.
-
Create a service account for nodeapp and pythonapp:
-
Update the role binding on the cluster to contain the newly created service accounts:
-
Apply the following SMI access control policies:
Deploy SMI TrafficTarget
Deploy HTTPRouteGroup policy
-
Update the pod spec in both nodeapp (node.yaml) and pythonapp (python.yaml) to contain their respective service accounts. Delete and re-deploy the Dapr hello-kubernetes pods
-
Verify the Dapr hello-kubernetes demo works as expected, shown here
-
-
Cleanup:
-
To clean up the Dapr hello-kubernetes demo, clean the
dapr-test
namespace -
To uninstall Dapr, run
-
To uninstall OSM, run
-
To remove OSM’s cluster wide resources after uninstallation, run the following command. See the uninstall guide for more context and information.
-
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.