[EKS] Windows pause image is missing wincat.exe which breaks port forwarding
(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 / EKSshows the following fromkubelet:
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 / Applicationshows the following fromdocker:
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.exeusing kubernetes-sigs/sig-windows-tools/cmd/wincat/Dockerfile (updated to Windows Server Core 20.04) - Copy
wincat.exeto Windows node using Windows Admin Center - Copy
wincat.exeinto relevant container instance ofamazonaws.com/eks/pause-windows:latest- Run
docker cp wincat.exe c70dca3ca3eb:/Windows/System32/wincat.exefrom PowerShell on Windows node
- Run
- Verify port forward now works!
Note: this fix relates to the Kubernetes docs for Windows support in Kubernetes; in the troubleshooting section:
kubectl port-forwardfails 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 includewincat.
i.e. wincat.exe should be included in the amazonaws.com/eks/pause-windows custom image!
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. 🙏
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.
Latest EKS Windows AMIs now support port-forward