This is an automated email from the ASF dual-hosted git repository.

caigy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-operator.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e32e88  feat(broker): Support HostNetwork for broker
     new 27bfbce  Merge pull request #105 from 
shangjin92/feature/support-broker-hostnetwork
8e32e88 is described below

commit 8e32e889f59c1e5f563cf7da34e6e28a6e027eef
Author: jim.sj <[email protected]>
AuthorDate: Fri Jul 1 12:09:01 2022 +0800

    feat(broker): Support HostNetwork for broker
    
    Sometimes, it will access RocketMQ Cluster from outside the Kubernetes 
cluster. The client get broker ip and port from nameserver. If not use host 
network, the broker ip will be kubernetes pod ip, and the client cannot access 
this pod ip.
---
 deploy/crds/rocketmq.apache.org_brokers.yaml | 3 +++
 go.mod                                       | 4 +---
 images/broker/alpine/brokerGenConfig.sh      | 1 +
 pkg/apis/rocketmq/v1alpha1/broker_types.go   | 2 ++
 pkg/controller/broker/broker_controller.go   | 1 +
 5 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/deploy/crds/rocketmq.apache.org_brokers.yaml 
b/deploy/crds/rocketmq.apache.org_brokers.yaml
index 0913285..8775582 100644
--- a/deploy/crds/rocketmq.apache.org_brokers.yaml
+++ b/deploy/crds/rocketmq.apache.org_brokers.yaml
@@ -1121,6 +1121,9 @@ spec:
                   - name
                   type: object
                 type: array
+              hostNetwork:
+                description: HostNetwork can be true or false
+                type: boolean
               hostPath:
                 description: HostPath is the local path to store data
                 type: string
diff --git a/go.mod b/go.mod
index 1963407..2a3e0a8 100644
--- a/go.mod
+++ b/go.mod
@@ -3,9 +3,7 @@ module github.com/apache/rocketmq-operator
 go 1.16
 
 require (
-       github.com/google/uuid v1.1.2 // indirect
-       github.com/onsi/ginkgo v1.16.4
-       github.com/onsi/gomega v1.15.0
+       github.com/google/uuid v1.1.2
        github.com/pkg/errors v0.9.1
        k8s.io/api v0.22.1
        k8s.io/apimachinery v0.22.1
diff --git a/images/broker/alpine/brokerGenConfig.sh 
b/images/broker/alpine/brokerGenConfig.sh
index e681974..a4ba21b 100755
--- a/images/broker/alpine/brokerGenConfig.sh
+++ b/images/broker/alpine/brokerGenConfig.sh
@@ -27,6 +27,7 @@ function create_config() {
     echo "brokerClusterName=$BROKER_CLUSTER_NAME" >> $BROKER_CONFIG_FILE
     echo "brokerName=$BROKER_NAME" >> $BROKER_CONFIG_FILE
     echo "brokerId=$BROKER_ID" >> $BROKER_CONFIG_FILE
+    echo "brokerIP1=`hostname -i`" >> $BROKER_CONFIG_FILE
     if [ $BROKER_ID != 0 ]; then
         sed -i 's/brokerRole=.*/brokerRole=SLAVE/g' $BROKER_CONFIG_FILE
     fi
diff --git a/pkg/apis/rocketmq/v1alpha1/broker_types.go 
b/pkg/apis/rocketmq/v1alpha1/broker_types.go
index 3a7332b..b4654af 100644
--- a/pkg/apis/rocketmq/v1alpha1/broker_types.go
+++ b/pkg/apis/rocketmq/v1alpha1/broker_types.go
@@ -40,6 +40,8 @@ type BrokerSpec struct {
        BrokerImage string `json:"brokerImage"`
        // ImagePullPolicy defines how the image is pulled
        ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
+       // HostNetwork can be true or false
+       HostNetwork bool `json:"hostNetwork,omitempty"`
        // AllowRestart defines whether allow pod restart
        AllowRestart bool `json:"allowRestart"`
        // Resources describes the compute resource requirements
diff --git a/pkg/controller/broker/broker_controller.go 
b/pkg/controller/broker/broker_controller.go
index ab0870d..714141d 100644
--- a/pkg/controller/broker/broker_controller.go
+++ b/pkg/controller/broker/broker_controller.go
@@ -426,6 +426,7 @@ func (r *ReconcileBroker) getBrokerStatefulSet(broker 
*rocketmqv1alpha1.Broker,
                                        Labels: ls,
                                },
                                Spec: corev1.PodSpec{
+                                       HostNetwork:       
broker.Spec.HostNetwork,
                                        Affinity:          broker.Spec.Affinity,
                                        Tolerations:       
broker.Spec.Tolerations,
                                        NodeSelector:      
broker.Spec.NodeSelector,

Reply via email to