-
Notifications
You must be signed in to change notification settings - Fork 127
[ISSUE #54 #50] Operator multiple mq cluster && start sequence #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,6 @@ import ( | |
| "github.com/apache/rocketmq-operator/pkg/apis" | ||
| "github.com/apache/rocketmq-operator/pkg/controller" | ||
|
|
||
| "github.com/operator-framework/operator-sdk/pkg/k8sutil" | ||
| "github.com/operator-framework/operator-sdk/pkg/leader" | ||
| "github.com/operator-framework/operator-sdk/pkg/log/zap" | ||
| "github.com/operator-framework/operator-sdk/pkg/metrics" | ||
|
|
@@ -76,12 +75,6 @@ func main() { | |
|
|
||
| printVersion() | ||
|
|
||
| namespace, err := k8sutil.GetWatchNamespace() | ||
| if err != nil { | ||
| log.Error(err, "Failed to get watch namespace") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Get a config to talk to the apiserver | ||
| cfg, err := config.GetConfig() | ||
| if err != nil { | ||
|
|
@@ -100,7 +93,6 @@ func main() { | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing |
||
| // Create a new Cmd to provide shared dependencies and start components | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing GetWatchNamespace()/the Namespace option silently ignores the WATCH_NAMESPACE env var that existing operator deployments set. After upgrading, the operator expands from namespaced to cluster-wide watching with no notice; deployments that deliberately scoped it for least privilege will break at startup because the caches now need list/watch across all namespaces (and old namespaced Role manifests no longer suffice). Keep honoring WATCH_NAMESPACE, or at minimum log a loud warning when it is set. |
||
| mgr, err := manager.New(cfg, manager.Options{ | ||
| Namespace: namespace, | ||
| MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort), | ||
| }) | ||
| if err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # 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. | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| creationTimestamp: null | ||
| name: rocketmq-operator | ||
| rules: | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - pods | ||
| - services | ||
| - endpoints | ||
| - persistentvolumeclaims | ||
| - events | ||
| - configmaps | ||
| - secrets | ||
| - pods/exec | ||
| verbs: | ||
| - '*' | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - namespaces | ||
| verbs: | ||
| - get | ||
| - apiGroups: | ||
| - apps | ||
| resources: | ||
| - deployments | ||
| - daemonsets | ||
| - replicasets | ||
| - statefulsets | ||
| verbs: | ||
| - '*' | ||
| - apiGroups: | ||
| - monitoring.coreos.com | ||
| resources: | ||
| - servicemonitors | ||
| verbs: | ||
| - get | ||
| - create | ||
| - apiGroups: | ||
| - apps | ||
| resourceNames: | ||
| - rocketmq-operator | ||
| resources: | ||
| - deployments/finalizers | ||
| verbs: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| - update | ||
| - apiGroups: | ||
| - rocketmq.apache.org | ||
| resources: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - '*' | ||
| - brokers | ||
| - pods/exec | ||
| - topictransfers | ||
| verbs: | ||
| - '*' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # 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. | ||
|
|
||
| kind: ClusterRoleBinding | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| metadata: | ||
| name: rocketmq-operator | ||
| subjects: | ||
| - kind: ServiceAccount | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ClusterRoleBinding subject hardcodes namespace: default. If the operator is installed in any other namespace, its ServiceAccount never receives the ClusterRole and — since the manager now watches all namespaces — informer cache sync fails and the operator cannot start. The binding should be parameterized by the install namespace, and deploy/operator.yaml needs to be updated to reference this cluster-scoped RBAC (the diff does not touch it, so existing deployments still ship the namespaced Role and WATCH_NAMESPACE). |
||
| name: rocketmq-operator | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ClusterRoleBinding hardcodes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ServiceAccount namespace is hardcoded to |
||
| namespace: default | ||
| roleRef: | ||
| kind: ClusterRole | ||
| name: rocketmq-operator | ||
| apiGroup: rbac.authorization.k8s.io | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,9 @@ spec: | |
| items: | ||
| type: object | ||
| type: array | ||
| rocketMQName: | ||
| description: The name of rocketmq, and the broker and nameserver in the same cluster must be filled with the same name | ||
| type: string | ||
| required: | ||
| - size | ||
| - replicaPerGroup | ||
|
|
@@ -93,6 +96,7 @@ spec: | |
| - volumes | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - volumeClaimTemplates | ||
| - scalePodName | ||
| - rocketMQName | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rocketMQName is added to |
||
| type: object | ||
| status: | ||
| properties: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,9 @@ spec: | |
| items: | ||
| type: object | ||
| type: array | ||
| rocketMQName: | ||
| description: The name of rocketmq, and the broker and nameserver in the same cluster must be filled with the same name | ||
| type: string | ||
| required: | ||
| - size | ||
| - nameServiceImage | ||
|
|
@@ -73,6 +76,7 @@ spec: | |
| - storageMode | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same breaking change as the Broker CRD: making |
||
| - hostPath | ||
| - volumeClaimTemplates | ||
| - rocketMQName | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same backward-compatibility break as the Broker CRD: |
||
| type: object | ||
| status: | ||
| properties: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,8 @@ spec: | |
| size: 1 | ||
| # nameServers is the [ip:port] list of name service | ||
| nameServers: "" | ||
| # rocketMQName is the rocketmq name, must equal to nameserver.spec.rocketMQName and topictransfer.spec.rocketMQName | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can not ensure users set insistent name correctly, is there a better way to do this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this because we don't have a rocketmq resource as the parent resource of the broker and nameserver. Without a common parent controller, we can only specify the connection of the child resource in the spec. So I hope to add a rocketmq api.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case should we add rocketmq higher level api before this PR?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so |
||
| rocketMQName: "rocketmq_name" | ||
| # replicaPerGroup is the number of each broker cluster | ||
| replicaPerGroup: 1 | ||
| # brokerImage is the customized docker image repo of the RocketMQ broker | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,8 @@ type TopicTransferSpec struct { | |
| SourceCluster string `json:"sourceCluster,omitempty"` | ||
| // The cluster where the topic will be transferred to | ||
| TargetCluster string `json:"targetCluster,omitempty"` | ||
| // // RocketMQ Name, the broker and nameserver in the same cluster must be filled with the same name | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double comment marker on line 40: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Malformed comment: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is doubled ( |
||
| RocketMQName string `json:"rocketMQName"` | ||
| } | ||
|
|
||
| // TopicTransferStatus defines the observed state of TopicTransfer | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.