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
3357b5ec
Commit
3357b5ec
authored
Jul 25, 2018
by
Andrew Lytvynov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set connrotation dialer via restclient.Config.Dialer
Instead of Transport. This fixes ExecPlugin, which fails if restclient.Config.Transport is set.
parent
afcc1568
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
transport.go
pkg/kubelet/certificate/transport.go
+15
-5
exec.go
.../src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
+4
-14
No files found.
pkg/kubelet/certificate/transport.go
View file @
3357b5ec
...
...
@@ -65,15 +65,26 @@ func updateTransport(stopCh <-chan struct{}, period time.Duration, clientConfig
d
:=
connrotation
.
NewDialer
((
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
KeepAlive
:
30
*
time
.
Second
})
.
DialContext
)
if
clientCertificateManager
!=
nil
{
if
err
:=
addCertRotation
(
stopCh
,
period
,
clientConfig
,
clientCertificateManager
,
exitAfter
,
d
);
err
!=
nil
{
return
nil
,
err
}
}
else
{
clientConfig
.
Dial
=
d
.
DialContext
}
return
d
.
CloseAll
,
nil
}
func
addCertRotation
(
stopCh
<-
chan
struct
{},
period
time
.
Duration
,
clientConfig
*
restclient
.
Config
,
clientCertificateManager
certificate
.
Manager
,
exitAfter
time
.
Duration
,
d
*
connrotation
.
Dialer
)
error
{
tlsConfig
,
err
:=
restclient
.
TLSConfigFor
(
clientConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to configure TLS for the rest client: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to configure TLS for the rest client: %v"
,
err
)
}
if
tlsConfig
==
nil
{
tlsConfig
=
&
tls
.
Config
{}
}
if
clientCertificateManager
!=
nil
{
tlsConfig
.
Certificates
=
nil
tlsConfig
.
GetClientCertificate
=
func
(
requestInfo
*
tls
.
CertificateRequestInfo
)
(
*
tls
.
Certificate
,
error
)
{
cert
:=
clientCertificateManager
.
Current
()
...
...
@@ -125,14 +136,13 @@ func updateTransport(stopCh <-chan struct{}, period time.Duration, clientConfig
// See: https://github.com/kubernetes-incubator/bootkube/pull/663#issuecomment-318506493
d
.
CloseAll
()
},
period
,
stopCh
)
}
clientConfig
.
Transport
=
utilnet
.
SetTransportDefaults
(
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
TLSHandshakeTimeout
:
10
*
time
.
Second
,
TLSClientConfig
:
tlsConfig
,
MaxIdleConnsPerHost
:
25
,
DialContext
:
d
.
DialContext
,
// Use custom dialer.
DialContext
:
d
.
DialContext
,
})
// Zero out all existing TLS options since our new transport enforces them.
...
...
@@ -144,5 +154,5 @@ func updateTransport(stopCh <-chan struct{}, period time.Duration, clientConfig
clientConfig
.
CAFile
=
""
clientConfig
.
Insecure
=
false
return
d
.
CloseAll
,
nil
return
nil
}
staging/src/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go
View file @
3357b5ec
...
...
@@ -20,6 +20,7 @@ import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"net"
...
...
@@ -179,21 +180,10 @@ func (a *Authenticator) UpdateTransportConfig(c *transport.Config) error {
return
&
roundTripper
{
a
,
rt
}
}
getCert
:=
c
.
TLS
.
GetCert
c
.
TLS
.
GetCert
=
func
()
(
*
tls
.
Certificate
,
error
)
{
// If previous GetCert is present and returns a valid non-nil
// certificate, use that. Otherwise use cert from exec plugin.
if
getCert
!=
nil
{
cert
,
err
:=
getCert
()
if
err
!=
nil
{
return
nil
,
err
}
if
cert
!=
nil
{
return
cert
,
nil
}
}
return
a
.
cert
()
if
c
.
TLS
.
GetCert
!=
nil
{
return
errors
.
New
(
"can't add TLS certificate callback: transport.Config.TLS.GetCert already set"
)
}
c
.
TLS
.
GetCert
=
a
.
cert
var
dial
func
(
ctx
context
.
Context
,
network
,
addr
string
)
(
net
.
Conn
,
error
)
if
c
.
Dial
!=
nil
{
...
...
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