| ... | ... |
@@ -86,21 +86,34 @@ func GetAndTestEtcdClient(etcdClientInfo configapi.EtcdConnectionInfo) (*etcdcli |
| 86 | 86 |
|
| 87 | 87 |
// EtcdClient creates an etcd client based on the provided config. |
| 88 | 88 |
func EtcdClient(etcdClientInfo configapi.EtcdConnectionInfo) (*etcdclient.Client, error) {
|
| 89 |
- // etcd does a poor job of setting up the transport - use the Kube client stack |
|
| 90 |
- transport, err := client.TransportFor(&client.Config{
|
|
| 89 |
+ tlsConfig, err := client.TLSConfigFor(&client.Config{
|
|
| 91 | 90 |
TLSClientConfig: client.TLSClientConfig{
|
| 92 | 91 |
CertFile: etcdClientInfo.ClientCert.CertFile, |
| 93 | 92 |
KeyFile: etcdClientInfo.ClientCert.KeyFile, |
| 94 | 93 |
CAFile: etcdClientInfo.CA, |
| 95 | 94 |
}, |
| 96 |
- WrapTransport: DefaultEtcdClientTransport, |
|
| 97 | 95 |
}) |
| 98 | 96 |
if err != nil {
|
| 99 | 97 |
return nil, err |
| 100 | 98 |
} |
| 101 | 99 |
|
| 100 |
+ transport := &http.Transport{
|
|
| 101 |
+ TLSClientConfig: tlsConfig, |
|
| 102 |
+ Dial: (&net.Dialer{
|
|
| 103 |
+ // default from http.DefaultTransport |
|
| 104 |
+ Timeout: 30 * time.Second, |
|
| 105 |
+ // Lower the keep alive for connections. |
|
| 106 |
+ KeepAlive: 1 * time.Second, |
|
| 107 |
+ }).Dial, |
|
| 108 |
+ // Because watches are very bursty, defends against long delays in watch reconnections. |
|
| 109 |
+ MaxIdleConnsPerHost: 500, |
|
| 110 |
+ // defaults from http.DefaultTransport |
|
| 111 |
+ Proxy: http.ProxyFromEnvironment, |
|
| 112 |
+ TLSHandshakeTimeout: 10 * time.Second, |
|
| 113 |
+ } |
|
| 114 |
+ |
|
| 102 | 115 |
etcdClient := etcdclient.NewClient(etcdClientInfo.URLs) |
| 103 |
- etcdClient.SetTransport(transport.(*http.Transport)) |
|
| 116 |
+ etcdClient.SetTransport(transport) |
|
| 104 | 117 |
return etcdClient, nil |
| 105 | 118 |
} |
| 106 | 119 |
|
| ... | ... |
@@ -120,19 +133,3 @@ func TestEtcdClient(etcdClient *etcdclient.Client) error {
|
| 120 | 120 |
} |
| 121 | 121 |
return nil |
| 122 | 122 |
} |
| 123 |
- |
|
| 124 |
-// DefaultEtcdClientTransport sets defaults for an etcd Transport that are suitable |
|
| 125 |
-// for use by infrastructure components. |
|
| 126 |
-func DefaultEtcdClientTransport(rt http.RoundTripper) http.RoundTripper {
|
|
| 127 |
- transport := rt.(*http.Transport) |
|
| 128 |
- dialer := &net.Dialer{
|
|
| 129 |
- Timeout: 30 * time.Second, |
|
| 130 |
- // Lower the keep alive for connections. |
|
| 131 |
- KeepAlive: 1 * time.Second, |
|
| 132 |
- } |
|
| 133 |
- transport.Dial = dialer.Dial |
|
| 134 |
- // Because watches are very bursty, defends against long delays |
|
| 135 |
- // in watch reconnections. |
|
| 136 |
- transport.MaxIdleConnsPerHost = 500 |
|
| 137 |
- return transport |
|
| 138 |
-} |