[ISSUE #202 #159]when the broker uses hostNetwork, the IP registered by the broker to the nameserver is not the podIP #203
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when the broker uses hostNetwork, the IP registered by the broker to the nameserver is not the podIP
related #202 #159
What is the purpose of the change
when the broker uses hostNetwork, the broker's IP returned by NameServer is the IP of the k8s node where the broker is located.
This is because the broker uses the cluster ip(or other ip) instead of its own pod ip when registering.
The root cause is that when using hostnetwork, the host's network is used, including /etc/hosts. When generating the
brokerIP1
configuration project, use thehostname -i
command in theimages/broker/alpine/brokerGenConfig.sh
to obtain the ip./images/broker/alpine/brokerGenConfig.sh#L30
but in many cases this command does not correctly obtain the correct ip.
for exampels:
bash-4.4# hostname -i
127.0.1.1
when use
127.0.1.1
to register, the nameserver will select the IP based on its own algorithm. Most of the time it is not the status.podIP of the pod we want: https://github.com/apache/rocketmq/blob/2c898c9b31bf195174cf1e3a626a7c61f7576381/common/src/main/java/org/apache/rocketmq/common/utils/NetworkUtil.java#L91bash-4.4# hostname -i
127.0.1.1 10.6.178.178
check the log, it seems to be successful
but when we used the mqadmin command to check the registered broker address, we found that this was not the case.
Brief changelog
When setting up with hostNetwork option, we explicitly add an environment variable
HOST_NETWORK_POD_IP
on the pod. When obtainingbrokerIP1
, we obtain it from this environment variable and register it with the nameserver.Verifying this change
the log from the pod:
the podIP:
use mqadmin see the broker address:
Please go through this checklist to help us incorporate your contribution quickly and easily.
Notice:
It would be helpful if you could finish the following checklist (the last one is not necessary) before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.make docker-build
to build docker image for operator, try your changes from Pod inside your Kubernetes cluster, not just locally. Also provide screenshots to show that the RocketMQ cluster is healthy after the changes.make manifests
to make sure the CRD files are updated.