Skip to content
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

Fix issue where container IP is occasionally empty for Kubernetes pods in HostNetwork mode #1280

Merged
merged 3 commits into from
Dec 26, 2023

Conversation

EvanLjp
Copy link
Collaborator

@EvanLjp EvanLjp commented Dec 25, 2023

BUG:
The following PNG shows the hosts file and hostname file not mapping in the pod host network condition. So the container IP in the docker center would be empty.
image
image

FIX:
Use the local hostname as the default value to mapping the previous condition, to avoid the case.

@EvanLjp EvanLjp added the bug Something isn't working label Dec 25, 2023
@EvanLjp EvanLjp requested a review from yyuuttaaoo December 25, 2023 11:25
@yyuuttaaoo yyuuttaaoo changed the title Fix k8s hostnetwork cluster ip empty Fix issue where container IP is occasionally empty for Kubernetes pods in HostNetwork mode Dec 25, 2023
@yyuuttaaoo yyuuttaaoo merged commit 5a6139a into main Dec 26, 2023
20 checks passed
@yyuuttaaoo yyuuttaaoo added this to the v2.0 milestone Jan 2, 2024
yyuuttaaoo pushed a commit that referenced this pull request Jan 2, 2024
…s in HostNetwork mode (#1280)

This patch addresses a problem where the hostname specified in the hostname file does not match the entry in the etc-hosts file when using Kubernetes HostNetwork mode. The mismatch leads to scenarios where the container IP is retrieved as empty. 

To resolve this issue, the fix implements a check to compare the container's hostname against the daemon's hostname when HostNetwork mode is enabled. If they are identical, the container will inherit the daemon's IP address, ensuring consistency and preventing the container's IP from being empty.

This adjustment ensures reliable IP address assignment and mitigates the risk of networking issues within the Kubernetes cluster.
@henryzhx8 henryzhx8 deleted the fix-k8s-hostnetwork-cluster-ip-empty branch June 21, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants