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

rkt: Generate a new Network Namespace for each Pod #45280

Conversation

JulienBalestra
Copy link
Contributor

What this PR does / why we need it:

This PR concerns the Kubelet with the Container runtime rkt.
Currently, when a Pod stops and the kubelet restart it, the Pod will use the same network namespace based on its PodID.

When the Garbage Collection is triggered, it delete all the old resources and the current network namespace.

The Pods and all containers inside it loose the eth0 interface.
I explained more in details in #45149 how to reproduce this behavior.

This PR generates a new unique network namespace name for each new/restarting Pod.
The Garbage collection retrieve the correct network namespace and remove it safely.

Which issue this PR fixes :

fix #45149

Special notes for your reviewer:

Following @yifan-gu guidelines, so maybe expecting him for the final review.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 3, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @JulienBalestra. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 3, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 3, 2017
@JulienBalestra JulienBalestra changed the title Generate a new Network Namespace for each Pod rkt: Generate a new Network Namespace for each Pod May 3, 2017
@dims
Copy link
Member

dims commented May 3, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 3, 2017
@feiskyer
Copy link
Member

feiskyer commented May 3, 2017

/assign @yifan-gu

// but a pod id. This is because it knows too much about the infra container.
// We pretend the pod.UID is an infra container ID.
// This deception is only possible because we played the same trick in
// Currently the containerID is an UUID for a network namespace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an/a

// If we are running no-op network plugin, then get the pod IP from the rkt pod status.
if r.network.PluginName() == network.DefaultPluginName {
if latestPod != nil {
if latestPod != nil {
Copy link
Contributor

@yifan-gu yifan-gu May 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change to:

if latestPod == nil {
    glog.Warningf()
    return podStatus, nil
}

So that we don't need the big if block here

for _, n := range latestPod.Networks {
if n.Name == defaultNetworkName {
podStatus.IP = n.Ipv4
break
}
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can just return in the above break, so the else can be removed. But it's ok to keep it here as it's not big.

@yifan-gu
Copy link
Contributor

yifan-gu commented May 4, 2017

LGTM except some small nits. Thanks for the fix @JulienBalestra ! Very appreciate it!

@JulienBalestra
Copy link
Contributor Author

I made the changes and I squashed them.
Thanks for the review @yifan-gu

@yifan-gu
Copy link
Contributor

yifan-gu commented May 9, 2017

@JulienBalestra LGTM, but the CI is failing, might need a rebase?

@JulienBalestra
Copy link
Contributor Author

@yifan-gu That's better but Jenkins GCE etcd3 e2e is failing now.
@k8s-bot gce etcd3 e2e test this

@yifan-gu
Copy link
Contributor

yifan-gu commented May 9, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 9, 2017
@yifan-gu
Copy link
Contributor

yifan-gu commented May 9, 2017

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JulienBalestra, yifan-gu

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels May 9, 2017
@yifan-gu yifan-gu added the release-note-none Denotes a PR that doesn't merit a release note. label May 9, 2017
@yifan-gu yifan-gu removed release-note-label-needed do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels May 9, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 7688911 into kubernetes:master May 9, 2017
@yifan-gu yifan-gu added this to the v1.6 milestone May 17, 2017
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.6" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

@JulienBalestra JulienBalestra deleted the run-pod-inside-unique-netns branch February 29, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rkt Pod looses the network
8 participants