Debug daprd on Kubernetes

    Sometimes it is necessary to understand what’s going on in the Dapr sidecar (daprd), which runs as a sidecar next to your application, especially when you diagnose your Dapr application and wonder if there’s something wrong in Dapr itself. Additionally, you may be developing a new feature for Dapr on Kubernetes and want to debug your code.

    his guide will cover how to use built-in Dapr debugging to debug the Dapr sidecar in your Kubernetes pods.

    • Refer to this guide to learn how to deploy Dapr to your Kubernetes cluster.
    • Follow to build the Dapr debugging binaries you will be deploying in the next step.

    If Dapr has already been installed in your Kubernetes cluster, uninstall it first:

    First configure a values file named with these options:

    1. global:
    2. registry: docker.io/<your docker.io id>
    3. tag: "dev-linux-amd64"

    Then step into ‘dapr’ directory from your cloned dapr/dapr repository and execute the following command:

    To enable debug mode for daprd, you need to put an extra annotation dapr.io/enable-debug in your application’s deployment file. Let’s use as an example. Modify ‘deploy/node.yaml’ like below:

    1. index 23185a6..6cdb0ae 100644
    2. --- a/hello-kubernetes/deploy/node.yaml
    3. @@ -33,6 +33,7 @@ spec:
    4. dapr.io/enabled: "true"
    5. dapr.io/app-id: "nodeapp"
    6. dapr.io/app-port: "3000"
    7. + dapr.io/enable-debug: "true"
    8. spec:

    Deploy the application with the following command. For the complete guide refer to the Dapr Kubernetes Quickstart:

    Figure out the target application’s pod name with the following command:

    1. $ kubectl get pods
    2. NAME READY STATUS RESTARTS AGE
    3. nodeapp-78866448f5-pqdtr 1/2 Running 0 14s

    Then use kubectl’s port-forward command to expose the internal debug port to the external IDE: