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
ab3ce27f
Commit
ab3ce27f
authored
Oct 25, 2016
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make master+federation ServerRunOptions embeddings explicit
parent
b7985277
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
57 deletions
+57
-57
options.go
cmd/kube-apiserver/app/options/options.go
+5
-5
options_test.go
cmd/kube-apiserver/app/options/options_test.go
+2
-2
server.go
cmd/kube-apiserver/app/server.go
+0
-0
server_test.go
cmd/kube-apiserver/app/server_test.go
+1
-1
options.go
federation/cmd/federation-apiserver/app/options/options.go
+6
-6
server.go
federation/cmd/federation-apiserver/app/server.go
+37
-37
apiserver.go
test/e2e_node/services/apiserver.go
+2
-2
server_test.go
test/integration/federation/server_test.go
+4
-4
No files found.
cmd/kube-apiserver/app/options/options.go
View file @
ab3ce27f
...
...
@@ -30,7 +30,7 @@ import (
// ServerRunOptions runs a kubernetes api server.
type
ServerRunOptions
struct
{
*
genericoptions
.
ServerRunOptions
GenericServerRunOptions
*
genericoptions
.
ServerRunOptions
AllowPrivileged
bool
EventTTL
time
.
Duration
KubeletConfig
kubeletclient
.
KubeletClientConfig
...
...
@@ -46,8 +46,8 @@ type ServerRunOptions struct {
// NewServerRunOptions creates a new ServerRunOptions object with default parameters
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
ServerRunOptions
:
genericoptions
.
NewServerRunOptions
()
.
WithEtcdOptions
(),
EventTTL
:
1
*
time
.
Hour
,
Generic
ServerRunOptions
:
genericoptions
.
NewServerRunOptions
()
.
WithEtcdOptions
(),
EventTTL
:
1
*
time
.
Hour
,
KubeletConfig
:
kubeletclient
.
KubeletClientConfig
{
Port
:
ports
.
KubeletPort
,
EnableHttps
:
true
,
...
...
@@ -61,9 +61,9 @@ func NewServerRunOptions() *ServerRunOptions {
// AddFlags adds flags for a specific APIServer to the specified FlagSet
func
(
s
*
ServerRunOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
// Add the generic flags.
s
.
ServerRunOptions
.
AddUniversalFlags
(
fs
)
s
.
Generic
ServerRunOptions
.
AddUniversalFlags
(
fs
)
//Add etcd specific flags.
s
.
ServerRunOptions
.
AddEtcdStorageFlags
(
fs
)
s
.
Generic
ServerRunOptions
.
AddEtcdStorageFlags
(
fs
)
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
...
...
cmd/kube-apiserver/app/options/options_test.go
View file @
ab3ce27f
...
...
@@ -28,7 +28,7 @@ func TestAddFlagsFlag(t *testing.T) {
f
:=
pflag
.
NewFlagSet
(
"addflagstest"
,
pflag
.
ContinueOnError
)
s
:=
NewServerRunOptions
()
s
.
AddFlags
(
f
)
if
s
.
EnableSwaggerUI
{
if
s
.
GenericServerRunOptions
.
EnableSwaggerUI
{
t
.
Errorf
(
"Expected s.EnableSwaggerUI to be false by default"
)
}
...
...
@@ -36,7 +36,7 @@ func TestAddFlagsFlag(t *testing.T) {
"--enable-swagger-ui=true"
,
}
f
.
Parse
(
args
)
if
!
s
.
EnableSwaggerUI
{
if
!
s
.
GenericServerRunOptions
.
EnableSwaggerUI
{
t
.
Errorf
(
"Expected s.EnableSwaggerUI to be true"
)
}
}
cmd/kube-apiserver/app/server.go
View file @
ab3ce27f
This diff is collapsed.
Click to expand it.
cmd/kube-apiserver/app/server_test.go
View file @
ab3ce27f
...
...
@@ -24,7 +24,7 @@ import (
)
func
TestLongRunningRequestRegexp
(
t
*
testing
.
T
)
{
regexp
:=
regexp
.
MustCompile
(
options
.
NewServerRunOptions
()
.
LongRunningRequestRE
)
regexp
:=
regexp
.
MustCompile
(
options
.
NewServerRunOptions
()
.
GenericServerRunOptions
.
LongRunningRequestRE
)
dontMatch
:=
[]
string
{
"/api/v1/watch-namespace/"
,
"/api/v1/namespace-proxy/"
,
...
...
federation/cmd/federation-apiserver/app/options/options.go
View file @
ab3ce27f
...
...
@@ -27,15 +27,15 @@ import (
// Runtime options for the federation-apiserver.
type
ServerRunOptions
struct
{
*
genericoptions
.
ServerRunOptions
EventTTL
time
.
Duration
GenericServerRunOptions
*
genericoptions
.
ServerRunOptions
EventTTL
time
.
Duration
}
// NewServerRunOptions creates a new ServerRunOptions object with default values.
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
ServerRunOptions
:
genericoptions
.
NewServerRunOptions
()
.
WithEtcdOptions
(),
EventTTL
:
1
*
time
.
Hour
,
Generic
ServerRunOptions
:
genericoptions
.
NewServerRunOptions
()
.
WithEtcdOptions
(),
EventTTL
:
1
*
time
.
Hour
,
}
return
&
s
}
...
...
@@ -43,9 +43,9 @@ func NewServerRunOptions() *ServerRunOptions {
// AddFlags adds flags for ServerRunOptions fields to be specified via FlagSet.
func
(
s
*
ServerRunOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
// Add the generic flags.
s
.
ServerRunOptions
.
AddUniversalFlags
(
fs
)
s
.
Generic
ServerRunOptions
.
AddUniversalFlags
(
fs
)
//Add etcd specific flags.
s
.
ServerRunOptions
.
AddEtcdStorageFlags
(
fs
)
s
.
Generic
ServerRunOptions
.
AddEtcdStorageFlags
(
fs
)
fs
.
DurationVar
(
&
s
.
EventTTL
,
"event-ttl"
,
s
.
EventTTL
,
"Amount of time to retain events. Default is 1h."
)
...
...
federation/cmd/federation-apiserver/app/server.go
View file @
ab3ce27f
...
...
@@ -67,11 +67,11 @@ cluster's shared state through which all other components interact.`,
// Run runs the specified APIServer. This should never exit.
func
Run
(
s
*
options
.
ServerRunOptions
)
error
{
genericvalidation
.
VerifyEtcdServersList
(
s
.
ServerRunOptions
)
genericapiserver
.
DefaultAndValidateRunOptions
(
s
.
ServerRunOptions
)
genericvalidation
.
VerifyEtcdServersList
(
s
.
Generic
ServerRunOptions
)
genericapiserver
.
DefaultAndValidateRunOptions
(
s
.
Generic
ServerRunOptions
)
genericConfig
:=
genericapiserver
.
NewConfig
()
.
// create the new config
ApplyOptions
(
s
.
ServerRunOptions
)
.
// apply the options selected
Complete
()
// set default values based on the known values
ApplyOptions
(
s
.
Generic
ServerRunOptions
)
.
// apply the options selected
Complete
()
// set default values based on the known values
if
err
:=
genericConfig
.
MaybeGenerateServingCerts
();
err
!=
nil
{
glog
.
Fatalf
(
"Failed to generate service certificate: %v"
,
err
)
...
...
@@ -80,23 +80,23 @@ func Run(s *options.ServerRunOptions) error {
// TODO: register cluster federation resources here.
resourceConfig
:=
genericapiserver
.
NewResourceConfig
()
if
s
.
StorageConfig
.
DeserializationCacheSize
==
0
{
if
s
.
GenericServerRunOptions
.
StorageConfig
.
DeserializationCacheSize
==
0
{
// When size of cache is not explicitly set, set it to 50000
s
.
StorageConfig
.
DeserializationCacheSize
=
50000
s
.
GenericServerRunOptions
.
StorageConfig
.
DeserializationCacheSize
=
50000
}
storageGroupsToEncodingVersion
,
err
:=
s
.
StorageGroupsToEncodingVersion
()
storageGroupsToEncodingVersion
,
err
:=
s
.
GenericServerRunOptions
.
StorageGroupsToEncodingVersion
()
if
err
!=
nil
{
glog
.
Fatalf
(
"error generating storage version map: %s"
,
err
)
}
storageFactory
,
err
:=
genericapiserver
.
BuildDefaultStorageFactory
(
s
.
StorageConfig
,
s
.
DefaultStorageMediaType
,
api
.
Codecs
,
s
.
GenericServerRunOptions
.
StorageConfig
,
s
.
GenericServerRunOption
s
.
DefaultStorageMediaType
,
api
.
Codecs
,
genericapiserver
.
NewDefaultResourceEncodingConfig
(),
storageGroupsToEncodingVersion
,
[]
unversioned
.
GroupVersionResource
{},
resourceConfig
,
s
.
RuntimeConfig
)
[]
unversioned
.
GroupVersionResource
{},
resourceConfig
,
s
.
GenericServerRunOptions
.
RuntimeConfig
)
if
err
!=
nil
{
glog
.
Fatalf
(
"error in initializing storage factory: %s"
,
err
)
}
for
_
,
override
:=
range
s
.
EtcdServersOverrides
{
for
_
,
override
:=
range
s
.
GenericServerRunOptions
.
EtcdServersOverrides
{
tokens
:=
strings
.
Split
(
override
,
"#"
)
if
len
(
tokens
)
!=
2
{
glog
.
Errorf
(
"invalid value of etcd server overrides: %s"
,
override
)
...
...
@@ -117,49 +117,49 @@ func Run(s *options.ServerRunOptions) error {
}
apiAuthenticator
,
securityDefinitions
,
err
:=
authenticator
.
New
(
authenticator
.
AuthenticatorConfig
{
Anonymous
:
s
.
AnonymousAuth
,
AnyToken
:
s
.
EnableAnyToken
,
BasicAuthFile
:
s
.
BasicAuthFile
,
ClientCAFile
:
s
.
ClientCAFile
,
TokenAuthFile
:
s
.
TokenAuthFile
,
OIDCIssuerURL
:
s
.
OIDCIssuerURL
,
OIDCClientID
:
s
.
OIDCClientID
,
OIDCCAFile
:
s
.
OIDCCAFile
,
OIDCUsernameClaim
:
s
.
OIDCUsernameClaim
,
OIDCGroupsClaim
:
s
.
OIDCGroupsClaim
,
KeystoneURL
:
s
.
KeystoneURL
,
RequestHeaderConfig
:
s
.
AuthenticationRequestHeaderConfig
(),
Anonymous
:
s
.
GenericServerRunOptions
.
AnonymousAuth
,
AnyToken
:
s
.
GenericServerRunOptions
.
EnableAnyToken
,
BasicAuthFile
:
s
.
GenericServerRunOptions
.
BasicAuthFile
,
ClientCAFile
:
s
.
GenericServerRunOptions
.
ClientCAFile
,
TokenAuthFile
:
s
.
GenericServerRunOptions
.
TokenAuthFile
,
OIDCIssuerURL
:
s
.
GenericServerRunOptions
.
OIDCIssuerURL
,
OIDCClientID
:
s
.
GenericServerRunOptions
.
OIDCClientID
,
OIDCCAFile
:
s
.
GenericServerRunOptions
.
OIDCCAFile
,
OIDCUsernameClaim
:
s
.
GenericServerRunOptions
.
OIDCUsernameClaim
,
OIDCGroupsClaim
:
s
.
GenericServerRunOptions
.
OIDCGroupsClaim
,
KeystoneURL
:
s
.
GenericServerRunOptions
.
KeystoneURL
,
RequestHeaderConfig
:
s
.
GenericServerRunOptions
.
AuthenticationRequestHeaderConfig
(),
})
if
err
!=
nil
{
glog
.
Fatalf
(
"Invalid Authentication Config: %v"
,
err
)
}
privilegedLoopbackToken
:=
uuid
.
NewRandom
()
.
String
()
selfClientConfig
,
err
:=
s
.
NewSelfClientConfig
(
privilegedLoopbackToken
)
selfClientConfig
,
err
:=
s
.
GenericServerRunOptions
.
NewSelfClientConfig
(
privilegedLoopbackToken
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to create clientset: %v"
,
err
)
}
client
,
err
:=
s
.
NewSelfClient
(
privilegedLoopbackToken
)
client
,
err
:=
s
.
GenericServerRunOptions
.
NewSelfClient
(
privilegedLoopbackToken
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to create clientset: %v"
,
err
)
}
sharedInformers
:=
informers
.
NewSharedInformerFactory
(
client
,
10
*
time
.
Minute
)
authorizationConfig
:=
authorizer
.
AuthorizationConfig
{
PolicyFile
:
s
.
AuthorizationPolicyFile
,
WebhookConfigFile
:
s
.
AuthorizationWebhookConfigFile
,
WebhookCacheAuthorizedTTL
:
s
.
AuthorizationWebhookCacheAuthorizedTTL
,
WebhookCacheUnauthorizedTTL
:
s
.
AuthorizationWebhookCacheUnauthorizedTTL
,
RBACSuperUser
:
s
.
AuthorizationRBACSuperUser
,
PolicyFile
:
s
.
GenericServerRunOptions
.
AuthorizationPolicyFile
,
WebhookConfigFile
:
s
.
GenericServerRunOptions
.
AuthorizationWebhookConfigFile
,
WebhookCacheAuthorizedTTL
:
s
.
GenericServerRunOptions
.
AuthorizationWebhookCacheAuthorizedTTL
,
WebhookCacheUnauthorizedTTL
:
s
.
GenericServerRunOptions
.
AuthorizationWebhookCacheUnauthorizedTTL
,
RBACSuperUser
:
s
.
GenericServerRunOptions
.
AuthorizationRBACSuperUser
,
InformerFactory
:
sharedInformers
,
}
authorizationModeNames
:=
strings
.
Split
(
s
.
AuthorizationMode
,
","
)
authorizationModeNames
:=
strings
.
Split
(
s
.
GenericServerRunOptions
.
AuthorizationMode
,
","
)
apiAuthorizer
,
err
:=
authorizer
.
NewAuthorizerFromAuthorizationConfig
(
authorizationModeNames
,
authorizationConfig
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Invalid Authorization Config: %v"
,
err
)
}
admissionControlPluginNames
:=
strings
.
Split
(
s
.
AdmissionControl
,
","
)
admissionControlPluginNames
:=
strings
.
Split
(
s
.
GenericServerRunOptions
.
AdmissionControl
,
","
)
// TODO(dims): We probably need to add an option "EnableLoopbackToken"
if
apiAuthenticator
!=
nil
{
...
...
@@ -180,7 +180,7 @@ func Run(s *options.ServerRunOptions) error {
pluginInitializer
:=
admission
.
NewPluginInitializer
(
sharedInformers
,
apiAuthorizer
)
admissionController
,
err
:=
admission
.
NewFromPlugins
(
client
,
admissionControlPluginNames
,
s
.
AdmissionControlConfigFile
,
pluginInitializer
)
admissionController
,
err
:=
admission
.
NewFromPlugins
(
client
,
admissionControlPluginNames
,
s
.
GenericServerRunOptions
.
AdmissionControlConfigFile
,
pluginInitializer
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to initialize plugins: %v"
,
err
)
}
...
...
@@ -197,9 +197,9 @@ func Run(s *options.ServerRunOptions) error {
genericConfig
.
OpenAPIConfig
.
SecurityDefinitions
=
securityDefinitions
// TODO: Move this to generic api server (Need to move the command line flag).
if
s
.
EnableWatchCache
{
cachesize
.
InitializeWatchCacheSizes
(
s
.
TargetRAMMB
)
cachesize
.
SetWatchCacheSizes
(
s
.
WatchCacheSizes
)
if
s
.
GenericServerRunOptions
.
EnableWatchCache
{
cachesize
.
InitializeWatchCacheSizes
(
s
.
GenericServerRunOptions
.
TargetRAMMB
)
cachesize
.
SetWatchCacheSizes
(
s
.
GenericServerRunOptions
.
WatchCacheSizes
)
}
m
,
err
:=
genericConfig
.
New
()
...
...
@@ -212,9 +212,9 @@ func Run(s *options.ServerRunOptions) error {
restOptionsFactory
:=
restOptionsFactory
{
storageFactory
:
storageFactory
,
deleteCollectionWorkers
:
s
.
DeleteCollectionWorkers
,
deleteCollectionWorkers
:
s
.
GenericServerRunOptions
.
DeleteCollectionWorkers
,
}
if
s
.
EnableWatchCache
{
if
s
.
GenericServerRunOptions
.
EnableWatchCache
{
restOptionsFactory
.
storageDecorator
=
registry
.
StorageWithCacher
}
else
{
restOptionsFactory
.
storageDecorator
=
generic
.
UndecoratedStorage
...
...
test/e2e_node/services/apiserver.go
View file @
ab3ce27f
...
...
@@ -41,12 +41,12 @@ func NewAPIServer() *APIServer {
// Start starts the apiserver, returns when apiserver is ready.
func
(
a
*
APIServer
)
Start
()
error
{
config
:=
options
.
NewServerRunOptions
()
config
.
StorageConfig
.
ServerList
=
[]
string
{
getEtcdClientURL
()}
config
.
GenericServerRunOptions
.
StorageConfig
.
ServerList
=
[]
string
{
getEtcdClientURL
()}
_
,
ipnet
,
err
:=
net
.
ParseCIDR
(
clusterIPRange
)
if
err
!=
nil
{
return
err
}
config
.
ServiceClusterIPRange
=
*
ipnet
config
.
GenericServerRunOptions
.
ServiceClusterIPRange
=
*
ipnet
config
.
AllowPrivileged
=
true
errCh
:=
make
(
chan
error
)
go
func
()
{
...
...
test/integration/federation/server_test.go
View file @
ab3ce27f
...
...
@@ -37,7 +37,7 @@ import (
)
func
TestLongRunningRequestRegexp
(
t
*
testing
.
T
)
{
regexp
:=
regexp
.
MustCompile
(
options
.
NewServerRunOptions
()
.
LongRunningRequestRE
)
regexp
:=
regexp
.
MustCompile
(
options
.
NewServerRunOptions
()
.
GenericServerRunOptions
.
LongRunningRequestRE
)
dontMatch
:=
[]
string
{
"/api/v1/watch-namespace/"
,
"/api/v1/namespace-proxy/"
,
...
...
@@ -86,10 +86,10 @@ var groupVersions = []unversioned.GroupVersion{
func
TestRun
(
t
*
testing
.
T
)
{
s
:=
options
.
NewServerRunOptions
()
s
.
InsecurePort
=
insecurePort
s
.
GenericServerRunOptions
.
InsecurePort
=
insecurePort
_
,
ipNet
,
_
:=
net
.
ParseCIDR
(
"10.10.10.0/24"
)
s
.
ServiceClusterIPRange
=
*
ipNet
s
.
StorageConfig
.
ServerList
=
[]
string
{
"http://localhost:2379"
}
s
.
GenericServerRunOptions
.
ServiceClusterIPRange
=
*
ipNet
s
.
GenericServerRunOptions
.
StorageConfig
.
ServerList
=
[]
string
{
"http://localhost:2379"
}
go
func
()
{
if
err
:=
app
.
Run
(
s
);
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the server: %v"
,
err
)
...
...
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