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
82225fd9
Commit
82225fd9
authored
Feb 12, 2018
by
hzxuzhonghu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize DefaultTolerationSeconds admission controller
parent
9d33926d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
19 deletions
+17
-19
BUILD
plugin/pkg/admission/defaulttolerationseconds/BUILD
+0
-1
admission.go
plugin/pkg/admission/defaulttolerationseconds/admission.go
+17
-18
No files found.
plugin/pkg/admission/defaulttolerationseconds/BUILD
View file @
82225fd9
...
@@ -25,7 +25,6 @@ go_library(
...
@@ -25,7 +25,6 @@ go_library(
importpath = "k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds",
importpath = "k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds",
deps = [
deps = [
"//pkg/apis/core:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core/helper:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//pkg/scheduler/algorithm:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
...
...
plugin/pkg/admission/defaulttolerationseconds/admission.go
View file @
82225fd9
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
api
"k8s.io/kubernetes/pkg/apis/core"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/helper"
"k8s.io/kubernetes/pkg/scheduler/algorithm"
"k8s.io/kubernetes/pkg/scheduler/algorithm"
)
)
...
@@ -39,6 +38,20 @@ var (
...
@@ -39,6 +38,20 @@ var (
defaultUnreachableTolerationSeconds
=
flag
.
Int64
(
"default-unreachable-toleration-seconds"
,
300
,
defaultUnreachableTolerationSeconds
=
flag
.
Int64
(
"default-unreachable-toleration-seconds"
,
300
,
"Indicates the tolerationSeconds of the toleration for unreachable:NoExecute"
+
"Indicates the tolerationSeconds of the toleration for unreachable:NoExecute"
+
" that is added by default to every pod that does not already have such a toleration."
)
" that is added by default to every pod that does not already have such a toleration."
)
notReadyToleration
=
api
.
Toleration
{
Key
:
algorithm
.
TaintNodeNotReady
,
Operator
:
api
.
TolerationOpExists
,
Effect
:
api
.
TaintEffectNoExecute
,
TolerationSeconds
:
defaultNotReadyTolerationSeconds
,
}
unreachableToleration
=
api
.
Toleration
{
Key
:
algorithm
.
TaintNodeUnreachable
,
Operator
:
api
.
TolerationOpExists
,
Effect
:
api
.
TaintEffectNoExecute
,
TolerationSeconds
:
defaultUnreachableTolerationSeconds
,
}
)
)
// Register registers a plugin
// Register registers a plugin
...
@@ -99,27 +112,13 @@ func (p *Plugin) Admit(attributes admission.Attributes) (err error) {
...
@@ -99,27 +112,13 @@ func (p *Plugin) Admit(attributes admission.Attributes) (err error) {
}
}
}
}
// no change is required, return immediately
if
toleratesNodeNotReady
&&
toleratesNodeUnreachable
{
return
nil
}
if
!
toleratesNodeNotReady
{
if
!
toleratesNodeNotReady
{
helper
.
AddOrUpdateTolerationInPod
(
pod
,
&
api
.
Toleration
{
pod
.
Spec
.
Tolerations
=
append
(
pod
.
Spec
.
Tolerations
,
notReadyToleration
)
Key
:
algorithm
.
TaintNodeNotReady
,
Operator
:
api
.
TolerationOpExists
,
Effect
:
api
.
TaintEffectNoExecute
,
TolerationSeconds
:
defaultNotReadyTolerationSeconds
,
})
}
}
if
!
toleratesNodeUnreachable
{
if
!
toleratesNodeUnreachable
{
helper
.
AddOrUpdateTolerationInPod
(
pod
,
&
api
.
Toleration
{
pod
.
Spec
.
Tolerations
=
append
(
pod
.
Spec
.
Tolerations
,
unreachableToleration
)
Key
:
algorithm
.
TaintNodeUnreachable
,
Operator
:
api
.
TolerationOpExists
,
Effect
:
api
.
TaintEffectNoExecute
,
TolerationSeconds
:
defaultUnreachableTolerationSeconds
,
})
}
}
return
nil
return
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