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
e32f380f
Commit
e32f380f
authored
Jul 04, 2018
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiserver: get rid of ReadWritePort in config
parent
cff2a2af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
14 deletions
+34
-14
controller.go
pkg/master/controller.go
+6
-1
config.go
staging/src/k8s.io/apiserver/pkg/server/config.go
+28
-11
serving_with_loopback.go
....io/apiserver/pkg/server/options/serving_with_loopback.go
+0
-2
No files found.
pkg/master/controller.go
View file @
e32f380f
...
@@ -79,6 +79,11 @@ type Controller struct {
...
@@ -79,6 +79,11 @@ type Controller struct {
// NewBootstrapController returns a controller for watching the core capabilities of the master
// NewBootstrapController returns a controller for watching the core capabilities of the master
func
(
c
*
completedConfig
)
NewBootstrapController
(
legacyRESTStorage
corerest
.
LegacyRESTStorage
,
serviceClient
coreclient
.
ServicesGetter
,
nsClient
coreclient
.
NamespacesGetter
,
eventClient
coreclient
.
EventsGetter
)
*
Controller
{
func
(
c
*
completedConfig
)
NewBootstrapController
(
legacyRESTStorage
corerest
.
LegacyRESTStorage
,
serviceClient
coreclient
.
ServicesGetter
,
nsClient
coreclient
.
NamespacesGetter
,
eventClient
coreclient
.
EventsGetter
)
*
Controller
{
_
,
publicServicePort
,
err
:=
c
.
GenericConfig
.
SecureServing
.
HostPort
()
if
err
!=
nil
{
glog
.
Fatalf
(
"failed to get listener address: %v"
,
err
)
}
return
&
Controller
{
return
&
Controller
{
ServiceClient
:
serviceClient
,
ServiceClient
:
serviceClient
,
NamespaceClient
:
nsClient
,
NamespaceClient
:
nsClient
,
...
@@ -104,7 +109,7 @@ func (c *completedConfig) NewBootstrapController(legacyRESTStorage corerest.Lega
...
@@ -104,7 +109,7 @@ func (c *completedConfig) NewBootstrapController(legacyRESTStorage corerest.Lega
ServicePort
:
c
.
ExtraConfig
.
APIServerServicePort
,
ServicePort
:
c
.
ExtraConfig
.
APIServerServicePort
,
ExtraServicePorts
:
c
.
ExtraConfig
.
ExtraServicePorts
,
ExtraServicePorts
:
c
.
ExtraConfig
.
ExtraServicePorts
,
ExtraEndpointPorts
:
c
.
ExtraConfig
.
ExtraEndpointPorts
,
ExtraEndpointPorts
:
c
.
ExtraConfig
.
ExtraEndpointPorts
,
PublicServicePort
:
c
.
GenericConfig
.
ReadWrit
ePort
,
PublicServicePort
:
publicServic
ePort
,
KubernetesServiceNodePort
:
c
.
ExtraConfig
.
KubernetesServiceNodePort
,
KubernetesServiceNodePort
:
c
.
ExtraConfig
.
KubernetesServiceNodePort
,
}
}
}
}
...
...
staging/src/k8s.io/apiserver/pkg/server/config.go
View file @
e32f380f
...
@@ -181,9 +181,6 @@ type Config struct {
...
@@ -181,9 +181,6 @@ type Config struct {
// values below here are targets for removal
// values below here are targets for removal
//===========================================================================
//===========================================================================
// The port on PublicAddress where a read-write server will be installed.
// Defaults to 6443 if not set.
ReadWritePort
int
// PublicAddress is the IP address where members of the cluster (kubelet,
// PublicAddress is the IP address where members of the cluster (kubelet,
// kube-proxy, services, etc.) can reach the GenericAPIServer.
// kube-proxy, services, etc.) can reach the GenericAPIServer.
// If nil or 0.0.0.0, the host's default interface will be used.
// If nil or 0.0.0.0, the host's default interface will be used.
...
@@ -250,7 +247,6 @@ type AuthorizationInfo struct {
...
@@ -250,7 +247,6 @@ type AuthorizationInfo struct {
func
NewConfig
(
codecs
serializer
.
CodecFactory
)
*
Config
{
func
NewConfig
(
codecs
serializer
.
CodecFactory
)
*
Config
{
return
&
Config
{
return
&
Config
{
Serializer
:
codecs
,
Serializer
:
codecs
,
ReadWritePort
:
443
,
BuildHandlerChainFunc
:
DefaultBuildHandlerChain
,
BuildHandlerChainFunc
:
DefaultBuildHandlerChain
,
HandlerChainWaitGroup
:
new
(
utilwaitgroup
.
SafeWaitGroup
),
HandlerChainWaitGroup
:
new
(
utilwaitgroup
.
SafeWaitGroup
),
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
DefaultLegacyAPIPrefix
),
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
DefaultLegacyAPIPrefix
),
...
@@ -354,16 +350,21 @@ type CompletedConfig struct {
...
@@ -354,16 +350,21 @@ type CompletedConfig struct {
// Complete fills in any fields not set that are required to have valid data and can be derived
// Complete fills in any fields not set that are required to have valid data and can be derived
// from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.
// from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.
func
(
c
*
Config
)
Complete
(
informers
informers
.
SharedInformerFactory
)
CompletedConfig
{
func
(
c
*
Config
)
Complete
(
informers
informers
.
SharedInformerFactory
)
CompletedConfig
{
host
:=
c
.
ExternalAddress
if
len
(
c
.
ExternalAddress
)
==
0
&&
c
.
PublicAddress
!=
nil
{
if
host
==
""
&&
c
.
PublicAddress
!=
nil
{
c
.
ExternalAddress
=
c
.
PublicAddress
.
String
()
host
=
c
.
PublicAddress
.
String
()
}
}
// if there is no port, and we have a ReadWritePort, use that
// if there is no port, and we listen on one securely, use that one
if
_
,
_
,
err
:=
net
.
SplitHostPort
(
host
);
err
!=
nil
&&
c
.
ReadWritePort
!=
0
{
if
_
,
_
,
err
:=
net
.
SplitHostPort
(
c
.
ExternalAddress
);
err
!=
nil
{
host
=
net
.
JoinHostPort
(
host
,
strconv
.
Itoa
(
c
.
ReadWritePort
))
if
c
.
SecureServing
==
nil
{
glog
.
Fatalf
(
"cannot derive external address port without listening on a secure port."
)
}
_
,
port
,
err
:=
c
.
SecureServing
.
HostPort
()
if
err
!=
nil
{
glog
.
Fatalf
(
"cannot derive external address from the secure port: %v"
,
err
)
}
c
.
ExternalAddress
=
net
.
JoinHostPort
(
c
.
ExternalAddress
,
strconv
.
Itoa
(
port
))
}
}
c
.
ExternalAddress
=
host
if
c
.
OpenAPIConfig
!=
nil
&&
c
.
OpenAPIConfig
.
SecurityDefinitions
!=
nil
{
if
c
.
OpenAPIConfig
!=
nil
&&
c
.
OpenAPIConfig
.
SecurityDefinitions
!=
nil
{
// Setup OpenAPI security: all APIs will have the same authentication for now.
// Setup OpenAPI security: all APIs will have the same authentication for now.
...
@@ -615,3 +616,19 @@ func NewRequestInfoResolver(c *Config) *apirequest.RequestInfoFactory {
...
@@ -615,3 +616,19 @@ func NewRequestInfoResolver(c *Config) *apirequest.RequestInfoFactory {
GrouplessAPIPrefixes
:
legacyAPIPrefixes
,
GrouplessAPIPrefixes
:
legacyAPIPrefixes
,
}
}
}
}
func
(
s
*
SecureServingInfo
)
HostPort
()
(
string
,
int
,
error
)
{
if
s
==
nil
||
s
.
Listener
==
nil
{
return
""
,
0
,
fmt
.
Errorf
(
"no listener found"
)
}
addr
:=
s
.
Listener
.
Addr
()
.
String
()
host
,
portStr
,
err
:=
net
.
SplitHostPort
(
addr
)
if
err
!=
nil
{
return
""
,
0
,
fmt
.
Errorf
(
"failed to get port from listener address %q: %v"
,
addr
,
err
)
}
port
,
err
:=
strconv
.
Atoi
(
portStr
)
if
err
!=
nil
{
return
""
,
0
,
fmt
.
Errorf
(
"invalid non-numeric port %q"
,
portStr
)
}
return
host
,
port
,
nil
}
staging/src/k8s.io/apiserver/pkg/server/options/serving_with_loopback.go
View file @
e32f380f
...
@@ -48,8 +48,6 @@ func (s *SecureServingOptionsWithLoopback) ApplyTo(c *server.Config) error {
...
@@ -48,8 +48,6 @@ func (s *SecureServingOptionsWithLoopback) ApplyTo(c *server.Config) error {
return
nil
return
nil
}
}
c
.
ReadWritePort
=
s
.
BindPort
// create self-signed cert+key with the fake server.LoopbackClientServerNameOverride and
// create self-signed cert+key with the fake server.LoopbackClientServerNameOverride and
// let the server return it when the loopback client connects.
// let the server return it when the loopback client connects.
certPem
,
keyPem
,
err
:=
certutil
.
GenerateSelfSignedCertKey
(
server
.
LoopbackClientServerNameOverride
,
nil
,
nil
)
certPem
,
keyPem
,
err
:=
certutil
.
GenerateSelfSignedCertKey
(
server
.
LoopbackClientServerNameOverride
,
nil
,
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