mirror of https://github.com/k3s-io/k3s
Update client connections to try to use http2, except attach, exec, and
port-forward which are customizedpull/6/head
parent
786b7989a0
commit
199e15ab64
|
@ -72,7 +72,7 @@ func MakeTransport(config *KubeletClientConfig) (http.RoundTripper, error) {
|
||||||
|
|
||||||
rt := http.DefaultTransport
|
rt := http.DefaultTransport
|
||||||
if config.Dial != nil || tlsConfig != nil {
|
if config.Dial != nil || tlsConfig != nil {
|
||||||
rt = utilnet.SetTransportDefaults(&http.Transport{
|
rt = utilnet.SetOldTransportDefaults(&http.Transport{
|
||||||
Dial: config.Dial,
|
Dial: config.Dial,
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,6 +26,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
|
"golang.org/x/net/http2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsProbableEOF returns true if the given error resembles a connection termination
|
// IsProbableEOF returns true if the given error resembles a connection termination
|
||||||
|
@ -53,9 +56,9 @@ func IsProbableEOF(err error) bool {
|
||||||
|
|
||||||
var defaultTransport = http.DefaultTransport.(*http.Transport)
|
var defaultTransport = http.DefaultTransport.(*http.Transport)
|
||||||
|
|
||||||
// SetTransportDefaults applies the defaults from http.DefaultTransport
|
// SetOldTransportDefaults applies the defaults from http.DefaultTransport
|
||||||
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
|
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
|
||||||
func SetTransportDefaults(t *http.Transport) *http.Transport {
|
func SetOldTransportDefaults(t *http.Transport) *http.Transport {
|
||||||
if t.Proxy == nil || isDefault(t.Proxy) {
|
if t.Proxy == nil || isDefault(t.Proxy) {
|
||||||
// http.ProxyFromEnvironment doesn't respect CIDRs and that makes it impossible to exclude things like pod and service IPs from proxy settings
|
// http.ProxyFromEnvironment doesn't respect CIDRs and that makes it impossible to exclude things like pod and service IPs from proxy settings
|
||||||
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
|
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
|
||||||
|
@ -70,6 +73,19 @@ func SetTransportDefaults(t *http.Transport) *http.Transport {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTransportDefaults applies the defaults from http.DefaultTransport
|
||||||
|
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
|
||||||
|
func SetTransportDefaults(t *http.Transport) *http.Transport {
|
||||||
|
t = SetOldTransportDefaults(t)
|
||||||
|
// Allow HTTP2 clients but default off for now
|
||||||
|
if s := os.Getenv("ENABLE_HTTP2"); len(s) > 0 {
|
||||||
|
if err := http2.ConfigureTransport(t); err != nil {
|
||||||
|
glog.Warningf("Transport failed http2 configuration: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
type RoundTripperWrapper interface {
|
type RoundTripperWrapper interface {
|
||||||
http.RoundTripper
|
http.RoundTripper
|
||||||
WrappedRoundTripper() http.RoundTripper
|
WrappedRoundTripper() http.RoundTripper
|
||||||
|
|
Loading…
Reference in New Issue