Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2a1286c8
Commit
2a1286c8
authored
Oct 02, 2015
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add util to set transport defaults
parent
719cf561
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
29 deletions
+30
-29
validator.go
pkg/apiserver/validator.go
+4
-10
helper.go
pkg/client/unversioned/helper.go
+2
-8
kubelet.go
pkg/client/unversioned/kubelet.go
+4
-2
http.go
pkg/util/http.go
+18
-0
oidc.go
plugin/pkg/auth/authenticator/token/oidc/oidc.go
+2
-9
No files found.
pkg/apiserver/validator.go
View file @
2a1286c8
...
...
@@ -23,9 +23,9 @@ import (
"net"
"net/http"
"strconv"
"time"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/util"
)
// TODO: this basic interface is duplicated in N places. consolidate?
...
...
@@ -59,15 +59,9 @@ func (server *Server) DoServerCheck(rt http.RoundTripper) (probe.Result, string,
// TODO(roberthbailey): The servers that use HTTPS are currently the
// kubelets, and we should be using a standard kubelet client library
// to talk to them rather than a separate http client.
transport
:=
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
(
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
KeepAlive
:
30
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
10
*
time
.
Second
,
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
}
transport
:=
util
.
SetTransportDefaults
(
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
})
client
=
&
http
.
Client
{
Transport
:
transport
}
scheme
=
"https://"
...
...
pkg/client/unversioned/helper.go
View file @
2a1286c8
...
...
@@ -380,15 +380,9 @@ func tlsTransportFor(config *Config) (http.RoundTripper, error) {
}
// Cache a single transport for these options
tlsTransports
[
key
]
=
&
http
.
Transport
{
tlsTransports
[
key
]
=
util
.
SetTransportDefaults
(
&
http
.
Transport
{
TLSClientConfig
:
tlsConfig
,
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
(
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
KeepAlive
:
30
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
10
*
time
.
Second
,
}
})
return
tlsTransports
[
key
],
nil
}
...
...
pkg/client/unversioned/kubelet.go
View file @
2a1286c8
...
...
@@ -19,6 +19,8 @@ package unversioned
import
(
"errors"
"net/http"
"k8s.io/kubernetes/pkg/util"
)
// KubeletClient is an interface for all kubelet functionality
...
...
@@ -49,10 +51,10 @@ func MakeTransport(config *KubeletConfig) (http.RoundTripper, error) {
return
nil
,
err
}
if
config
.
Dial
!=
nil
||
tlsConfig
!=
nil
{
return
&
http
.
Transport
{
return
util
.
SetTransportDefaults
(
&
http
.
Transport
{
Dial
:
config
.
Dial
,
TLSClientConfig
:
tlsConfig
,
},
nil
}
)
,
nil
}
else
{
return
http
.
DefaultTransport
,
nil
}
...
...
pkg/util/http.go
View file @
2a1286c8
...
...
@@ -18,6 +18,7 @@ package util
import
(
"io"
"net/http"
"net/url"
"strings"
)
...
...
@@ -44,3 +45,20 @@ func IsProbableEOF(err error) bool {
}
return
false
}
var
defaultTransport
=
http
.
DefaultTransport
.
(
*
http
.
Transport
)
// SetTransportDefaults applies the defaults from http.DefaultTransport
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func
SetTransportDefaults
(
t
*
http
.
Transport
)
*
http
.
Transport
{
if
t
.
Proxy
==
nil
{
t
.
Proxy
=
defaultTransport
.
Proxy
}
if
t
.
Dial
==
nil
{
t
.
Dial
=
defaultTransport
.
Dial
}
if
t
.
TLSHandshakeTimeout
==
0
{
t
.
TLSHandshakeTimeout
=
defaultTransport
.
TLSHandshakeTimeout
}
return
t
}
plugin/pkg/auth/authenticator/token/oidc/oidc.go
View file @
2a1286c8
...
...
@@ -21,7 +21,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"net"
"net/http"
"net/url"
"time"
...
...
@@ -72,17 +71,11 @@ func New(issuerURL, clientID, caFile, usernameClaim string) (*OIDCAuthenticator,
}
// Copied from http.DefaultTransport.
tr
:=
&
http
.
Transport
{
tr
:=
util
.
SetTransportDefaults
(
&
http
.
Transport
{
// According to golang's doc, if RootCAs is nil,
// TLS uses the host's root CA set.
TLSClientConfig
:
&
tls
.
Config
{
RootCAs
:
roots
},
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
(
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
KeepAlive
:
30
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
10
*
time
.
Second
,
}
})
hc
:=
&
http
.
Client
{}
hc
.
Transport
=
tr
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment