mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-27 07:28:14 +00:00
Merge pull request #50476 from caesarxuchao/plumb-proxy
Automatic merge from submit-queue (batch tested with PRs 51824, 50476, 52451, 52009, 52237) Plumbing the proxy dialer to the webhook admission plugin * Fixing https://github.com/kubernetes/kubernetes/issues/49987. Plumb the `Dial` function to the `transport.Config` * Fixing https://github.com/kubernetes/kubernetes/issues/52366. Let the webhook admission plugin sets the `TLSConfg.ServerName`. I tested it in my gke setup. I don't have time to implement an e2e test before 1.8 release. I think it's ok to add the test later, because *i)* the change only affects the alpha webhook admission feature, and *ii)* the webhook feature is unusable without the fix. That said, it's up to my reviewer to decide. Filed https://github.com/kubernetes/kubernetes/issues/52368 for the missing e2e test. ( The second commit is https://github.com/kubernetes/kubernetes/pull/52372, which is just a cleanup of client configuration in e2e tests. It removed a function that marshalled the client config to json and then unmarshalled it. It is a prerequisite of this PR, because this PR added the `Dial` function to the config which is not json marshallable.) ```release-note Fixed the webhook admission plugin so that it works even if the apiserver and the nodes are in two networks (e.g., in GKE). Fixed the webhook admission plugin so that webhook author could use the DNS name of the service as the CommonName when generating the server cert for the webhook. Action required: Anyone who generated server cert for admission webhooks need to regenerate the cert. Previously, when generating server cert for the admission webhook, the CN value doesn't matter. Now you must set it to the DNS name of the webhook service, i.e., `<service.Name>.<service.Namespace>.svc`. ``` Kubernetes-commit: 7181dd49460787871b602a47ab2ad05babacb820
This commit is contained in:
commit
48c8058911
@ -114,6 +114,9 @@ type Config struct {
|
|||||||
// The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.
|
// The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
|
||||||
|
// Dial specifies the dial function for creating unencrypted TCP connections.
|
||||||
|
Dial func(network, addr string) (net.Conn, error)
|
||||||
|
|
||||||
// Version forces a specific version to be used (if registered)
|
// Version forces a specific version to be used (if registered)
|
||||||
// Do we need this?
|
// Do we need this?
|
||||||
// Version string
|
// Version string
|
||||||
|
@ -18,6 +18,7 @@ package rest
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -236,6 +237,8 @@ func TestAnonymousConfig(t *testing.T) {
|
|||||||
func(r *clientcmdapi.AuthProviderConfig, f fuzz.Continue) {
|
func(r *clientcmdapi.AuthProviderConfig, f fuzz.Continue) {
|
||||||
r.Config = map[string]string{}
|
r.Config = map[string]string{}
|
||||||
},
|
},
|
||||||
|
// Dial does not require fuzzer
|
||||||
|
func(r *func(network, addr string) (net.Conn, error), f fuzz.Continue) {},
|
||||||
)
|
)
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
original := &Config{}
|
original := &Config{}
|
||||||
|
@ -96,5 +96,6 @@ func (c *Config) TransportConfig() (*transport.Config, error) {
|
|||||||
Groups: c.Impersonate.Groups,
|
Groups: c.Impersonate.Groups,
|
||||||
Extra: c.Impersonate.Extra,
|
Extra: c.Impersonate.Extra,
|
||||||
},
|
},
|
||||||
|
Dial: c.Dial,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -63,16 +63,20 @@ func (c *tlsTransportCache) get(config *Config) (http.RoundTripper, error) {
|
|||||||
return http.DefaultTransport, nil
|
return http.DefaultTransport, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dial := config.Dial
|
||||||
|
if dial == nil {
|
||||||
|
dial = (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial
|
||||||
|
}
|
||||||
// Cache a single transport for these options
|
// Cache a single transport for these options
|
||||||
c.transports[key] = utilnet.SetTransportDefaults(&http.Transport{
|
c.transports[key] = utilnet.SetTransportDefaults(&http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
MaxIdleConnsPerHost: idleConnsPerHost,
|
MaxIdleConnsPerHost: idleConnsPerHost,
|
||||||
Dial: (&net.Dialer{
|
Dial: dial,
|
||||||
Timeout: 30 * time.Second,
|
|
||||||
KeepAlive: 30 * time.Second,
|
|
||||||
}).Dial,
|
|
||||||
})
|
})
|
||||||
return c.transports[key], nil
|
return c.transports[key], nil
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ limitations under the License.
|
|||||||
|
|
||||||
package transport
|
package transport
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
// Config holds various options for establishing a transport.
|
// Config holds various options for establishing a transport.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -52,6 +55,9 @@ type Config struct {
|
|||||||
// config may layer other RoundTrippers on top of the returned
|
// config may layer other RoundTrippers on top of the returned
|
||||||
// RoundTripper.
|
// RoundTripper.
|
||||||
WrapTransport func(rt http.RoundTripper) http.RoundTripper
|
WrapTransport func(rt http.RoundTripper) http.RoundTripper
|
||||||
|
|
||||||
|
// Dial specifies the dial function for creating unencrypted TCP connections.
|
||||||
|
Dial func(network, addr string) (net.Conn, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImpersonationConfig has all the available impersonation options
|
// ImpersonationConfig has all the available impersonation options
|
||||||
|
Loading…
Reference in New Issue
Block a user