Skip to content

Commit 326f601

Browse files
committed
Dapr Kubernetes Operator CRDs should be cluster scope #180
Signed-off-by: Luca Burgazzoli <[email protected]>
1 parent aaf689f commit 326f601

File tree

93 files changed

+916
-2721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+916
-2721
lines changed

PROJECT

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,16 @@ repo: github.com/dapr/kubernetes-operator
1111
resources:
1212
- api:
1313
crdVersion: v1
14-
namespaced: true
15-
controller: true
16-
domain: dapr.io
17-
group: operator
18-
kind: DaprControlPlane
19-
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
20-
version: v1alpha1
21-
- api:
22-
crdVersion: v1
23-
namespaced: true
2414
domain: dapr.io
2515
group: operator
2616
kind: DaprInstance
27-
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
28-
version: v1alpha1
17+
path: github.com/dapr/kubernetes-operator/api/operator/v1beta1
18+
version: v1beta1
2919
- api:
3020
crdVersion: v1
31-
namespaced: true
3221
domain: dapr.io
3322
group: operator
3423
kind: DaprCruiseControl
35-
path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1
36-
version: v1alpha1
24+
path: github.com/dapr/kubernetes-operator/api/operator/v1beta1
25+
version: v1beta1
3726
version: "3"

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,22 @@ Kubernetes cluster.
4242
The following example shows the most minimal valid manifest to create a new Dapr instance:
4343

4444
```yaml
45-
apiVersion: operator.dapr.io/v1alpha1
45+
apiVersion: operator.dapr.io/v1beta1
4646
kind: DaprInstance
4747
metadata:
4848
name: "dapr-instance"
4949
spec:
5050
values: {}
5151
```
5252
53-
```yaml
54-
# Deprecated, use DaprInstance instead
55-
apiVersion: operator.dapr.io/v1alpha1
56-
kind: DaprControlPlane
57-
metadata:
58-
name: "dapr-control-plane"
59-
spec:
60-
values: {}
61-
```
62-
6353
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.
6454

6555
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.
6656
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`
6757
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.
6858

6959
> [!IMPORTANT]
70-
> 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.
71-
> Any additional `DaprInstance` resources will be moved to an `Error` state and ignored.
60+
> The operator expect that a single cluster wide `DaprInstance` named `dapr-instance`.
7261

7362
The `DaprInstance` Custom Resource consists of the following properties
7463

api/operator/v1alpha1/dapr_control_plane_types.go

Lines changed: 0 additions & 72 deletions
This file was deleted.

api/operator/v1alpha1/common_types.go renamed to api/operator/v1beta1/common_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package v1alpha1
16+
package v1beta1
1717

1818
import (
1919
"encoding/json"

api/operator/v1alpha1/dapr_cruise_control_types.go renamed to api/operator/v1beta1/dapr_cruise_control_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package v1alpha1
17+
package v1beta1
1818

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

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

4547
// DaprCruiseControl is the Schema for the daprcruisecontrols API.
4648
type DaprCruiseControl struct {

api/operator/v1alpha1/dapr_instance_types.go renamed to api/operator/v1beta1/dapr_instance_types.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package v1alpha1
17+
package v1beta1
1818

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

24+
type DeploymentSpec struct {
25+
// +kubebuilder:validation:Required
26+
// Namespace represent the target namespace where the Dapr resources will be installed
27+
Namespace string `json:"namespace,omitempty"`
28+
}
29+
2430
// DaprInstanceSpec defines the desired state of DaprInstance.
2531
type DaprInstanceSpec struct {
32+
Deployment DeploymentSpec `json:"deployment"`
33+
2634
// +kubebuilder:validation:Optional
2735
Chart *ChartSpec `json:"chart,omitempty"`
2836

@@ -37,6 +45,7 @@ type DaprInstanceStatus struct {
3745
}
3846

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

5060
// DaprInstance is the Schema for the daprinstances API.
5161
type DaprInstance struct {

api/operator/v1alpha1/groupversion_info.go renamed to api/operator/v1beta1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

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

2222
import (
2323
"github.com/dapr/kubernetes-operator/api/operator"
@@ -27,7 +27,7 @@ import (
2727

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

3232
// SchemeGroupVersion is an hack for client gen.
3333
SchemeGroupVersion = GroupVersion

api/operator/v1alpha1/zz_generated.deepcopy.go renamed to api/operator/v1beta1/zz_generated.deepcopy.go

Lines changed: 18 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)