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
524bfde3
Commit
524bfde3
authored
Apr 08, 2016
by
Jeff Lowdermilk
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23883 from liggitt/attis
Externalize immortal namespaces
parents
cd85b064
bef1d6e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
admission.go
plugin/pkg/admission/namespace/lifecycle/admission.go
+6
-4
admission_test.go
plugin/pkg/admission/namespace/lifecycle/admission_test.go
+2
-1
No files found.
plugin/pkg/admission/namespace/lifecycle/admission.go
View file @
524bfde3
...
@@ -32,9 +32,11 @@ import (
...
@@ -32,9 +32,11 @@ import (
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
const
PluginName
=
"NamespaceLifecycle"
func
init
()
{
func
init
()
{
admission
.
RegisterPlugin
(
"NamespaceLifecycle"
,
func
(
client
clientset
.
Interface
,
config
io
.
Reader
)
(
admission
.
Interface
,
error
)
{
admission
.
RegisterPlugin
(
PluginName
,
func
(
client
clientset
.
Interface
,
config
io
.
Reader
)
(
admission
.
Interface
,
error
)
{
return
NewLifecycle
(
client
),
nil
return
NewLifecycle
(
client
,
sets
.
NewString
(
api
.
NamespaceDefault
)
),
nil
})
})
}
}
...
@@ -109,7 +111,7 @@ func (l *lifecycle) Admit(a admission.Attributes) (err error) {
...
@@ -109,7 +111,7 @@ func (l *lifecycle) Admit(a admission.Attributes) (err error) {
}
}
// NewLifecycle creates a new namespace lifecycle admission control handler
// NewLifecycle creates a new namespace lifecycle admission control handler
func
NewLifecycle
(
c
clientset
.
Interface
)
admission
.
Interface
{
func
NewLifecycle
(
c
clientset
.
Interface
,
immortalNamespaces
sets
.
String
)
admission
.
Interface
{
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
reflector
:=
cache
.
NewReflector
(
reflector
:=
cache
.
NewReflector
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
...
@@ -129,6 +131,6 @@ func NewLifecycle(c clientset.Interface) admission.Interface {
...
@@ -129,6 +131,6 @@ func NewLifecycle(c clientset.Interface) admission.Interface {
Handler
:
admission
.
NewHandler
(
admission
.
Create
,
admission
.
Update
,
admission
.
Delete
),
Handler
:
admission
.
NewHandler
(
admission
.
Create
,
admission
.
Update
,
admission
.
Delete
),
client
:
c
,
client
:
c
,
store
:
store
,
store
:
store
,
immortalNamespaces
:
sets
.
NewString
(
api
.
NamespaceDefault
)
,
immortalNamespaces
:
immortalNamespaces
,
}
}
}
}
plugin/pkg/admission/namespace/lifecycle/admission_test.go
View file @
524bfde3
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/sets"
)
)
// TestAdmission
// TestAdmission
...
@@ -60,7 +61,7 @@ func TestAdmission(t *testing.T) {
...
@@ -60,7 +61,7 @@ func TestAdmission(t *testing.T) {
return
true
,
&
api
.
NamespaceList
{
Items
:
[]
api
.
Namespace
{
*
namespaceObj
}},
nil
return
true
,
&
api
.
NamespaceList
{
Items
:
[]
api
.
Namespace
{
*
namespaceObj
}},
nil
})
})
lfhandler
:=
NewLifecycle
(
mockClient
)
.
(
*
lifecycle
)
lfhandler
:=
NewLifecycle
(
mockClient
,
sets
.
NewString
(
"default"
)
)
.
(
*
lifecycle
)
lfhandler
.
store
=
store
lfhandler
.
store
=
store
handler
:=
admission
.
NewChainHandler
(
lfhandler
)
handler
:=
admission
.
NewChainHandler
(
lfhandler
)
pod
:=
api
.
Pod
{
pod
:=
api
.
Pod
{
...
...
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