2016-03-06 35 views
1

我已將kubernetes升級到1.1.7版,並從我的一個pod中得到此錯誤,該錯誤是經常調用k8s ApiServer來檢查每個其他pod的活躍狀態。Kubernetes api服務器從pod導致撥號錯誤的服務器丟棄請求

Error #01: Get http://[api-server]:8080/api/v1/namespaces/production/pods?labelSelector=app%3Dworkflow-worker-mandrill-hook-handler: dial tcp [api-server]:8080: connect: cannot assign requested address 

請求以〜80個請求/秒的速率發送。雖然有這個錯誤,我仍然可以從我的本地調用該API。重新開始解決問題,但第二天,它再次發生。看起來apiserver阻止了這個吊艙以避免DOS?

我使用泊塢窗版本Docker version 1.7.1, build 2c2c52b-dirty和CoreOS v773.0.0

Linux ***** 4.1.5-coreos #2 SMP Thu Aug 13 09:18:45 UTC 2015 x86_64 Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz GenuineIntel GNU/Linux 

Kubernetes API服務器錯誤日誌:

I0306 07:32:13.087599  1 logs.go:40] http: TLS handshake error from ***:60033: EOF 
I0306 07:32:14.596398  1 logs.go:40] http: TLS handshake error from ***:57257: EOF 
I0306 07:32:15.126962  1 logs.go:40] http: TLS handshake error from ***:60035: EOF 
I0306 07:32:15.136445  1 logs.go:40] http: TLS handshake error from ***:60054: EOF 
I0306 07:32:15.210656  1 logs.go:40] http: TLS handshake error from ***:45384: EOF 
I0306 07:32:15.215155  1 logs.go:40] http: TLS handshake error from ***:45385: EOF 
I0306 07:32:15.253877  1 logs.go:40] http: TLS handshake error from ***:37527: EOF 
I0306 07:32:15.265899  1 logs.go:40] http: TLS handshake error from ***:57258: EOF 
I0306 07:32:15.272564  1 logs.go:40] http: TLS handshake error from ***:57249: EOF 
I0306 07:32:15.282808  1 logs.go:40] http: TLS handshake error from ***:59928: EOF 

在主節點dmesg

[Sun Mar 6 07:32:04 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:04 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:04 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:04 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:04 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:15 2016] net_ratelimit: 34 callbacks suppressed 
[Sun Mar 6 07:32:15 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:18 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:18 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:18 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:21 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:21 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:21 2016] TCP: too many orphaned sockets 
[Sun Mar 6 07:32:29 2016] TCP: too many orphaned sockets 
+1

你有多少豆莢同時嘗試80次?您的吊艙是否有可能泄漏插座,導致kube-apiserver的系統耗盡可用的插座? 請注意,如果您有非標準kubernetes設置,則需要增加kube-apiserver具有的FD數量(例如'ulimit')。 – lavalamp

+0

此外,請注意,列表操作現在不幸很貴,我預計至少較大的羣集可能無法處理80qps的pod列表。 但是,你可能會考慮製作一個服務或複製控制器 - 根據你在做什麼,這些對象可能會爲你做。 – lavalamp

回答

0

4後幾個小時的調查,結果證明,因爲我的應用程序吃k8s api服務器。它是用Golang編寫的,並使用「gorequest」庫來調用REST API來訪問api服務器。

gorequest在發送後沒有關閉請求,即使我在代碼中明確地關閉了它。由於它在Docker容器中運行,因此很難檢查打開連接的數量。通常通過命令ls /proc/PID/fd | wc -l檢查主機就足夠了,但是這次我不得不在容器內部進行檢查。所以我嘗試使用「http」庫而不是gorequest,並解決了問題!