Migrate with the Diagrid Kubernetes Operator
The Diagrid Kubernetes Operator is a Kubernetes-native way to migrate your workloads from Dapr OSS. It can read your existing Dapr resources directly from Kubernetes and only requires you to migrate from the dapr.io annotations to the catalyst.diagrid.io annotations. It configures Diagrid for you and integrates your workloads, but some apps need steps from you before and after you run it. A workflow app needs its in-flight workflows drained first, and a component that reads a Kubernetes secret needs a plaintext value. See Before you migrate.
Before you migrate
Do these steps before you run diagrid k8s-operator migrate.
Drain in-flight workflows
If your app runs Dapr workflows, drain them first. When you migrate a namespace in place, the migration stops every in-flight workflow at once. The workflows do not show on Diagrid. The Dapr OSS Scheduler keeps their timers, but nothing runs them.
- Stop starting new workflows on Dapr OSS.
- Wait until the running workflows finish. For example, run
dapr workflow listand check that no instance is still running. - Migrate.
Migrating into a copy with --new-namespace does not stop the workflows in the original namespace, but they still do not resume on Diagrid. See Cut over and decommission Dapr OSS for what does not carry over.
Replace secretKeyRef with a plaintext value
Diagrid has no way to read a Kubernetes secret that a component references. If a component has a secretKeyRef in its metadata, replace it with a plaintext value before you migrate. Diagrid extracts the sensitive value into a managed secret store, so the plaintext is not kept in the control plane. See Components that reference a secret.
1. Deploy the operator
The operator's mutating webhook needs a serving certificate, and by default the chart has cert-manager issue it. Install cert-manager before the operator, and pin its version. Recent cert-manager releases do not install on older Kubernetes versions: on Kubernetes 1.29, cert-manager v1.21.3 rejects four of its own CRDs. Version v1.17.2 works on Kubernetes 1.29:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.2/cert-manager.yaml
kubectl wait --for=condition=Available -n cert-manager deploy --all --timeout=120s
The CLI checks that cert-manager is present before it installs anything, and stops with install commands if it is missing. Plain Helm does not check, so on the Helm tab below the install fails part-way with a resource mapping error for Certificate in cert-manager.io/v1 instead of telling you what to install.
Already managing the webhook certificate yourself? Pass --set webhook.certManager.enabled=false and the chart renders no cert-manager resources.
- CLI
- Helm
You can use the Diagrid CLI to install the Diagrid Kubernetes Operator Helm chart into your cluster.
diagrid k8s-operator install
You can also override the Helm values using the --set flag:
diagrid k8s-operator install --set some.helm.value=foo
The chart also installs the Dapr CRDs, which on this migration path your Dapr open source installation already owns. The CLI checks the cluster before it installs and turns them off for you when it finds them, so diagrid k8s-operator install works whether or not Dapr is present. To decide yourself instead, set the value explicitly — --set dapr.installCRDs=false never installs them, --set dapr.installCRDs=true always does, and either choice is left untouched:
diagrid k8s-operator install --set dapr.installCRDs=false
To uninstall the Diagrid Kubernetes Operator, run:
diagrid k8s-operator uninstall
diagrid k8s-operator uninstall does not restore Dapr OSS, and it does not undo migrate. To go back to Dapr OSS, see Roll back to Dapr OSS.
You can directly use Helm to install the Diagrid Kubernetes Operator into your cluster. On a cluster that already runs Dapr open source, add --set dapr.installCRDs=false:
helm install catalyst-operator oci://public.ecr.aws/diagrid/catalyst-operator \
--namespace catalyst-system --create-namespace \
--set dapr.installCRDs=false
Helm does not check the cluster the way the CLI does. Without that flag the install fails before it creates anything, because the Dapr CRDs already exist and belong to your Dapr installation rather than to this Helm release:
Unable to continue with install: CustomResourceDefinition "components.dapr.io" in
namespace "" exists and cannot be imported into the current release: invalid
ownership metadata; label validation error: missing key
"app.kubernetes.io/managed-by": must be set to "Helm"
Leave the flag out only on a cluster that has never had Dapr installed, where nothing else registers the dapr.io types.
You can uninstall the Diagrid Kubernetes Operator with:
helm uninstall catalyst-operator --namespace catalyst-system
See the Helm chart reference for the full list of values you can set on the chart.
2. Migrate resources
You can use the Diagrid CLI to automatically migrate an existing namespace or you can manually annotation your workloads and Dapr resources within a namespace.
Add the annotations with the CLI
You can migrate a namespace in-place, which will update the annotations and sidecar on your existing workloads and CRDs to use Diagrid instead of Dapr OSS.
diagrid k8s-operator migrate my-namespace --project my-project
Or you can copy your existing namespace to a new one and only update the copy, leaving the original namespace untouched.
diagrid k8s-operator migrate my-namespace --project my-project \
--new-namespace my-namespace-copy
We recommend using --new-namespace on any real use cases to ensure you can validate the migrated workloads before removing the existing workloads. If your app runs workflows, drain them before you migrate in place.
migrate writes the annotations onto the pod template, which Kubernetes treats as a change to the Deployment. Your pods are replaced by a rolling update as soon as the command finishes — that is when the Dapr OSS sidecar goes and the Diagrid one arrives. You do not need to restart anything yourself.
Migrating in place therefore restarts the running workload. With --new-namespace the restart happens in the copy, and the original is left alone, which is the other reason to prefer it.
If you want to use local Dapr Servers, you must add the --host local flag to the migrate command:
diagrid k8s-operator migrate my-namespace --project my-project \
--host local
In a public region, a local Dapr server cannot run workflows or use the managed KV store and pub/sub. See Dapr Server location before you choose it.
Add the annotations manually
You can also manually apply the necessary catalyst.diagrid.io annotations to your workloads and Dapr resources.
Workloads
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders
spec:
template:
metadata:
annotations:
catalyst.diagrid.io/enabled: "true"
catalyst.diagrid.io/app-id: "orders"
catalyst.diagrid.io/provider: "catalyst" # tells the Diagrid operator to claim this pod
catalyst.diagrid.io/project: "my-project" # which Diagrid project to register against
catalyst.diagrid.io/host: "remote" # or "local" to inject the sidecar
catalyst.diagrid.io/app-port: "8080" # optional
catalyst.diagrid.io/app-protocol: "grpc" # optional
catalyst.diagrid.io/host is the switch between remote and local location. The operator reads only the annotations listed above — any dapr.io/* annotations on the pod are ignored. To prevent the Dapr OSS operator from also acting on the pod, the Diagrid operator disables the dapr.io/enabled annotation whenever catalyst.diagrid.io/enabled is present, so you don't get conflicting sidecars. The diagrid k8s-operator migrate command goes further: it sets dapr.io/enabled to "false" and deletes every other dapr.io/* annotation from the pod template.
Dapr resources
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: orderstate
annotations:
catalyst.diagrid.io/project: "my-project"
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: redis:6379
CRDs without catalyst.diagrid.io/project are left alone, which is useful for keeping in-cluster Dapr OSS resources side-by-side with Diagrid-managed ones during a phased migration.
Run the Dapr server in your pods (local)
With catalyst.diagrid.io/host: "local", the operator runs the Dapr server as a sidecar container in your pod instead of in Diagrid. The app it creates is an external app. The operator takes care of the setup that running the sidecar yourself needs. When a pod is created, it:
- Creates the external app in your project, if it doesn't exist yet. An app's location can't change after it's created, so the operator refuses a
localworkload whose app already exists asremote, and the other way round. To switch, delete the app first. - Waits for the app's bootstrap config, and stores it in a Secret named
catalyst-bootstrap-<app-id>in the workload's namespace, together with the certificate authority (CA) the sidecar issues its certificates from. - Adds a sidecar container named
daprdto the pod. - Sets
DAPR_HTTP_ENDPOINT(http://localhost:3500),DAPR_GRPC_ENDPOINT(localhost:50001) andDAPR_API_TOKENon your app's containers, so Dapr SDKs find the sidecar without changes. - Creates a Service named
<app-id>-dapr, which other sidecars use for service invocation.
The certificate authority
On its first start, the operator creates a root and an issuer CA and stores them in the Secret catalyst-operator-issuer in its own namespace. It uses that CA for every local sidecar.
To use your own CA instead, create the Secret before you install the operator, with these keys:
| Key | Contents |
|---|---|
ca.crt | The root CA certificate |
tls.crt | The issuer certificate, signed by the root |
tls.key | The issuer private key |
kubectl create namespace catalyst-system --dry-run=client -o yaml | kubectl apply -f -
kubectl create secret generic catalyst-operator-issuer --namespace catalyst-system \
--from-file=ca.crt=trust-anchors.pem \
--from-file=tls.crt=issuer.pem \
--from-file=tls.key=issuer-key.pem
To create these files, follow Create a certificate authority. To use a different Secret name or namespace, set dapr.issuer.secretName and dapr.issuer.secretNamespace when you install the operator.
Sidecar annotations
These optional annotations change the sidecar's ports. Set them when they clash with ports your app uses.
| Annotation | Default | What it sets |
|---|---|---|
catalyst.diagrid.io/app-port | none | The port your app listens on. The sidecar delivers inbound calls to http://localhost:<app-port>. |
catalyst.diagrid.io/probes-port | 39091 | The port of the sidecar's readiness endpoint, /ready. |
catalyst.diagrid.io/metrics-port | 9091 | The port of the sidecar's own metrics. Dapr metrics stay on 9090. |
The sidecar also listens on 3500, 3501, 50001, 50002 and 9090, so your app must not use those ports and you must leave these open on the pod. The operator adds prometheus.io/* annotations to the pod that point at the Dapr metrics on port 9090.
Roll back to Dapr OSS
diagrid k8s-operator uninstall does not put Dapr OSS back. To return a migrated Deployment to Dapr OSS, roll the Deployment back to the revision from before the migration, and keep the Dapr OSS control plane installed until you are sure:
kubectl rollout history deployment/<name> --namespace <namespace>
kubectl rollout undo deployment/<name> --namespace <namespace> --to-revision=<revision before migrate>
The rolled-back pods use the Dapr OSS sidecar again. Timers that the Dapr OSS Scheduler held during the migration then fire.
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, input bindings or programmatic pub/sub subscriptions. When using the Diagrid Kubernetes Operator, all you need to do is ensure you have the following annotation:
catalyst.diagrid.io/app-port: "8080" # or whatever port your app listens on
For remote Dapr servers, the operator will establish a secure tunnel between Diagrid and your app so that traffic can flow without you having to expose the app directly to the Diagrid network.
For local Dapr servers (external apps), the operator will set the app's appEndpoint to http://localhost:<app-port> and the sidecar will route traffic from Diagrid to your app over localhost.
Next steps
- To see every step on a local cluster first, follow the migration quickstart.
- Once your workloads are running on Diagrid, cut over your traffic and decommission Dapr OSS.