0

I'm doing some tests with Dapr that are not working, the scenario is not very common (for the moment it's just a few tests). It is that a Web App deployed in Azure uses a Dapr sidecar that is also located in azure, but that does not run, let's say, in the same "network". In this case, the sidecar is a deployment/service in AKS. In the Dapr documentation I haven't seen any impediment for an application and its sidecar to communicate via internet (yes, I know it's a weird scenario). Is this the case? That is to say, is it true that in theory there is no impediment to do this?

The deployment of the Sidecar is as follows.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dapr-sidecar
spec:
  selector:
    matchLabels:
      app: dapr-sidecar
  replicas: 1
  template:
    metadata:
      labels:
        app: dapr-sidecar
    spec:
      containers:
        - name: daprd
          image: "daprio/daprd:latest"
          imagePullPolicy: Always
          command:
            - "./daprd"
          args:
            - "--app-id"
            - "daprtestbackend"
            - "--app-port"
            - "80"
            - "--dapr-grpc-port"
            - "50001"
            - "--dapr-http-port"
            - "8078"
            - "--components-path"
            - "/components"
            - "--log-level"
            - "debug"
          volumeMounts:
            - name: components-volume
              mountPath: /components
          ports:
            - containerPort: 50001
              name: grpc-port
            - containerPort: 8078
              name: http-port
      volumes:
        - name: components-volume
          configMap:
            name: dapr-components
---
apiVersion: v1
kind: Service
metadata:
  name: dapr-sidecar-service
spec:
  selector:
    app: dapr-sidecar
  ports:
    - name: grpc
      port: 50001
      targetPort: 50001
    - name: http
      port: 8078
      targetPort: 8078
  type: LoadBalancer

On the web application side, I basically do the following:

// Here I basically put the IP of the AKS Service (load balancer type) and the port that 
// I have configured there, I have tried with HTTP, gRPC etc...
const string httpEndPoint = "http://{SERVICE_SIDECAR}:{PORT}";
builder.Services.AddDaprClient(options =>
{
    options.UseHttpEndpoint(httpEndPoint);
});
...
...
// Dapr will send a serialized event object instead of a raw CloudEvent.
app.UseCloudEvents();

// required for Dapr's pub/sub routing.
app.MapSubscribeHandler();

// Dapr subscription in [Topic] routes topic requests to this path
app.MapPost("/jobs", [Topic("jobpubsub", "jobs")] (Job job) => {
    Console.WriteLine("Call to /jobs");
    /Register the job
    Console.WriteLine("Subscriber received : " + job);
    return Results.Ok(job);
});

...

I have tried with gRPC, HTTP, but there is no way to get messages.... any advice?

1 Answers1

0

This is not a weird scenario at all. I created this sandbox project for the same reason as you are describing here:

https://github.com/dapr-sandbox/dapr-ambient

This right now is a simple approach of running the sidecar as a separate deployment/deamonset that your applications can connect to. The idea here is to push this prototype to support multiple applications to connect to the same ambient, but that is still not working yet, as we need to create a proposal to define how we can make that happen.

From your deployment definition I think you are missing this parameter: https://github.com/dapr-sandbox/dapr-ambient/blob/main/chart/dapr-ambient/templates/daemonset.yaml#L74

--dapr-listen-addresses=0.0.0.0

Which we are using in Dapr-Ambient. Let me know if you want to collaborate on making Dapr-Ambient work for your use case, as having a community-driven approach is much better than maintaining your inhouse solution.

Hope this helps. Cheers

salaboy
  • 4,123
  • 1
  • 14
  • 15