ITC*_*hap 10 kubernetes kube-proxy
默认情况下,当配置中未指定任何值时,kube-proxy 可能会在 iptables 或用户空间模式下运行:
--proxy-mode 代理模式
使用哪种代理模式:“userspace”(较旧)或“iptables”(更快)或“ipvs”或“kernelspace”(Windows)。如果为空,则使用最佳可用代理(当前为 iptables)。如果选择了 iptables 代理,无论如何,但系统的内核或 iptables 版本不足,这总是会回落到用户空间代理。
由于用户空间和 iptables 模式似乎都会在节点上创建 iptables 规则,因此有没有可靠的方法可以找出 kube-proxy 默认使用的代理模式?
Sag*_*kar 13
kube-proxy 提供的模式在 kube-proxy 日志文件中提到。
W0322 08:09:44.312816 1 server_others.go:578] Unknown proxy mode "", assuming iptables proxy
I0322 08:09:44.313052 1 server_others.go:185] Using iptables Proxier.
Run Code Online (Sandbox Code Playgroud)
签入代码https://github.com/kubernetes/kubernetes/blob/master/cmd/kube-proxy/app/server_others.go
func getProxyMode(proxyMode string, canUseIPVS bool, kcompat iptables.KernelCompatTester) string {
switch proxyMode {
case proxyModeUserspace:
return proxyModeUserspace
case proxyModeIPTables:
return tryIPTablesProxy(kcompat)
case proxyModeIPVS:
return tryIPVSProxy(canUseIPVS, kcompat)
}
klog.Warningf("Unknown proxy mode %q, assuming iptables proxy", proxyMode)
return tryIPTablesProxy(kcompat)
}
func tryIPTablesProxy(kcompat iptables.KernelCompatTester) string {
// guaranteed false on error, error only necessary for debugging
useIPTablesProxy, err := iptables.CanUseIPTablesProxier(kcompat)
if err != nil {
utilruntime.HandleError(fmt.Errorf("can't determine whether to use iptables proxy, using userspace proxier: %v", err))
return proxyModeUserspace
}
if useIPTablesProxy {
return proxyModeIPTables
}
// Fallback.
klog.V(1).Infof("Can't use iptables proxy, using userspace proxier")
return proxyModeUserspace
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6510 次 |
| 最近记录: |