Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1505 from xyz-li/master
Browse files Browse the repository at this point in the history
fix: controller-manager panic when kubeconfig set filed insecure-skip-tls-verify
  • Loading branch information
k8s-ci-robot committed Jun 6, 2022
2 parents ba0bf52 + a13458f commit 6f23c86
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions pkg/controller/util/cluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,31 @@ func CustomizeTLSTransport(fedCluster *fedv1b1.KubeFedCluster, clientConfig *res
return errors.Errorf("Cluster %s transport error: %s", fedCluster.Name, err)
}

err = CustomizeCertificateValidation(fedCluster, transportConfig)
if err != nil {
return errors.Errorf("Cluster %s custom certificate validation error: %s", fedCluster.Name, err)
}
if transportConfig != nil {
err = CustomizeCertificateValidation(fedCluster, transportConfig)
if err != nil {
return errors.Errorf("Cluster %s custom certificate validation error: %s", fedCluster.Name, err)
}

// using the same defaults as http.DefaultTransport
clientConfig.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: transportConfig,
// using the same defaults as http.DefaultTransport
clientConfig.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: transportConfig,
}
clientConfig.TLSClientConfig = restclient.TLSClientConfig{}
} else {
clientConfig.Insecure = true
}
clientConfig.TLSClientConfig = restclient.TLSClientConfig{}

return nil
}

Expand Down

0 comments on commit 6f23c86

Please sign in to comment.