The Dapr Kubernetes Operator manages the lifecycle for Dapr and its components.
The operator's goal is to automate the tasks required when operating a Dapr running in Kubernetes Mode.
The Dapr Kubernetes Operator was created with the intention of running through the Operator Lifecycle Manager,
specifically on OpenShift 4. This is where the operator shines most, as it leverages the powerful
features built into the latest version of OpenShift.
That being said, the operator can be installed and provide the same functionality on any Kubernetes cluster. The following methods are provided for installing the operator.
The operator is published as part of the built-in Community Operators in the Operator Hub on OpenShift 4. See the OpenShift Install Guide for more information on installing on the OpenShift platform.
Using the Operator Lifecycle Manager to install and manage the Dapr Kubernetes Operator is the preferred method. The operator
is published to operatorhub.io. Following the installation process there should work for most OLM
installations.
Look at the OLM Install Guide for an example using this approach with minikube.
The operator can be installed manually if desired.
Important
The manual installation method requires cluster credentials that provide the cluster-admin ClusterRole or equivalent.
The Manual Installation Guide provides the steps needed to manually install the operator on any Kubernetes cluster.
The following example shows the most minimal valid manifest to create a new Dapr instance:
apiVersion: operator.dapr.io/v1alpha1
kind: DaprInstance
metadata:
name: "dapr-instance"
spec:
values: {}# Deprecated, use DaprInstance instead
apiVersion: operator.dapr.io/v1alpha1
kind: DaprControlPlane
metadata:
name: "dapr-control-plane"
spec:
values: {}The DaprInstance resource is a Kubernetes Custom Resource (CRD) that describes the desired state for a given Dapr instance and allows for the configuration of the components that make up the instance.
When the Dapr Kubernetes Operator sees a new DaprInstance resource, the Dapr components are provisioned using Kubernetes resources generated from the official Dapr Helm Charts and managed by the operator.
This means that the same configuration option that are available when installing Dapr using Helm can also be used to configure the Dapr Kubernetes Operator
When something changes on an existing DaprInstance resource or any resource generated by the operator, the operator works to reconfigure the cluster to ensure the actual state of the cluster matches the desired state.
Important
The operator expect that a single DaprInstance named dapr-instance and placed in the same namespace where the operator runs exists at a given point in time.
Any additional DaprInstance resources will be moved to an Error state and ignored.
The DaprInstance Custom Resource consists of the following properties
| Name | Default | Description |
|---|---|---|
| values | [Empty] | The values passed into the Dapr Helm chart |
| chart | [Empty] | The Dapr Helm chart to use instead of the chart in the operator. Fields: repo (default https://dapr.github.io/helm-charts), name (default dapr), version, and secret (the credentials for repo). See Versions and Channels. |
Create a new Dapr Control Plane operator in the openshift-operators namespace using the provided basic example
kubectl apply -n openshift-operators -f config/samples/basic/dapr-basic.yamlThere will be several Dapr controllers and resources created that should be familiar to anyone who has deployed Dapr before using helm:
➜ kubecto tree daprinstance.operator.dapr.io dapr-instance
NAMESPACE NAME READY REASON AGE
openshift-operators DaprInstance/dapr-instance True Ready 72s
openshift-operators ├─ConfigMap/dapr-trust-bundle - 68s
openshift-operators ├─Configuration/daprsystem - 68s
openshift-operators ├─Deployment/dapr-operator - 68s
openshift-operators │ └─ReplicaSet/dapr-operator-5b98cf8c8 - 68s
openshift-operators │ └─Pod/dapr-operator-5b98cf8c8-cnt29 True 67s
openshift-operators ├─Deployment/dapr-sentry - 68s
openshift-operators │ └─ReplicaSet/dapr-sentry-74cbc77cb - 68s
openshift-operators │ └─Pod/dapr-sentry-74cbc77cb-n7kb9 True 67s
openshift-operators ├─Deployment/dapr-sidecar-injector - 68s
openshift-operators │ └─ReplicaSet/dapr-sidecar-injector-6745d677c7 - 68s
openshift-operators │ └─Pod/dapr-sidecar-injector-6745d677c7-zbxv4 True 67s
openshift-operators ├─Role/dapr-injector - 67s
openshift-operators ├─Role/dapr-operator - 67s
openshift-operators ├─Role/dapr-sentry - 67s
openshift-operators ├─Role/secret-reader - 67s
openshift-operators ├─RoleBinding/dapr-injector - 67s
openshift-operators ├─RoleBinding/dapr-operator - 67s
openshift-operators ├─RoleBinding/dapr-secret-reader - 67s
openshift-operators ├─RoleBinding/dapr-sentry - 67s
openshift-operators ├─Secret/dapr-trust-bundle - 67s
openshift-operators ├─Service/dapr-api - 67s
openshift-operators │ └─EndpointSlice/dapr-api-mxw2p - 67s
openshift-operators ├─Service/dapr-placement-server - 67s
openshift-operators │ └─EndpointSlice/dapr-placement-server-74rkd - 67s
openshift-operators ├─Service/dapr-sentry - 67s
openshift-operators │ └─EndpointSlice/dapr-sentry-6c46f - 67s
openshift-operators ├─Service/dapr-sidecar-injector - 67s
openshift-operators │ └─EndpointSlice/dapr-sidecar-injector-8lt7j - 67s
openshift-operators ├─Service/dapr-webhook - 67s
openshift-operators │ └─EndpointSlice/dapr-webhook-sq5vm - 67s
openshift-operators ├─ServiceAccount/dapr-injector - 67s
openshift-operators ├─ServiceAccount/dapr-operator - 67s
openshift-operators ├─ServiceAccount/dapr-placement - 67s
openshift-operators ├─ServiceAccount/dapr-sentry - 67s
openshift-operators └─StatefulSet/dapr-placement-server - 67s
openshift-operators └─ControllerRevision/dapr-placement-server-6cb96b4b85 - 67sEach operator release installs one Dapr version, and the operator version is equal to that Dapr version. For example, operator 1.19.1 installs Dapr 1.19.1. Releases up to 0.0.15 used a separate version number.
The operator is published to these OLM channels:
| Channel | Content |
|---|---|
alpha |
The default channel. It follows the newest Dapr minor version. |
dapr-X.Y |
The releases for Dapr X.Y only. For example, dapr-1.18 for Dapr 1.18. |
To stay on a Dapr minor version, set spec.channel in the Subscription to dapr-X.Y. OLM then upgrades the operator only to new releases for that minor version. After the switch, OLM upgrades the operator only if a release in the new channel replaces the installed version. For example, 0.0.14 (Dapr 1.18.4) upgrades in dapr-1.18. 0.0.15 (Dapr 1.19.0) stays on 0.0.15 in dapr-1.18, because no release in that channel replaces it.
With manual approval, the subscription can have an InstallPlan from the old channel that is not approved. OLM does not resolve the new channel while that InstallPlan is pending. Delete it, and OLM then creates an InstallPlan from the new channel.
To install a Dapr patch version without a new operator release, set spec.chart.version in the DaprInstance. The operator then loads that chart from spec.chart.repo instead of the chart that it contains. Use this only for a patch version of the Dapr minor version that the operator installs.
The operator does not compare spec.chart.version with its own chart, so the setting stays in force after an operator upgrade. Remove spec.chart when the installed operator release contains the Dapr version that you need.
apiVersion: operator.dapr.io/v1alpha1
kind: DaprInstance
metadata:
name: "dapr-instance"
spec:
chart:
version: "1.18.10"
values: {}All other tools (kustomize, kind, ko, etc.) are fetched automatically via go run.
make buildmake checkUpdate HELM_CHART_VERSION in the Makefile, then run:
make update/daprThe release workflow runs when a v* tag is pushed. It checks the tag and finds the place of the release in the OLM update graph:
- The tag must be equal to
vand the version inhelm-charts/dapr/Chart.yaml, for examplev1.19.1. Pre-release tags are not published. - The bundle replaces the previous
v*tag in the history of the tagged commit. That tag must be lower than the new tag. - A tag on
maingoes to thealphachannel and to thedapr-X.Ychannel. A tag that is not onmaingoes to thedapr-X.Ychannel only.
main holds the newest Dapr minor version. To make patch releases for an older Dapr minor version:
- Create the
release-X.Ybranch from the last release tag for that minor version. - Make sure that the branch has this release workflow. A tag from before this workflow, for example
v0.0.14, has the old one: it publishes toalphaonly and overwriteskubernetes-operator-catalog:latest. On such a branch, cherry-pick the changes to.github/workflows/build-release.yml,.github/workflows/publish.yml,Makefileandhack/scripts/gen_bundle.shfrommainfirst. - Update the Dapr Helm chart on that branch, then push the release tag from that branch.
Bring changes to a release-X.Y branch with cherry-picks. A merge from main adds newer tags to the history of the branch, and the release workflow then stops the release.
All bundles keep alpha as their default channel annotation. In the catalog, the bundle with the highest version sets the default channel of the package. The release workflow does not build the kubernetes-operator-catalog image for a tag that is not on main, because opm builds that image from the new bundle only.
The project uses end-to-end tests that run against a real Kubernetes cluster.
-
Create a Kind cluster:
make test/e2e/kind/setup
-
Deploy the ingress controller:
make deploy/e2e/ingress
-
Build and publish the operator image (using ttl.sh as a temporary registry):
export CONTAINER_IMAGE="ttl.sh/$(uuidgen | tr '[:upper:]' '[:lower:]'):1h" make docker/build docker/push
-
Deploy the operator:
make deploy/e2e/controller
-
Build the test application:
make test/e2e/app
-
Run the tests:
make test/e2e/operator
-
Tear down the Kind cluster:
make test/e2e/kind/teardown
make deploy/e2e/olm
make test/e2e/olm