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
27f3fd2d
Commit
27f3fd2d
authored
Jan 23, 2018
by
hzxuzhonghu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set default enabled admission plugins by official document
parent
4327bc92
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
6 deletions
+20
-6
test-cmd.sh
hack/make-rules/test-cmd.sh
+2
-0
test-update-storage-objects.sh
hack/test-update-storage-objects.sh
+2
-0
plugins.go
pkg/kubeapiserver/options/plugins.go
+12
-3
admission.go
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
+1
-1
admission_test.go
...src/k8s.io/apiserver/pkg/server/options/admission_test.go
+1
-1
apiserver.go
test/e2e_node/services/apiserver.go
+1
-0
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+1
-1
No files found.
hack/make-rules/test-cmd.sh
View file @
27f3fd2d
...
@@ -35,6 +35,7 @@ function run_kube_apiserver() {
...
@@ -35,6 +35,7 @@ function run_kube_apiserver() {
# Admission Controllers to invoke prior to persisting objects in cluster
# Admission Controllers to invoke prior to persisting objects in cluster
ENABLE_ADMISSION_PLUGINS
=
"Initializers,LimitRanger,ResourceQuota"
ENABLE_ADMISSION_PLUGINS
=
"Initializers,LimitRanger,ResourceQuota"
DISABLE_ADMISSION_PLUGINS
=
"ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook"
# Include RBAC (to exercise bootstrapping), and AlwaysAllow to allow all actions
# Include RBAC (to exercise bootstrapping), and AlwaysAllow to allow all actions
AUTHORIZATION_MODE
=
"RBAC,AlwaysAllow"
AUTHORIZATION_MODE
=
"RBAC,AlwaysAllow"
...
@@ -46,6 +47,7 @@ function run_kube_apiserver() {
...
@@ -46,6 +47,7 @@ function run_kube_apiserver() {
--authorization-mode
=
"
${
AUTHORIZATION_MODE
}
"
\
--authorization-mode
=
"
${
AUTHORIZATION_MODE
}
"
\
--secure-port
=
"
${
SECURE_API_PORT
}
"
\
--secure-port
=
"
${
SECURE_API_PORT
}
"
\
--enable-admission-plugins
=
"
${
ENABLE_ADMISSION_PLUGINS
}
"
\
--enable-admission-plugins
=
"
${
ENABLE_ADMISSION_PLUGINS
}
"
\
--disable-admission-plugins
=
"
${
DISABLE_ADMISSION_PLUGINS
}
"
\
--etcd-servers
=
"http://
${
ETCD_HOST
}
:
${
ETCD_PORT
}
"
\
--etcd-servers
=
"http://
${
ETCD_HOST
}
:
${
ETCD_PORT
}
"
\
--runtime-config
=
api/v1
\
--runtime-config
=
api/v1
\
--storage-media-type
=
"
${
KUBE_TEST_API_STORAGE_TYPE
-
}
"
\
--storage-media-type
=
"
${
KUBE_TEST_API_STORAGE_TYPE
-
}
"
\
...
...
hack/test-update-storage-objects.sh
View file @
27f3fd2d
...
@@ -46,6 +46,7 @@ RUNTIME_CONFIG=""
...
@@ -46,6 +46,7 @@ RUNTIME_CONFIG=""
ETCDCTL
=
$(
which etcdctl
)
ETCDCTL
=
$(
which etcdctl
)
KUBECTL
=
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
KUBECTL
=
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
UPDATE_ETCD_OBJECTS_SCRIPT
=
"
${
KUBE_ROOT
}
/cluster/update-storage-objects.sh"
UPDATE_ETCD_OBJECTS_SCRIPT
=
"
${
KUBE_ROOT
}
/cluster/update-storage-objects.sh"
DISABLE_ADMISSION_PLUGINS
=
"ServiceAccount,NamespaceLifecycle,LimitRanger,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,PersistentVolumeLabel,DefaultStorageClass"
function
startApiServer
()
{
function
startApiServer
()
{
local
storage_versions
=
${
1
:-
""
}
local
storage_versions
=
${
1
:-
""
}
...
@@ -64,6 +65,7 @@ function startApiServer() {
...
@@ -64,6 +65,7 @@ function startApiServer() {
--etcd-servers
=
"http://
${
ETCD_HOST
}
:
${
ETCD_PORT
}
"
\
--etcd-servers
=
"http://
${
ETCD_HOST
}
:
${
ETCD_PORT
}
"
\
--etcd-prefix
=
"/
${
ETCD_PREFIX
}
"
\
--etcd-prefix
=
"/
${
ETCD_PREFIX
}
"
\
--runtime-config
=
"
${
RUNTIME_CONFIG
}
"
\
--runtime-config
=
"
${
RUNTIME_CONFIG
}
"
\
--disable-admission-plugins
=
"
${
DISABLE_ADMISSION_PLUGINS
}
"
\
--cert-dir
=
"
${
TMPDIR
:-
/tmp/
}
"
\
--cert-dir
=
"
${
TMPDIR
:-
/tmp/
}
"
\
--service-cluster-ip-range
=
"10.0.0.0/24"
\
--service-cluster-ip-range
=
"10.0.0.0/24"
\
--storage-versions
=
"
${
storage_versions
}
"
\
--storage-versions
=
"
${
storage_versions
}
"
\
...
...
pkg/kubeapiserver/options/plugins.go
View file @
27f3fd2d
...
@@ -130,8 +130,17 @@ func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
...
@@ -130,8 +130,17 @@ func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
// DefaultOffAdmissionPlugins get admission plugins off by default for kube-apiserver.
// DefaultOffAdmissionPlugins get admission plugins off by default for kube-apiserver.
func
DefaultOffAdmissionPlugins
()
sets
.
String
{
func
DefaultOffAdmissionPlugins
()
sets
.
String
{
defaultOffPlugins
:=
sets
.
NewString
(
AllOrderedPlugins
...
)
defaultOnPlugins
:=
sets
.
NewString
(
defaultOffPlugins
.
Delete
(
lifecycle
.
PluginName
)
lifecycle
.
PluginName
,
//NamespaceLifecycle
limitranger
.
PluginName
,
//LimitRanger
serviceaccount
.
PluginName
,
//ServiceAccount
label
.
PluginName
,
//PersistentVolumeLabel
setdefault
.
PluginName
,
//DefaultStorageClass
defaulttolerationseconds
.
PluginName
,
//DefaultTolerationSeconds
mutatingwebhook
.
PluginName
,
//MutatingAdmissionWebhook
validatingwebhook
.
PluginName
,
//ValidatingAdmissionWebhook
resourcequota
.
PluginName
,
//ResourceQuota
)
return
defaultOffPlugins
return
sets
.
NewString
(
AllOrderedPlugins
...
)
.
Difference
(
defaultOnPlugins
)
}
}
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
View file @
27f3fd2d
...
@@ -79,7 +79,7 @@ func NewAdmissionOptions() *AdmissionOptions {
...
@@ -79,7 +79,7 @@ func NewAdmissionOptions() *AdmissionOptions {
// after all the mutating ones, so their relative order in this list
// after all the mutating ones, so their relative order in this list
// doesn't matter.
// doesn't matter.
RecommendedPluginOrder
:
[]
string
{
lifecycle
.
PluginName
,
initialization
.
PluginName
,
mutatingwebhook
.
PluginName
,
validatingwebhook
.
PluginName
},
RecommendedPluginOrder
:
[]
string
{
lifecycle
.
PluginName
,
initialization
.
PluginName
,
mutatingwebhook
.
PluginName
,
validatingwebhook
.
PluginName
},
DefaultOffPlugins
:
sets
.
NewString
(
initialization
.
PluginName
,
mutatingwebhook
.
PluginName
,
validatingwebhook
.
PluginName
),
DefaultOffPlugins
:
sets
.
NewString
(
initialization
.
PluginName
),
}
}
server
.
RegisterAllAdmissionPlugins
(
options
.
Plugins
)
server
.
RegisterAllAdmissionPlugins
(
options
.
Plugins
)
return
options
return
options
...
...
staging/src/k8s.io/apiserver/pkg/server/options/admission_test.go
View file @
27f3fd2d
...
@@ -36,7 +36,7 @@ func TestEnabledPluginNames(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestEnabledPluginNames(t *testing.T) {
}{
}{
// scenario 0: check if a call to enabledPluginNames sets expected values.
// scenario 0: check if a call to enabledPluginNames sets expected values.
{
{
expectedPluginNames
:
[]
string
{
"NamespaceLifecycle"
},
expectedPluginNames
:
[]
string
{
"NamespaceLifecycle"
,
"MutatingAdmissionWebhook"
,
"ValidatingAdmissionWebhook"
},
},
},
// scenario 1: use default off plugins if no specified
// scenario 1: use default off plugins if no specified
...
...
test/e2e_node/services/apiserver.go
View file @
27f3fd2d
...
@@ -52,6 +52,7 @@ func (a *APIServer) Start() error {
...
@@ -52,6 +52,7 @@ func (a *APIServer) Start() error {
}
}
config
.
ServiceClusterIPRange
=
*
ipnet
config
.
ServiceClusterIPRange
=
*
ipnet
config
.
AllowPrivileged
=
true
config
.
AllowPrivileged
=
true
config
.
Admission
.
GenericAdmission
.
DisablePlugins
=
[]
string
{
"ServiceAccount"
}
errCh
:=
make
(
chan
error
)
errCh
:=
make
(
chan
error
)
go
func
()
{
go
func
()
{
defer
close
(
errCh
)
defer
close
(
errCh
)
...
...
test/integration/etcd/etcd_storage_path_test.go
View file @
27f3fd2d
...
@@ -728,13 +728,13 @@ func startRealMasterOrDie(t *testing.T, certDir string) (*allClient, clientv3.KV
...
@@ -728,13 +728,13 @@ func startRealMasterOrDie(t *testing.T, certDir string) (*allClient, clientv3.KV
}
}
kubeAPIServerOptions
:=
options
.
NewServerRunOptions
()
kubeAPIServerOptions
:=
options
.
NewServerRunOptions
()
kubeAPIServerOptions
.
SecureServing
.
Listener
=
listener
kubeAPIServerOptions
.
SecureServing
.
Listener
=
listener
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
Etcd
.
DefaultStorageMediaType
=
runtime
.
ContentTypeJSON
// TODO use protobuf?
kubeAPIServerOptions
.
Etcd
.
DefaultStorageMediaType
=
runtime
.
ContentTypeJSON
// TODO use protobuf?
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
Authorization
.
Mode
=
"RBAC"
kubeAPIServerOptions
.
Authorization
.
Mode
=
"RBAC"
kubeAPIServerOptions
.
Admission
.
GenericAdmission
.
DisablePlugins
=
[]
string
{
"ServiceAccount"
}
tunneler
,
proxyTransport
,
err
:=
app
.
CreateNodeDialer
(
kubeAPIServerOptions
)
tunneler
,
proxyTransport
,
err
:=
app
.
CreateNodeDialer
(
kubeAPIServerOptions
)
if
err
!=
nil
{
if
err
!=
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