GCE Windows: Set TCP/IP parameters to keep idle connections alive on GCE.

This commit is contained in:
Jeremy Edwards 2021-06-21 16:02:17 +00:00
parent ce8b7afc8a
commit 7839668877
2 changed files with 22 additions and 0 deletions

View File

@ -129,6 +129,9 @@ try {
$kube_env = Fetch-KubeEnv $kube_env = Fetch-KubeEnv
Set-EnvironmentVars Set-EnvironmentVars
# Set the TCP/IP Parameters to keep idle connections alive.
Set-WindowsTCPParameters
# Install Docker if the select CRI is not containerd and docker is not already # Install Docker if the select CRI is not containerd and docker is not already
# installed. # installed.
if (${env:CONTAINER_RUNTIME} -ne "containerd") { if (${env:CONTAINER_RUNTIME} -ne "containerd") {

View File

@ -1438,6 +1438,25 @@ function Configure_Dockerd {
Restart-Service Docker Restart-Service Docker
} }
# Configures the TCP/IP parameters to be in sync with the GCP recommendation.
# Not setting these values correctly can cause network issues for connections
# that live longer than 10 minutes.
# See: https://cloud.google.com/compute/docs/troubleshooting/general-tips#idle-connections
function Set-WindowsTCPParameters {
Set-ItemProperty -Force -Confirm:$false -Path `
'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' `
-Name 'KeepAliveInterval' -Type Dword -Value 1000
Set-ItemProperty -Force -Confirm:$false `
-Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' `
-Name 'KeepAliveTime' -Type Dword -Value 60000
Set-ItemProperty -Force -Confirm:$false `
-Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' `
-Name 'TcpMaxDataRetransmissions' -Type Dword -Value 10
Log-Output 'TCP/IP Parameters'
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
}
# Writes a CNI config file under $env:CNI_CONFIG_DIR for containerd. # Writes a CNI config file under $env:CNI_CONFIG_DIR for containerd.
# #
# Prerequisites: # Prerequisites: