From 7839668877e82e55b8306aa190cfc51d40b295ec Mon Sep 17 00:00:00 2001 From: Jeremy Edwards Date: Mon, 21 Jun 2021 16:02:17 +0000 Subject: [PATCH] GCE Windows: Set TCP/IP parameters to keep idle connections alive on GCE. --- cluster/gce/windows/configure.ps1 | 3 +++ cluster/gce/windows/k8s-node-setup.psm1 | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cluster/gce/windows/configure.ps1 b/cluster/gce/windows/configure.ps1 index c8f8641cdc1..170602a9e80 100644 --- a/cluster/gce/windows/configure.ps1 +++ b/cluster/gce/windows/configure.ps1 @@ -129,6 +129,9 @@ try { $kube_env = Fetch-KubeEnv 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 # installed. if (${env:CONTAINER_RUNTIME} -ne "containerd") { diff --git a/cluster/gce/windows/k8s-node-setup.psm1 b/cluster/gce/windows/k8s-node-setup.psm1 index bf78ef835a6..e317d1eecc3 100644 --- a/cluster/gce/windows/k8s-node-setup.psm1 +++ b/cluster/gce/windows/k8s-node-setup.psm1 @@ -1438,6 +1438,25 @@ function Configure_Dockerd { 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. # # Prerequisites: