For more information about service invocation see the Dapr docs
To run this demo in Dapr, run:
dapr run \
--app-id http-service-demo \
--app-port 8080 \
--app-protocol http \
--dapr-http-port 3500 \
--components-path ./config \
go run main.go
Deploy and wait for the pod to be ready
kubectl apply -f deployment.yaml
kubectl rollout status deployment/http-echo-service
If you have changed an existing component, make sure to reload the ingress and wait until the new version is ready
kubectl rollout restart deployment/nginx-ingress-nginx-controller
kubectl rollout status deployment/nginx-ingress-nginx-controller
Follow logs
kubectl logs -l app=http-echo-service -c service -f
In a separate terminal session export API token
export API_TOKEN=$(kubectl get secret dapr-api-token -o jsonpath="{.data.token}" | base64 --decode)
And invoke the service
curl -d '{ "message": "ping" }' \
-H "Content-type: application/json" \
-H "dapr-api-token: ${API_TOKEN}" \
"https://api.cloudylabs.dev/v1.0/invoke/http-echo-service/method/echo"
The response should include the sent message
{
"message": "ping"
}
And the logs
Invocation (ContentType:application/json, Verb:POST, QueryString:map[], Data:{ "message": "ping" })
This is my personal project and it does not represent my employer. While I do my best to ensure that everything works, I take no responsibility for issues caused by this code.
This software is released under the MIT