This example demonstrates how to perform local development with Dapr, Skaffold, and Diagrid Conductor. It covers:
- Mocking Dapr client and unit testing applications.
- Running multiple applications with Dapr multi-app run.
- Deploying applications to a local Kubernetes cluster with Skaffold, and observing real-time redeployment for application code changes or Dapr CRD changes.
For a detailed step by step write, check out the blog post walking through these project steps.
To install Kubernetes on macOS, use the following commands:
brew install minikube
minikube start
Follow the steps in the quickstart guide and apply your unique cluster connection token:
kubectl apply -f "YOUR_UNIQUE_CLUSTER_CONNECTION_TOKEN"
To install Skaffold, use the following command:
brew install skaffold
Install Redis using Helm:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install redis bitnami/redis --set cluster.enabled=false --set replica.replicaCount=0 --set fullnameOverride=dapr-dev-redis
This project comprises a Java app that publishes messages to Redis and another Java app that consumes these messages.
Clone the repository:
git clone git@github.com:bibryam/dapr-skaffold.git
cd dapr-skaffold
Build the Java applications and run unit tests:
mvn clean install
Use Dapr CLI to run a single application with a sidecar:
dapr run --app-id publisher --app-port 5001 --resources-path ./common/local -- java -jar publisher/target/Publisher-0.0.1-SNAPSHOT.jar
Run both applications at the same time with multi-app run:
dapr run -f dapr.yaml
To deploy the application, run:
skaffold dev
Update the application YAML files or modify the Java code followed by a Maven build. The changes will be detected and redeployed automatically.
Publish a single order by calling the Publisher application:
curl -X POST http://localhost:5001/pubsub/orders \
-H "Content-Type: application/json" \
-d @order.json
Or use Dapr CLI to publish an order directly to the pubsub:
dapr publish --publish-app-id publisher --pubsub pubsub --topic orders --data '{"orderId": "123"}'
brew install httpd
ab -n 100 -c 100 -p order.json -T "application/json" http://localhost:5001/pubsub/orders
ab -n 100 -c 100 -p order.json -T "application/json" http://localhost:3501/v1.0/publish/pubsub/orders