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
74186d3e
Commit
74186d3e
authored
Feb 08, 2017
by
Andy Goldstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch disruption controller to shared informers
parent
e9de1b02
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
132 deletions
+111
-132
policy.go
cmd/kube-controller-manager/app/policy.go
+6
-1
BUILD
pkg/controller/disruption/BUILD
+10
-8
disruption.go
pkg/controller/disruption/disruption.go
+66
-115
disruption_test.go
pkg/controller/disruption/disruption_test.go
+0
-0
policy.go
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
+2
-0
cluster-roles.yaml
...thorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
+14
-0
evictions_test.go
test/integration/evictions/evictions_test.go
+13
-8
No files found.
cmd/kube-controller-manager/app/policy.go
View file @
74186d3e
...
@@ -30,7 +30,12 @@ func startDisruptionController(ctx ControllerContext) (bool, error) {
...
@@ -30,7 +30,12 @@ func startDisruptionController(ctx ControllerContext) (bool, error) {
return
false
,
nil
return
false
,
nil
}
}
go
disruption
.
NewDisruptionController
(
go
disruption
.
NewDisruptionController
(
ctx
.
InformerFactory
.
Pods
()
.
Informer
(),
ctx
.
NewInformerFactory
.
Core
()
.
V1
()
.
Pods
(),
ctx
.
NewInformerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
ctx
.
NewInformerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
ctx
.
NewInformerFactory
.
Extensions
()
.
V1beta1
()
.
ReplicaSets
(),
ctx
.
NewInformerFactory
.
Extensions
()
.
V1beta1
()
.
Deployments
(),
ctx
.
NewInformerFactory
.
Apps
()
.
V1beta1
()
.
StatefulSets
(),
ctx
.
ClientBuilder
.
ClientOrDie
(
"disruption-controller"
),
ctx
.
ClientBuilder
.
ClientOrDie
(
"disruption-controller"
),
)
.
Run
(
ctx
.
Stop
)
)
.
Run
(
ctx
.
Stop
)
return
true
,
nil
return
true
,
nil
...
...
pkg/controller/disruption/BUILD
View file @
74186d3e
...
@@ -15,21 +15,25 @@ go_library(
...
@@ -15,21 +15,25 @@ go_library(
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/apps/v1beta1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/policy/v1beta1:go_default_library",
"//pkg/apis/policy/v1beta1:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/policy/v1beta1:go_default_library",
"//pkg/client/clientset_generated/clientset/typed/policy/v1beta1:go_default_library",
"//pkg/client/legacylisters:go_default_library",
"//pkg/client/informers/informers_generated/apps/v1beta1:go_default_library",
"//pkg/client/informers/informers_generated/core/v1:go_default_library",
"//pkg/client/informers/informers_generated/extensions/v1beta1:go_default_library",
"//pkg/client/informers/informers_generated/policy/v1beta1:go_default_library",
"//pkg/client/listers/apps/v1beta1:go_default_library",
"//pkg/client/listers/core/v1:go_default_library",
"//pkg/client/listers/extensions/v1beta1:go_default_library",
"//pkg/client/listers/policy/v1beta1:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/util/intstr",
"//vendor:k8s.io/apimachinery/pkg/util/intstr",
"//vendor:k8s.io/apimachinery/pkg/util/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/runtime",
"//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/apimachinery/pkg/watch",
"//vendor:k8s.io/client-go/kubernetes/typed/core/v1",
"//vendor:k8s.io/client-go/kubernetes/typed/core/v1",
"//vendor:k8s.io/client-go/pkg/api/v1",
"//vendor:k8s.io/client-go/pkg/api/v1",
"//vendor:k8s.io/client-go/tools/cache",
"//vendor:k8s.io/client-go/tools/cache",
...
@@ -49,14 +53,12 @@ go_test(
...
@@ -49,14 +53,12 @@ go_test(
"//pkg/apis/apps/v1beta1:go_default_library",
"//pkg/apis/apps/v1beta1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//pkg/apis/policy/v1beta1:go_default_library",
"//pkg/apis/policy/v1beta1:go_default_library",
"//pkg/client/
legacylisters
:go_default_library",
"//pkg/client/
informers/informers_generated
:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/util/intstr",
"//vendor:k8s.io/apimachinery/pkg/util/intstr",
"//vendor:k8s.io/apimachinery/pkg/util/uuid",
"//vendor:k8s.io/apimachinery/pkg/util/uuid",
"//vendor:k8s.io/client-go/pkg/api/v1",
"//vendor:k8s.io/client-go/tools/cache",
"//vendor:k8s.io/client-go/tools/cache",
"//vendor:k8s.io/client-go/tools/record",
"//vendor:k8s.io/client-go/util/workqueue",
"//vendor:k8s.io/client-go/util/workqueue",
],
],
)
)
...
...
pkg/controller/disruption/disruption.go
View file @
74186d3e
This diff is collapsed.
Click to expand it.
pkg/controller/disruption/disruption_test.go
View file @
74186d3e
This diff is collapsed.
Click to expand it.
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
View file @
74186d3e
...
@@ -283,6 +283,8 @@ func ClusterRoles() []rbac.ClusterRole {
...
@@ -283,6 +283,8 @@ func ClusterRoles() []rbac.ClusterRole {
"persistentvolumes"
,
"pods"
,
"secrets"
,
"services"
,
"serviceaccounts"
,
"replicationcontrollers"
)
.
RuleOrDie
(),
"persistentvolumes"
,
"pods"
,
"secrets"
,
"services"
,
"serviceaccounts"
,
"replicationcontrollers"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
extensionsGroup
)
.
Resources
(
"daemonsets"
,
"deployments"
,
"replicasets"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
extensionsGroup
)
.
Resources
(
"daemonsets"
,
"deployments"
,
"replicasets"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
batchGroup
)
.
Resources
(
"jobs"
,
"cronjobs"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
batchGroup
)
.
Resources
(
"jobs"
,
"cronjobs"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
appsGroup
)
.
Resources
(
"statefulsets"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
policyGroup
)
.
Resources
(
"poddisruptionbudgets"
)
.
RuleOrDie
(),
},
},
},
},
{
{
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
View file @
74186d3e
...
@@ -475,6 +475,20 @@ items:
...
@@ -475,6 +475,20 @@ items:
verbs
:
verbs
:
-
list
-
list
-
watch
-
watch
-
apiGroups
:
-
apps
resources
:
-
statefulsets
verbs
:
-
list
-
watch
-
apiGroups
:
-
policy
resources
:
-
poddisruptionbudgets
verbs
:
-
list
-
watch
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
ClusterRole
kind
:
ClusterRole
metadata
:
metadata
:
...
...
test/integration/evictions/evictions_test.go
View file @
74186d3e
...
@@ -36,8 +36,8 @@ import (
...
@@ -36,8 +36,8 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/policy/v1beta1"
"k8s.io/kubernetes/pkg/apis/policy/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
informers
"k8s.io/kubernetes/pkg/client/informers/informers_generated"
"k8s.io/kubernetes/pkg/controller/disruption"
"k8s.io/kubernetes/pkg/controller/disruption"
"k8s.io/kubernetes/pkg/controller/informers"
"k8s.io/kubernetes/test/integration/framework"
"k8s.io/kubernetes/test/integration/framework"
)
)
...
@@ -50,14 +50,14 @@ const (
...
@@ -50,14 +50,14 @@ const (
func
TestConcurrentEvictionRequests
(
t
*
testing
.
T
)
{
func
TestConcurrentEvictionRequests
(
t
*
testing
.
T
)
{
podNameFormat
:=
"test-pod-%d"
podNameFormat
:=
"test-pod-%d"
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
)
s
,
rm
,
informers
,
clientSet
:=
rmSetup
(
t
)
defer
s
.
Close
()
defer
s
.
Close
()
ns
:=
framework
.
CreateTestingNamespace
(
"concurrent-eviction-requests"
,
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
"concurrent-eviction-requests"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
informers
.
Start
(
stopCh
)
go
rm
.
Run
(
stopCh
)
go
rm
.
Run
(
stopCh
)
defer
close
(
stopCh
)
defer
close
(
stopCh
)
...
@@ -87,7 +87,7 @@ func TestConcurrentEvictionRequests(t *testing.T) {
...
@@ -87,7 +87,7 @@ func TestConcurrentEvictionRequests(t *testing.T) {
}
}
}
}
waitToObservePods
(
t
,
podInformer
,
numOfEvictions
)
waitToObservePods
(
t
,
informers
.
Core
()
.
V1
()
.
Pods
()
.
Informer
()
,
numOfEvictions
)
pdb
:=
newPDB
()
pdb
:=
newPDB
()
if
_
,
err
:=
clientSet
.
Policy
()
.
PodDisruptionBudgets
(
ns
.
Name
)
.
Create
(
pdb
);
err
!=
nil
{
if
_
,
err
:=
clientSet
.
Policy
()
.
PodDisruptionBudgets
(
ns
.
Name
)
.
Create
(
pdb
);
err
!=
nil
{
...
@@ -227,7 +227,7 @@ func newEviction(ns, evictionName string, deleteOption *metav1.DeleteOptions) *v
...
@@ -227,7 +227,7 @@ func newEviction(ns, evictionName string, deleteOption *metav1.DeleteOptions) *v
}
}
}
}
func
rmSetup
(
t
*
testing
.
T
)
(
*
httptest
.
Server
,
*
disruption
.
DisruptionController
,
cache
.
SharedIndexInformer
,
clientset
.
Interface
)
{
func
rmSetup
(
t
*
testing
.
T
)
(
*
httptest
.
Server
,
*
disruption
.
DisruptionController
,
informers
.
SharedInformerFactory
,
clientset
.
Interface
)
{
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
...
@@ -237,13 +237,18 @@ func rmSetup(t *testing.T) (*httptest.Server, *disruption.DisruptionController,
...
@@ -237,13 +237,18 @@ func rmSetup(t *testing.T) (*httptest.Server, *disruption.DisruptionController,
t
.
Fatalf
(
"Error in create clientset: %v"
,
err
)
t
.
Fatalf
(
"Error in create clientset: %v"
,
err
)
}
}
resyncPeriod
:=
12
*
time
.
Hour
resyncPeriod
:=
12
*
time
.
Hour
informers
:=
informers
.
NewSharedInformerFactory
(
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"pdb-informers"
)),
nil
,
resyncPeriod
)
informers
:=
informers
.
NewSharedInformerFactory
(
nil
,
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"pdb-informers"
))
,
resyncPeriod
)
rm
:=
disruption
.
NewDisruptionController
(
rm
:=
disruption
.
NewDisruptionController
(
informers
.
Pods
()
.
Informer
(),
informers
.
Core
()
.
V1
()
.
Pods
(),
informers
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
informers
.
Core
()
.
V1
()
.
ReplicationControllers
(),
informers
.
Extensions
()
.
V1beta1
()
.
ReplicaSets
(),
informers
.
Extensions
()
.
V1beta1
()
.
Deployments
(),
informers
.
Apps
()
.
V1beta1
()
.
StatefulSets
(),
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"disruption-controller"
)),
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"disruption-controller"
)),
)
)
return
s
,
rm
,
informers
.
Pods
()
.
Informer
()
,
clientSet
return
s
,
rm
,
informers
,
clientSet
}
}
// wait for the podInformer to observe the pods. Call this function before
// wait for the podInformer to observe the pods. Call this function before
...
...
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