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
de9706bc
Commit
de9706bc
authored
Apr 18, 2017
by
p0lyn0mial
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out AdmissionOptions
In the long term AdmissionOptions will accepts various dependencies and spit out AdmissionControl
parent
4e172303
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
24 deletions
+64
-24
options.go
cmd/kube-apiserver/app/options/options.go
+4
-1
server.go
cmd/kube-apiserver/app/server.go
+3
-3
options.go
federation/cmd/federation-apiserver/app/options/options.go
+4
-1
server.go
federation/cmd/federation-apiserver/app/server.go
+2
-2
admission.go
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
+49
-0
server_run_options.go
...k8s.io/apiserver/pkg/server/options/server_run_options.go
+2
-17
No files found.
cmd/kube-apiserver/app/options/options.go
View file @
de9706bc
...
...
@@ -48,6 +48,7 @@ type ServerRunOptions struct {
InsecureServing
*
kubeoptions
.
InsecureServingOptions
Audit
*
genericoptions
.
AuditLogOptions
Features
*
genericoptions
.
FeatureOptions
Admission
*
genericoptions
.
AdmissionOptions
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
...
...
@@ -72,12 +73,13 @@ type ServerRunOptions struct {
// NewServerRunOptions creates a new ServerRunOptions object with default parameters
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(
&
kubeapiserveradmission
.
Plugins
),
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
kubeoptions
.
DefaultEtcdPathPrefix
,
api
.
Scheme
,
nil
)),
SecureServing
:
kubeoptions
.
NewSecureServingOptions
(),
InsecureServing
:
kubeoptions
.
NewInsecureServingOptions
(),
Audit
:
genericoptions
.
NewAuditLogOptions
(),
Features
:
genericoptions
.
NewFeatureOptions
(),
Admission
:
genericoptions
.
NewAdmissionOptions
(
&
kubeapiserveradmission
.
Plugins
),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
...
...
@@ -129,6 +131,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
StorageSerialization
.
AddFlags
(
fs
)
s
.
APIEnablement
.
AddFlags
(
fs
)
s
.
Admission
.
AddFlags
(
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/server.go
View file @
de9706bc
...
...
@@ -360,7 +360,7 @@ func BuildGenericConfig(s *options.ServerRunOptions) (*genericapiserver.Config,
}
genericConfig
.
AdmissionControl
,
err
=
BuildAdmission
(
s
,
s
.
GenericServerRunOptions
.
Admission
Plugins
,
s
.
Admission
.
Plugins
,
client
,
sharedInformers
,
genericConfig
.
Authorizer
,
...
...
@@ -374,7 +374,7 @@ func BuildGenericConfig(s *options.ServerRunOptions) (*genericapiserver.Config,
// BuildAdmission constructs the admission chain
func
BuildAdmission
(
s
*
options
.
ServerRunOptions
,
plugins
*
admission
.
Plugins
,
client
internalclientset
.
Interface
,
sharedInformers
informers
.
SharedInformerFactory
,
apiAuthorizer
authorizer
.
Authorizer
)
(
admission
.
Interface
,
error
)
{
admissionControlPluginNames
:=
strings
.
Split
(
s
.
GenericServerRunOptions
.
Admission
Control
,
","
)
admissionControlPluginNames
:=
strings
.
Split
(
s
.
Admission
.
Control
,
","
)
var
cloudConfig
[]
byte
var
err
error
...
...
@@ -387,7 +387,7 @@ func BuildAdmission(s *options.ServerRunOptions, plugins *admission.Plugins, cli
// TODO: use a dynamic restmapper. See https://github.com/kubernetes/kubernetes/pull/42615.
restMapper
:=
api
.
Registry
.
RESTMapper
()
pluginInitializer
:=
kubeapiserveradmission
.
NewPluginInitializer
(
client
,
sharedInformers
,
apiAuthorizer
,
cloudConfig
,
restMapper
)
admissionConfigProvider
,
err
:=
admission
.
ReadAdmissionConfiguration
(
admissionControlPluginNames
,
s
.
GenericServerRunOptions
.
Admission
ControlConfigFile
)
admissionConfigProvider
,
err
:=
admission
.
ReadAdmissionConfiguration
(
admissionControlPluginNames
,
s
.
Admission
.
ControlConfigFile
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to read plugin config: %v"
,
err
)
}
...
...
federation/cmd/federation-apiserver/app/options/options.go
View file @
de9706bc
...
...
@@ -40,6 +40,7 @@ type ServerRunOptions struct {
InsecureServing
*
kubeoptions
.
InsecureServingOptions
Audit
*
genericoptions
.
AuditLogOptions
Features
*
genericoptions
.
FeatureOptions
Admission
*
genericoptions
.
AdmissionOptions
Authentication
*
kubeoptions
.
BuiltInAuthenticationOptions
Authorization
*
kubeoptions
.
BuiltInAuthorizationOptions
CloudProvider
*
kubeoptions
.
CloudProviderOptions
...
...
@@ -52,12 +53,13 @@ type ServerRunOptions struct {
// NewServerRunOptions creates a new ServerRunOptions object with default values.
func
NewServerRunOptions
()
*
ServerRunOptions
{
s
:=
ServerRunOptions
{
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(
&
kubeapiserveradmission
.
Plugins
),
GenericServerRunOptions
:
genericoptions
.
NewServerRunOptions
(),
Etcd
:
genericoptions
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
kubeoptions
.
DefaultEtcdPathPrefix
,
api
.
Scheme
,
nil
)),
SecureServing
:
kubeoptions
.
NewSecureServingOptions
(),
InsecureServing
:
kubeoptions
.
NewInsecureServingOptions
(),
Audit
:
genericoptions
.
NewAuditLogOptions
(),
Features
:
genericoptions
.
NewFeatureOptions
(),
Admission
:
genericoptions
.
NewAdmissionOptions
(
&
kubeapiserveradmission
.
Plugins
),
Authentication
:
kubeoptions
.
NewBuiltInAuthenticationOptions
()
.
WithAll
(),
Authorization
:
kubeoptions
.
NewBuiltInAuthorizationOptions
(),
CloudProvider
:
kubeoptions
.
NewCloudProviderOptions
(),
...
...
@@ -85,6 +87,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
s
.
CloudProvider
.
AddFlags
(
fs
)
s
.
StorageSerialization
.
AddFlags
(
fs
)
s
.
APIEnablement
.
AddFlags
(
fs
)
s
.
Admission
.
AddFlags
(
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 @
de9706bc
...
...
@@ -185,7 +185,7 @@ func NonBlockingRun(s *options.ServerRunOptions, stopCh <-chan struct{}) error {
return
fmt
.
Errorf
(
"invalid Authorization Config: %v"
,
err
)
}
admissionControlPluginNames
:=
strings
.
Split
(
s
.
GenericServerRunOptions
.
Admission
Control
,
","
)
admissionControlPluginNames
:=
strings
.
Split
(
s
.
Admission
.
Control
,
","
)
var
cloudConfig
[]
byte
if
s
.
CloudProvider
.
CloudConfigFile
!=
""
{
...
...
@@ -195,7 +195,7 @@ func NonBlockingRun(s *options.ServerRunOptions, stopCh <-chan struct{}) error {
}
}
pluginInitializer
:=
kubeapiserveradmission
.
NewPluginInitializer
(
client
,
sharedInformers
,
apiAuthorizer
,
cloudConfig
,
nil
)
admissionConfigProvider
,
err
:=
admission
.
ReadAdmissionConfiguration
(
admissionControlPluginNames
,
s
.
GenericServerRunOptions
.
Admission
ControlConfigFile
)
admissionConfigProvider
,
err
:=
admission
.
ReadAdmissionConfiguration
(
admissionControlPluginNames
,
s
.
Admission
.
ControlConfigFile
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read plugin config: %v"
,
err
)
}
...
...
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
0 → 100644
View file @
de9706bc
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
options
import
(
"strings"
"github.com/spf13/pflag"
"k8s.io/apiserver/pkg/admission"
)
// AdmissionOptions holds the admission options
type
AdmissionOptions
struct
{
Control
string
ControlConfigFile
string
Plugins
*
admission
.
Plugins
}
// NewAdmissionOptions creates a new instance of AdmissionOptions
func
NewAdmissionOptions
(
plugins
*
admission
.
Plugins
)
*
AdmissionOptions
{
return
&
AdmissionOptions
{
Plugins
:
plugins
,
Control
:
"AlwaysAdmit"
,
}
}
// AddFlags adds flags related to admission for a specific APIServer to the specified FlagSet
func
(
a
*
AdmissionOptions
)
AddFlags
(
fs
*
pflag
.
FlagSet
)
{
fs
.
StringVar
(
&
a
.
Control
,
"admission-control"
,
a
.
Control
,
""
+
"Ordered list of plug-ins to do admission control of resources into cluster. "
+
"Comma-delimited list of: "
+
strings
.
Join
(
a
.
Plugins
.
Registered
(),
", "
)
+
"."
)
fs
.
StringVar
(
&
a
.
ControlConfigFile
,
"admission-control-config-file"
,
a
.
ControlConfigFile
,
"File with admission control configuration."
)
}
staging/src/k8s.io/apiserver/pkg/server/options/server_run_options.go
View file @
de9706bc
...
...
@@ -19,11 +19,9 @@ package options
import
(
"fmt"
"net"
"strings"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/server"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
...
...
@@ -35,9 +33,7 @@ import (
// ServerRunOptions contains the options while running a generic api server.
type
ServerRunOptions
struct
{
AdmissionControl
string
AdmissionControlConfigFile
string
AdvertiseAddress
net
.
IP
AdvertiseAddress
net
.
IP
CorsAllowedOriginList
[]
string
ExternalHost
string
...
...
@@ -46,18 +42,14 @@ type ServerRunOptions struct {
MinRequestTimeout
int
TargetRAMMB
int
WatchCacheSizes
[]
string
AdmissionPlugins
*
admission
.
Plugins
}
func
NewServerRunOptions
(
admissionPlugins
*
admission
.
Plugins
)
*
ServerRunOptions
{
func
NewServerRunOptions
()
*
ServerRunOptions
{
defaults
:=
server
.
NewConfig
(
serializer
.
CodecFactory
{})
return
&
ServerRunOptions
{
AdmissionControl
:
"AlwaysAdmit"
,
MaxRequestsInFlight
:
defaults
.
MaxRequestsInFlight
,
MaxMutatingRequestsInFlight
:
defaults
.
MaxMutatingRequestsInFlight
,
MinRequestTimeout
:
defaults
.
MinRequestTimeout
,
AdmissionPlugins
:
admissionPlugins
,
}
}
...
...
@@ -96,13 +88,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
// arrange these text blocks sensibly. Grrr.
fs
.
StringVar
(
&
s
.
AdmissionControl
,
"admission-control"
,
s
.
AdmissionControl
,
""
+
"Ordered list of plug-ins to do admission control of resources into cluster. "
+
"Comma-delimited list of: "
+
strings
.
Join
(
s
.
AdmissionPlugins
.
Registered
(),
", "
)
+
"."
)
fs
.
StringVar
(
&
s
.
AdmissionControlConfigFile
,
"admission-control-config-file"
,
s
.
AdmissionControlConfigFile
,
"File with admission control configuration."
)
fs
.
IPVar
(
&
s
.
AdvertiseAddress
,
"advertise-address"
,
s
.
AdvertiseAddress
,
""
+
"The IP address on which to advertise the apiserver to members of the cluster. This "
+
"address must be reachable by the rest of the cluster. If blank, the --bind-address "
+
...
...
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