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

K8S API client 30s timeout: request canceled (Client.Timeout exceeded while awaiting headers) #179

Open
mgerasimchuk opened this issue Apr 26, 2024 · 0 comments

Comments

@mgerasimchuk
Copy link

mgerasimchuk commented Apr 26, 2024

I try to sniff the traffic by using a privileged pod, but face k8s API timeout:

» ~  kubectl sniff -p -n default nginx-69f9fb6f84 --pod-creation-timeout 520s
INFO[0001] sniffing method: privileged pod
INFO[0001] sniffing on pod: 'nginx-69f9fb6f84' [namespace: 'default', filter: '', interface: 'any']
INFO[0001] creating privileged pod on node: 'ip-10-12-1-1.ec2.internal'
ERRO[0031] failed to create privileged pod on node: 'ip-10-12-1-1.ec2.internal'  error="Post \"https://k8s-cluster.us-east-1.eks.amazonaws.com/api/v1/namespaces/default/pods?timeout=30s\": net/http: request canceled (Client.Timeout exceeded while awaiting headers)"
Error: Post "https://k8s-cluster.us-east-1.eks.amazonaws.com/api/v1/namespaces/default/pods?timeout=30s": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

For now, it's not possible to change timeout, cos it is hardcoded by 30s here: https://github.com/eldadru/ksniff/blob/b0b737c/pkg/cmd/sniff.go#L231

WORKAROUND (just use changes from the related PR):

For the workaround, you can build ksnif from PR sources and replace it.
Example for the MacOS on ARM:

» ~  cd /tmp
» /tmp  git clone -b feature/request-timeout-flag [email protected]:mgerasimchuk/ksniff.git 
Cloning into 'ksniff'...
Resolving deltas: 100% (293/293), done.
» /tmp  cd ksniff 
» /tmp/ksniff (feature/request-timeout-flag) make darwin
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -o kubectl-sniff-darwin cmd/kubectl-sniff.go
GO111MODULE=on GOOS=darwin GOARCH=arm64 go build -o kubectl-sniff-darwin-arm64 cmd/kubectl-sniff.go
» /tmp/ksniff (feature/request-timeout-flag) cp kubectl-sniff-darwin-arm64 ~/.krew/bin/kubectl-sniff

» /tmp/ksniff (feature/request-timeout-flag) kubectl sniff --help | grep timeout
      --pod-creation-timeout duration   the length of time to wait for privileged pod to be created (e.g. 20s, 2m, 1h). A value of zero means the creation never times out. (default 1m0s)
      --request-timeout duration        the length of time to wait before giving up on a single request to the kubernetes api (e.g. 20s, 2m, 1h). A value of zero means the creation never times out. (default 30s)


» ~  kubectl sniff --request-timeout 520s --pod-creation-timeout 520s -p -n default nginx-69f9fb6f84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant