To run this example on Kubernetes, you can use any Kubernetes distribution.
We install Dapr on a Kubernetes cluster and then we will deploy both the orders-api and dukebox.
If you don't have any Kubernetes cluster you can use Kubernetes KIND to create a local cluster. We will create a cluster with a local container registry, so we can push our container images to it. This is covered in the KIND documentation here.
./kind-with-registry.shNote: If you are using Podman Desktop, instead of Docker you need to run the following command to enable insecure registries:
read -r -d '' registry_conf <<EOF
[[registry]]
location = "localhost:5001"
insecure = true
EOF
podman machine ssh --username=root sh -c 'cat > /etc/containers/registries.conf.d/local.conf' <<<$registry_confOnce you have the cluster up and running you can install Dapr:
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
helm upgrade --install dapr dapr/dapr \
--version=1.16.0-rc.3 \
--namespace dapr-system \
--create-namespace \
--waitNow that we have our cluster set up with a local container registry, we need to build our orders-api and dukebox containers.
For this we will use Quarkus Container Image Buildpack extension, it functions to create container images using Buildpacks:
From inside the orders-api directory you can run the following command to create a container:
./mvnw clean packageOnce we have the container image created, we need to tag and push to the local registry, so the image can be used from our local cluster. Alternatively, you can push the images to a public registry and update the Kubernetes manifests accordingly.
docker tag localhost:5001/dapr/orders-api:0.1.0 localhost:5001/dapr/orders-api
docker push localhost:5001/dapr/orders-apiNote: for Podman you need to run:
podman push localhost:5001/orders-api --tls-verify=falseFrom inside the delivery-api directory you can run the following command to create a container:
./mvnw clean packageOnce we have the container image created, we need to tag and push to the local registry, so the image can be used from our local cluster. Alternatively, you can push the images to a public registry and update the Kubernetes manifests accordingly.
docker tag localhost:5001/dapr/delivery-api:0.1.0 localhost:5001/dapr/delivery-api
docker push localhost:5001/dapr/delivery-apiNote: for Podman you need to run:
podman push localhost:5001/delivery-api --tls-verify=falseFrom inside the app directory you can run the following command to create a container:
./mvnw clean packageOnce we have the container image created, we need to tag and push to the local registry, so the image can be used from our local cluster.
Alternatively, you can push the images to a public registry and update the Kubernetes manifests accordingly.
docker tag localhost:5001/dapr/dukebox:0.1.0 localhost:5001/dapr/dukebox
docker push localhost:5001/dapr/dukeboxNote: for Podman you need to run:
podman push localhost:5001/dukebox --tls-verify=falseNow we are ready to install our application into the cluster.
Now that we have a running Kubernetes cluster, we need to first install the components needed by the application. In this case RabbitMQ and PostgreSQL. We will use Helm to do so:
Let's start with RabbitMQ:
helm install rabbitmq oci://registry-1.docker.io/bitnamicharts/rabbitmq --set auth.username=guest --set auth.password=guest --set auth.erlangCookie=ABC --set image.repository=bitnamilegacy/rabbitmq --set global.security.allowInsecureImages=trueThen PostgreSQL:
helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --set global.postgresql.auth.database=dapr --set global.postgresql.auth.postgresPassword=passwordAfter, install Jaeger All-in-One:
helm repo add jaeger-all-in-one https://raw.githubusercontent.com/hansehe/jaeger-all-in-one/master/helm/charts
helm install jaeger-all-in-one jaeger-all-in-one/jaeger-all-in-one --set enableHttpOpenTelemetryCollector=trueThe enableHttpOpenTelemetryCollector=true is necessary because we will use the OpenTelemetry Collector endpoint on Tracing configuration.
Once we have these components up and running we can install the application by running from inside
the k8s/dapr directory:
kubectl apply -f k8s/daprNext you need to use kubectl port-forward to be able to send requests to the applications.
kubectl port-forward svc/dukebox 8080:8080Access the DukeBox application at http://localhost:8080.
In a different terminals you can check the logs of the orders-api, delivery-api and dukebox:
For orders-api app:
kubectl logs -f orders-api-<POD_ID>For dukebox app:
kubectl logs -f dukebox-<POD_ID>And for delivery-api app:
kubectl logs -f delivery-api-<POD_ID>Access your browser at http://localhost:9411.
Viewing tracing:
kubectl port-forward svc/jaeger-all-in-one 16686:16686