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 Sep 25, 2024
1 parent aaf689f commit 57566b1
Show file tree
Hide file tree
Showing 82 changed files with 643 additions and 2,537 deletions.
15 changes: 2 additions & 13 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
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha2
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: dapr.io
group: operator
kind: DaprCruiseControl
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha2
version: v1alpha1
version: "3"
72 changes: 0 additions & 72 deletions api/operator/v1alpha1/dapr_control_plane_types.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 v1alpha2

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 v1alpha2

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 v1alpha2

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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ 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 v1alpha1 contains API Schema definitions for the tools v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=operator.dapr.io
package v1alpha1
package v1alpha2

import (
"github.com/dapr/kubernetes-operator/api/operator"
Expand All @@ -27,7 +27,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: "v1alpha2"}

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"

"github.com/dapr/kubernetes-operator/internal/controller/operator/controlplane"
"github.com/dapr/kubernetes-operator/internal/controller/operator/instance"
"github.com/dapr/kubernetes-operator/pkg/helm"

Expand All @@ -19,7 +18,7 @@ import (
rtclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"

daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha2"
"github.com/dapr/kubernetes-operator/pkg/controller"
)

Expand Down Expand Up @@ -80,10 +79,6 @@ func NewRunCmd() *cobra.Command {
co.WatchSelectors = selector

return controller.Start(co, func(manager manager.Manager, opts controller.Options) error {
if _, err := controlplane.NewReconciler(cmd.Context(), manager, helmOpts); err != nil {
return fmt.Errorf("unable to set-up DaprControlPlane reconciler: %w", err)
}

if _, err := instance.NewReconciler(cmd.Context(), manager, helmOpts); err != nil {
return fmt.Errorf("unable to set-up DaprInstance reconciler: %w", err)
}
Expand Down
Loading

0 comments on commit 57566b1

Please sign in to comment.