containers-roadmap icon indicating copy to clipboard operation
containers-roadmap copied to clipboard

[EKS] Windows pause image is missing wincat.exe which breaks port forwarding

Open gitfool opened this issue 6 years ago • 3 comments

(Note: I'm not sure what repo to file this issue in but the aws containers roadmap seemed like a good candidate.)

Steps to reproduce:

  • Enable Windows support for an EKS cluster (using Kubernetes 1.17 with Windows Server Core 20.04 nodes)
  • Deploy a Windows pod
  • Add a port forward to the pod (which seems to work but actually fails)
  • Check the Windows Event Log with Windows Admin Center
  • Applications and Services Logs / EKS shows the following from kubelet:
E1004 08:41:56.115337    3500 httpstream.go:251] error forwarding port 80 to pod c70dca3ca3eb916bb135837bb27c6137627182cb5d417dbf81bba4f6807fa0e5, uid : Error executing in Docker Container: 126: 
  • Windows Logs / Application shows the following from docker:
exec's CreateProcess() failed [module=libcontainerd namespace=moby container=c70dca3ca3eb916bb135837bb27c6137627182cb5d417dbf81bba4f6807fa0e5 exec=a6c48e4aaaa9ea25272e1800e77d88e77060d7f2480abc632ec170584ac1fa90 error=container c70dca3ca3eb916bb135837bb27c6137627182cb5d417dbf81bba4f6807fa0e5 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"wincat.exe 127.0.0.1 80","User":"ContainerUser","WorkingDirectory":"/","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}]
Error running exec a6c48e4aaaa9ea25272e1800e77d88e77060d7f2480abc632ec170584ac1fa90 in container: container c70dca3ca3eb916bb135837bb27c6137627182cb5d417dbf81bba4f6807fa0e5 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"wincat.exe 127.0.0.1 80","User":"ContainerUser","WorkingDirectory":"/","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}

Steps to verify fix:

  • Build wincat.exe using kubernetes-sigs/sig-windows-tools/cmd/wincat/Dockerfile (updated to Windows Server Core 20.04)
  • Copy wincat.exe to Windows node using Windows Admin Center
  • Copy wincat.exe into relevant container instance of amazonaws.com/eks/pause-windows:latest
    • Run docker cp wincat.exe c70dca3ca3eb:/Windows/System32/wincat.exe from PowerShell on Windows node
  • Verify port forward now works!

Note: this fix relates to the Kubernetes docs for Windows support in Kubernetes; in the troubleshooting section:

  1. kubectl port-forward fails with "unable to do port forwarding: wincat not found"

This was implemented in Kubernetes 1.15, and the pause infrastructure container mcr.microsoft.com/k8s/core/pause:1.2.0. Be sure to use these versions or newer ones. If you would like to build your own pause infrastructure container, be sure to include wincat.

i.e. wincat.exe should be included in the amazonaws.com/eks/pause-windows custom image!

gitfool avatar Oct 04 '20 09:10 gitfool

Meanwhile, I can workaround this issue when launching self-managed Windows nodes by patching the pause container image specified in amazon-eks-windows-nodegroup.yaml with the following:

[string]$EKSBinDir = "$env:ProgramFiles\Amazon\EKS"
[string]$EKSBootstrapScriptName = 'Start-EKSBootstrap.ps1'
[string]$EKSBootstrapScriptFile = "$EKSBinDir\$EKSBootstrapScriptName"
[string]$cfn_signal = "$env:ProgramFiles\Amazon\cfn-bootstrap\cfn-signal.exe"

# patch windows pause image to workaround missing wincat.exe
(Get-Content "$EKSBootstrapScriptFile").Replace('amazonaws.com/eks/pause-windows:latest', 'mcr.microsoft.com/oss/kubernetes/pause:1.4.0') | Set-Content "$EKSBootstrapScriptFile"

& $EKSBootstrapScriptFile -EKSClusterName ${ClusterName} ${BootstrapArguments} 3>&1 4>&1 5>&1 6>&1
$LastError = if ($?) { 0 } else { $Error[0].Exception.HResult }
& $cfn_signal --exit-code=$LastError --stack="${AWS::StackName}" --resource="NodeGroup" --region=${AWS::Region}

That said, it would be nice to have this fixed before https://github.com/aws/containers-roadmap/issues/584 lands. 🙏

gitfool avatar Dec 09 '20 20:12 gitfool

Hi Changes have been made to update the pause image and kubectl port-forward will work by default on all Windows EKS AMIs from next month.

lalwanin2020 avatar Feb 26 '21 18:02 lalwanin2020

Latest EKS Windows AMIs now support port-forward

mikestef9 avatar Mar 15 '21 22:03 mikestef9