Migrate with Diagrid-native tooling
With Diagrid-native tooling you create your Diagrid resources yourself — using the UI, CLI, or Terraform — then wire each workload to Diagrid. This requires a little more work than the Diagrid Kubernetes Operator but gives you more control over how you interact with and automate your project setup.
1. Create your Diagrid resources
Diagrid resources can be created imperatively using the CLI or web console, or declaratively using Terraform or YAML manifests. Pick the tooling that best fits how you manage infrastructure today.
- UI
- CLI
- Terraform
- Visit the Diagrid Web Console at catalyst.diagrid.io and create a new project.
- Create an app for each Dapr-enabled application. If you want to use local location, you must enable the
externalflag on the app. - Recreate each Dapr component using the components catalog and scope it to the relevant apps.
- Recreate any other pub/sub subscriptions, configurations, and resiliency policies in the console as well.
- If your app receives pub/sub messages, bindings, or actor invocations, configure the App Connection for each app so Diagrid can deliver them.
The fastest path is diagrid apply, which mirrors kubectl apply and accepts a directory of YAML resources. Authenticate and create the target project once:
diagrid login
diagrid project create my-project --wait --use
Apply your existing Dapr OSS Component, Subscription, Configuration, and Resiliency manifests. The manifests do not apply unchanged. Make these changes first:
- Namespace. Remove
metadata.namespacefrom every manifest.diagrid applyrejects a manifest that has one. - Secrets. Replace each
secretKeyRefin component metadata with a plaintextvalue. Diagrid extracts the value into a managed secret store on apply (see Managing secrets). Do not keep asecretKeyReftogether withauth.secretStore: kubernetes: the apply succeeds, but the component stays pending. - Kubernetes secret store. Delete the
secretstores.kubernetescomponent. Diagrid does not support it. See Secret stores. - Actor state store. Remove
actorStateStore: "true"from the state store component. Workflows and actors use the project's managed workflow store instead (see Connect your workloads).
diagrid apply --project my-project -f ./dapr-resources/
diagrid apply can report "created" for content that Diagrid then drops or cannot load: targets.actors in a Resiliency policy, a Configuration with a tracing endpoint inside your cluster, and a component with auth.secretStore: kubernetes. Check the result with diagrid project get my-project -a and in the console. See Dapr configuration compatibility.
You still need an App ID per workload, since Dapr OSS identifies apps via the dapr.io/app-id annotation rather than a CRD. Add them declaratively alongside your Dapr CRDs. Set appConfig to the name of the Dapr Configuration that the workload used through dapr.io/config. Without it, Diagrid applies the Configuration but attaches it to no App:
# ./dapr-resources/orders-appid.yaml
apiVersion: cra.diagrid.io/v1beta1
kind: AppIdentity
metadata:
name: orders
spec:
protocol: http
appEndpoint:
url: https://orders.example.com # where Diagrid calls your app (optional)
appConfig: appconfig # name of your Dapr Configuration, the replacement for the dapr.io/config annotation
external: true # only if using local location
diagrid apply -f does not descend into subdirectories, so keep these manifests beside the rest or pass the subdirectory as its own -f. A file it does not read is not reported.
Or create them imperatively:
diagrid app create orders --project my-project \
--endpoint https://orders.example.com \
--endpoint-token $APP_TOKEN \
--endpoint-protocol http \
--app-config appconfig
$APP_TOKEN is a value that you choose. It secures calls from the App to your endpoint. Set it before you run the command, for example export APP_TOKEN=$(openssl rand -hex 24). It is not the API token that Diagrid generates for the App.
diagrid app create sets the endpoint, the token that secures it, the protocol, and the Configuration. For local location, add --external. Note that this cannot be changed after the app is created. See External apps. In a public region, an App ID with external: true cannot run workflows or use the managed KV store and pub/sub. See Dapr Server location.
Plaintext secrets in component metadata are automatically extracted into a managed secret store on apply — see Managing secrets.
See the full CLI reference for every command and flag.
Use the Diagrid Terraform provider to model Diagrid resources alongside the rest of your infrastructure. Authenticate by setting DIAGRID_API_KEY (or passing api_key to the provider block).
terraform {
required_providers {
diagrid = {
source = "diagridio/diagrid"
}
}
}
provider "diagrid" {
api_key = var.diagrid_api_key
}
resource "diagrid_project" "my_project" {
name = "my-project"
}
resource "diagrid_appid" "orders" {
project_id = diagrid_project.my_project.name
name = "orders"
protocol = "http"
app_endpoint = {
url = "https://orders.example.com"
}
}
resource "diagrid_component" "orderstate" {
project_name = diagrid_project.my_project.name
name = "orderstate"
spec = {
type = "state.redis"
version = "v1"
metadata = [
{ name = "redisHost", value = "redis:6379" },
{
name = "redisPassword"
secret_key_ref = {
name = "redis-secret"
key = "password"
}
},
]
}
scopes = [diagrid_appid.orders.name]
}
The provider can't set external on an App ID. If you use local location, create those App IDs with the CLI or the Diagrid Console instead, and list them in scopes by name.
Connecting Diagrid to your app endpoints
Some Dapr APIs require the Dapr server to be able to call endpoints on your application, such as service invocation, actor invocations, input bindings or non-streaming pub/sub subscriptions. When using the Diagrid-native tooling, you will need to manually connect Diagrid to your workload's app endpoints.
For local location (external apps), you will be able to set the appEndpoint field on the app to point to the local address you app listens on e.g. http://localhost:8080.
For remote location, you need to expose your app to the Diagrid network and set the appEndpoint to that address.
If it is not possible to establish a direct connection, you may want to consider using the Diagrid Kubernetes Operator which automates establishing a secure tunnel between Diagrid and your app without requiring you to expose the app directly to the Diagrid network. A similiar technique can be achieved manually by installing the Diagrid CLI in your app container and setting the entry point command to:
diagrid dev run \
--project ${PROJECT_NAME} \
--id ${APP_ID} \
--app-port ${APP_PORT} \
--skip-managed-kv \
--skip-managed-pubsub \
--approve -- <your app command>
Remove --skip-managed-kv if you want to use the Diagrid managed key/value store. Remove --skip-managed-pubsub if you want to use the Diagrid managed pub/sub. A comment after a trailing \ ends the line continuation, so do not add one.
Set the env vars DIAGRID_API_KEY, DAPR_API_TOKEN, PROJECT_NAME, APP_ID, and APP_PORT. Two more requirements apply in a pod:
- Run as a non-root user. In Kubernetes,
diagrid dev rundoes not start Dapr as root. It printsDapr must be run as a non-root user in Kubernetes environmentsand stops. SetsecurityContext.runAsNonRoot: trueand arunAsUseron the container. - Give the user a writable home directory. Set the
HOMEenv var to a writable path, for example/tmp.
2. Connect your workloads
Remote: Diagrid manages the Dapr server
Rolling out in place replaces the Dapr OSS sidecar. A workflow that is still running on Dapr OSS does not resume on Diagrid. After the rollout its instance ID returns no such instance exists on Diagrid. Before you update a Deployment, stop starting new workflows, wait until the running ones finish, and record any scheduled jobs and reminders you must recreate. See Data migration for the steps.
On this route you replace the sidecar of the same Deployment, so Dapr OSS does not keep running beside Diagrid for that workload.
Before you roll out, make sure the project has a workflow store (the next section). Then update each Deployment:
- Remove the
dapr.io/*annotations and the Dapr OSS sidecar from the workload spec (deployment, statefulset, etc.). - Fetch the Diagrid Dapr HTTP/gRPC endpoints and API token for the corresponding app.
# Get the project endpoints
diagrid project get my-project -a
# Get the appid token
diagrid app get my-app --project my-project
Alternatively, you can find these in the Diagrid Console. With Terraform, you can also output the project endpoints from the http_endpoint and grpc_endpoint attributes of diagrid_project; get the App ID token from the CLI or the console.
-
Inject the Diagrid endpoints and token as environment variables into your workload spec, typically via a Kubernetes Secret:
Env var Value DAPR_HTTP_ENDPOINTProject HTTP endpoint DAPR_GRPC_ENDPOINTProject gRPC endpoint DAPR_API_TOKENApp API token -
Roll the workload out. The app now calls Diagrid over HTTP/gRPC; no sidecar runs in the pod.
Enable the workflow store
If your app uses workflows or actors, the project needs a workflow store. The managed workflow store is on by default for projects created with diagrid CLI 1.119.0 or later. With an older CLI, diagrid project create creates the project without it. Enable it with:
diagrid project update my-project --enable-managed-workflow
The store can take about 30 seconds to start serving after you enable it. Without a workflow store, the first workflow call fails with the state store is not configured to use the actor runtime. A migrated state store component with actorStateStore: "true" does not replace the workflow store if it points at a host inside your cluster, because Diagrid cannot reach that host.
Local: the Diagrid Dapr server runs as a app sidecar in your cluster
If you need to run Dapr in the app pod but don't want to use the Diagrid Kubernetes Operator, you can set it up manually.
For the full steps, with a CA, the container image, its environment variables and ports, see Run the sidecar yourself.
Your app keeps talking to localhost on the standard Dapr ports.
Next steps
Once your workloads are running on Diagrid, cut over your traffic and decommission Dapr OSS.