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

Kubelet TCP/HTTP probes: improve network resources utilization #115143

Merged
merged 4 commits into from Jan 22, 2023

Conversation

aojea
Copy link
Member

@aojea aojea commented Jan 17, 2023

/kind bug
/kind cleanup
/kind feature

What this PR does / why we need it:

For every connection created, the OS opens a socket and, once it finish it doesn't free all the resources immediately, it goes through a TIME-WAIT state (60 seconds by default).

Kubelet probes create short lived connections (usually less than 1 seconds), each of these connection allocate a socket, ephemeral port, conntrack entry, ... and it takes 60 seconds (TIME-WAIT) state to be freed.

This causes a problem at scale on systems that are already using a considerable amount of network resources, when there are a considerable number of probes at a high rate, they will be consuming a considerable amount of them. Since Kubernetes is a distributed system, it relies heavily on the network, and is common to reach the limits of the network resources with the users workloads.

In addition, the failures caused by the exhaustion of this network's resources are very difficult to troubleshoot, since the symptoms vary from failed probes, to connectivity issues with Services and Ingresses, controllers failing to reach apiserver, ...

In order to be more efficient on the kubelet, we can use the option SO_LINGER for each of the network probes to set the TIME-WAIT to 1 second. This is not a big problem since the probes use the connection just to check the status of the Pod, and the data transferred is relatively small.

Fixes #89898

kubelet TCP and HTTP probes are more effective using networking resources: conntrack entries, sockets, ... 
This is achieved by reducing the TIME-WAIT state of the connection to 1 second, instead of the defaults 60 seconds. This allows kubelet to free the socket, and free conntrack entry and ephemeral port associated.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 17, 2023
@aojea
Copy link
Member Author

aojea commented Jan 17, 2023

/assign @SergeyKanzhelev @thockin
/priority important-soon

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Jan 17, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jan 17, 2023
@aojea
Copy link
Member Author

aojea commented Jan 17, 2023

/sig node
/sig network

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. sig/network Categorizes an issue or PR as relevant to SIG Network. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 17, 2023
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Surprisingly not huge!

pkg/probe/util.go Outdated Show resolved Hide resolved
pkg/probe/http/http.go Outdated Show resolved Hide resolved
pkg/kubelet/prober/prober.go Outdated Show resolved Hide resolved
pkg/probe/http/http_test.go Outdated Show resolved Hide resolved
pkg/kubelet/prober/scale_test.go Show resolved Hide resolved
@aojea aojea force-pushed the linger branch 3 times, most recently from 0363f7a to 42d6a44 Compare January 18, 2023 01:29
}
switch result.Result.String() {
case "Failure":
t.Errorf("Failure %s on contantinerID: %v Pod %v", probeType, result.ContainerID, result.PodUID)
Copy link
Member Author

Choose a reason for hiding this comment

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

the test fails on failed probes

Copy link
Member

Choose a reason for hiding this comment

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

nit: Can you make it an explicit comment in code? It was hard to understand when the test will fail.

@bart0sh bart0sh moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage Jan 21, 2023
@aojea
Copy link
Member Author

aojea commented Jan 21, 2023

/retest

probe util dial set linger to 1s
Change-Id: I323b472606eaf3242b665022afe2a79ecf3b8358
Change-Id: I1e49943531b569b5e02f82369750a9ca899ae726
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2023
@aojea
Copy link
Member Author

aojea commented Jan 22, 2023

added comment on the choice for linger socket time #115143 (comment) and it removed the lgtm, removing the hold and waiting for final lgmt @SergeyKanzhelev

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 22, 2023
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 630ad365977ca27c2e3b8a3704506211db2c9010

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, SergeyKanzhelev, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 1e3cc23 into kubernetes:master Jan 22, 2023
SIG Node PR Triage automation moved this from Needs Approver to Done Jan 22, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Jan 22, 2023
k8s-ci-robot added a commit that referenced this pull request Jan 30, 2023
…-of-#115143-upstream-release-1.23

Automated cherry pick of #115143: add custom dialer optimized for probes
k8s-ci-robot added a commit that referenced this pull request Jan 30, 2023
…-of-#115143-upstream-release-1.24

Automated cherry pick of #115143: add custom dialer optimized for probes
k8s-ci-robot added a commit that referenced this pull request Jan 30, 2023
…-of-#115143-upstream-release-1.25

Automated cherry pick of #115143: add custom dialer optimized for probes
k8s-ci-robot added a commit that referenced this pull request Jan 30, 2023
…-of-#115143-upstream-release-1.26

Automated cherry pick of #115143: add custom dialer optimized for probes
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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
7 participants