prom3theu5 / aspirational-manifests

Handle deployments of .NET Aspire AppHost Projects
MIT License
702 stars 36 forks source link

Issue deploying Dapr Components (statestore using redis) #243

Open spicycoder opened 4 months ago

spicycoder commented 4 months ago

🔥 Bug Description

Dapr state store (redis) when deployed using aspirate, is not recognized by application's sidecar

🔍 Steps to Reproduce the Bug

Refer the repo: https://github.com/spicycoder/Despirate I have a simple Aspire + Dapr application Trying to save (and read) state into dapr state store

    [HttpPost("save")]
    public async Task<ActionResult<Product>> Save([FromBody] Product product)
    {
        logger.LogInformation("Saving product: {Product}", product);

        await daprClient.SaveStateAsync(
            "statestore",
            product.Id.ToString(),
            product);

        return Ok(product);
    }

I have components/statestore.yaml, content below

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: statestore
spec:
  type: state.redis
  version: v1
  metadata:
    - name: redisHost
      value: localhost:6500
    - name: redisPassword
      value: ""
    - name: actorStateStore
      value: "true"
    - name: keyprefix
      value: none

And the AppHost's Program.cs file looks like

var redis = builder.AddRedis("redis", 6500);

var statestore = builder.AddDaprStateStore(
    "statestore",
    new DaprComponentOptions
    {
        LocalPath = Path.Combine("..", "components", "statestore.yaml")
    });

var api = builder
    .AddProject<Projects.AspireApp_API>("api")
    .WithDaprSidecar()
    .WithReference(statestore);

But aspirate generate produces dapr/statestore.yaml as below, which appears to be different from components/statestore.yaml

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: statestore
  labels:
    app: statestore
spec:
  type: state
  version: v1
  metadata: []

When I perform aspirate apply (tried both, generated statestore.yaml as well as replacing it with content from components/statestore.yaml) The application's sidecar could not reach dapr statestore

Can someone explain if I am doing something wrong here? Thanks