Skip to content

Commit

Permalink
Dapr Kubernetes Operator CRDs should be cluster scope dapr#180
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Burgazzoli <[email protected]>
  • Loading branch information
lburgazzoli committed Oct 3, 2024
1 parent 236cdd1 commit e000c9b
Show file tree
Hide file tree
Showing 97 changed files with 1,005 additions and 2,782 deletions.
19 changes: 4 additions & 15 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,16 @@ repo: github.com/dapr/kubernetes-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: dapr.io
group: operator
kind: DaprControlPlane
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: dapr.io
group: operator
kind: DaprInstance
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
version: v1alpha1
path: github.com/dapr/kubernetes-operator/api/operator/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
domain: dapr.io
group: operator
kind: DaprCruiseControl
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
version: v1alpha1
path: github.com/dapr/kubernetes-operator/api/operator/v1beta1
version: v1beta1
version: "3"
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,22 @@ Kubernetes cluster.
The following example shows the most minimal valid manifest to create a new Dapr instance:

```yaml
apiVersion: operator.dapr.io/v1alpha1
apiVersion: operator.dapr.io/v1beta1
kind: DaprInstance
metadata:
name: "dapr-instance"
spec:
values: {}
```
```yaml
# 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](https://github.com/dapr/helm-charts) and managed by the operator.
This means that the same configuration option that are available when [installing Dapr using Helm](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/#install-with-helm-advanced) 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 operator expect that a single cluster wide `DaprInstance` named `dapr-instance`.

The `DaprInstance` Custom Resource consists of the following properties

Expand Down
72 changes: 0 additions & 72 deletions api/operator/v1alpha1/dapr_control_plane_types.go

This file was deleted.

7 changes: 0 additions & 7 deletions api/operator/v1alpha1/doc.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
package v1beta1

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1beta1

import (
"github.com/dapr/kubernetes-operator/pkg/conditions"
Expand All @@ -32,6 +32,7 @@ type DaprCruiseControlStatus struct {
}

// +genclient
// +genclient:nonNamespaced
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
Expand All @@ -40,7 +41,8 @@ type DaprCruiseControlStatus struct {
// +kubebuilder:printcolumn:name="Chart Name",type=string,JSONPath=`.status.chart.name`,description="Chart Name"
// +kubebuilder:printcolumn:name="Chart Repo",type=string,JSONPath=`.status.chart.repo`,description="Chart Repo"
// +kubebuilder:printcolumn:name="Chart Version",type=string,JSONPath=`.status.chart.version`,description="Chart Version"
// +kubebuilder:resource:path=daprcruiscontrols,scope=Namespaced,shortName=dcc,categories=dapr
// +kubebuilder:resource:path=daprcruiscontrols,scope=Cluster,shortName=dcc,categories=dapr
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'dapr-cruise-control'",message="DaprCruiseControl name must be dapr-cruise-control"

// DaprCruiseControl is the Schema for the daprcruisecontrols API.
type DaprCruiseControl struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1beta1

import (
"github.com/dapr/kubernetes-operator/pkg/conditions"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type DeploymentSpec struct {
// +kubebuilder:validation:Required
// Namespace represent the target namespace where the Dapr resources will be installed
Namespace string `json:"namespace,omitempty"`
}

// DaprInstanceSpec defines the desired state of DaprInstance.
type DaprInstanceSpec struct {
Deployment DeploymentSpec `json:"deployment"`

// +kubebuilder:validation:Optional
Chart *ChartSpec `json:"chart,omitempty"`

Expand All @@ -37,6 +45,7 @@ type DaprInstanceStatus struct {
}

// +genclient
// +genclient:nonNamespaced
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
Expand All @@ -45,7 +54,8 @@ type DaprInstanceStatus struct {
// +kubebuilder:printcolumn:name="Chart Name",type=string,JSONPath=`.status.chart.name`,description="Chart Name"
// +kubebuilder:printcolumn:name="Chart Repo",type=string,JSONPath=`.status.chart.repo`,description="Chart Repo"
// +kubebuilder:printcolumn:name="Chart Version",type=string,JSONPath=`.status.chart.version`,description="Chart Version"
// +kubebuilder:resource:path=daprinstances,scope=Namespaced,shortName=di,categories=dapr
// +kubebuilder:resource:path=daprinstances,scope=Cluster,shortName=di,categories=dapr
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'dapr-instance'",message="DaprInstance name must be dapr-instance"

// DaprInstance is the Schema for the daprinstances API.
type DaprInstance struct {
Expand Down
7 changes: 7 additions & 0 deletions api/operator/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Package v1beta1 contains API Schema definitions for the operator.dapr.io API group.
//
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
// +groupName=operator.dapr.io

package v1beta1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the tools v1alpha1 API group
// Package v1beta1 contains API Schema definitions for the tools v1beta1 API group
//
// +kubebuilder:object:generate=true
// +groupName=operator.dapr.io
package v1alpha1

package v1beta1

import (
"github.com/dapr/kubernetes-operator/api/operator"
Expand All @@ -27,7 +29,7 @@ import (

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: operator.Group, Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: operator.Group, Version: "v1beta1"}

// SchemeGroupVersion is an hack for client gen.
SchemeGroupVersion = GroupVersion
Expand Down
Loading

0 comments on commit e000c9b

Please sign in to comment.