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
85867e56
Commit
85867e56
authored
Mar 01, 2019
by
Xing Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify node admission and node authorizer
parent
6265f4f7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
120 additions
and
106 deletions
+120
-106
BUILD
plugin/pkg/admission/noderestriction/BUILD
+2
-2
admission.go
plugin/pkg/admission/noderestriction/admission.go
+13
-13
admission_test.go
plugin/pkg/admission/noderestriction/admission_test.go
+24
-42
BUILD
plugin/pkg/auth/authorizer/node/BUILD
+0
-1
node_authorizer.go
plugin/pkg/auth/authorizer/node/node_authorizer.go
+16
-17
node_authorizer_test.go
plugin/pkg/auth/authorizer/node/node_authorizer_test.go
+27
-27
controller_policy.go
...auth/authorizer/rbac/bootstrappolicy/controller_policy.go
+1
-1
policy.go
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
+3
-3
cluster-roles.yaml
...thorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
+26
-0
controller-roles.yaml
...rizer/rbac/bootstrappolicy/testdata/controller-roles.yaml
+8
-0
No files found.
plugin/pkg/admission/noderestriction/BUILD
View file @
85867e56
...
@@ -16,6 +16,7 @@ go_library(
...
@@ -16,6 +16,7 @@ go_library(
"//pkg/apis/coordination:go_default_library",
"//pkg/apis/coordination:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/auth/nodeidentifier:go_default_library",
"//pkg/auth/nodeidentifier:go_default_library",
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
"//pkg/kubelet/apis:go_default_library",
"//pkg/kubelet/apis:go_default_library",
...
@@ -30,7 +31,6 @@ go_library(
...
@@ -30,7 +31,6 @@ go_library(
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/client-go/informers:go_default_library",
"//staging/src/k8s.io/client-go/informers:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
],
)
)
...
@@ -44,6 +44,7 @@ go_test(
...
@@ -44,6 +44,7 @@ go_test(
"//pkg/apis/coordination:go_default_library",
"//pkg/apis/coordination:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/auth/nodeidentifier:go_default_library",
"//pkg/auth/nodeidentifier:go_default_library",
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
"//pkg/kubelet/apis:go_default_library",
"//pkg/kubelet/apis:go_default_library",
...
@@ -57,7 +58,6 @@ go_test(
...
@@ -57,7 +58,6 @@ go_test(
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library",
"//vendor/k8s.io/utils/pointer:go_default_library",
"//vendor/k8s.io/utils/pointer:go_default_library",
],
],
)
)
...
...
plugin/pkg/admission/noderestriction/admission.go
View file @
85867e56
...
@@ -32,13 +32,13 @@ import (
...
@@ -32,13 +32,13 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/informers"
"k8s.io/client-go/informers"
corev1lister
"k8s.io/client-go/listers/core/v1"
corev1lister
"k8s.io/client-go/listers/core/v1"
csiv1alpha1
"k8s.io/csi-api/pkg/apis/csi/v1alpha1"
"k8s.io/klog"
"k8s.io/klog"
podutil
"k8s.io/kubernetes/pkg/api/pod"
podutil
"k8s.io/kubernetes/pkg/api/pod"
authenticationapi
"k8s.io/kubernetes/pkg/apis/authentication"
authenticationapi
"k8s.io/kubernetes/pkg/apis/authentication"
coordapi
"k8s.io/kubernetes/pkg/apis/coordination"
coordapi
"k8s.io/kubernetes/pkg/apis/coordination"
api
"k8s.io/kubernetes/pkg/apis/core"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/apis/policy"
storage
"k8s.io/kubernetes/pkg/apis/storage"
"k8s.io/kubernetes/pkg/auth/nodeidentifier"
"k8s.io/kubernetes/pkg/auth/nodeidentifier"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
...
@@ -94,12 +94,12 @@ func (p *nodePlugin) ValidateInitialization() error {
...
@@ -94,12 +94,12 @@ func (p *nodePlugin) ValidateInitialization() error {
}
}
var
(
var
(
podResource
=
api
.
Resource
(
"pods"
)
podResource
=
api
.
Resource
(
"pods"
)
nodeResource
=
api
.
Resource
(
"nodes"
)
nodeResource
=
api
.
Resource
(
"nodes"
)
pvcResource
=
api
.
Resource
(
"persistentvolumeclaims"
)
pvcResource
=
api
.
Resource
(
"persistentvolumeclaims"
)
svcacctResource
=
api
.
Resource
(
"serviceaccounts"
)
svcacctResource
=
api
.
Resource
(
"serviceaccounts"
)
leaseResource
=
coordapi
.
Resource
(
"leases"
)
leaseResource
=
coordapi
.
Resource
(
"leases"
)
csiNode
InfoResource
=
csiv1alpha1
.
Resource
(
"csinodeinfo
s"
)
csiNode
Resource
=
storage
.
Resource
(
"csinode
s"
)
)
)
func
(
c
*
nodePlugin
)
Admit
(
a
admission
.
Attributes
,
o
admission
.
ObjectInterfaces
)
error
{
func
(
c
*
nodePlugin
)
Admit
(
a
admission
.
Attributes
,
o
admission
.
ObjectInterfaces
)
error
{
...
@@ -151,9 +151,9 @@ func (c *nodePlugin) Admit(a admission.Attributes, o admission.ObjectInterfaces)
...
@@ -151,9 +151,9 @@ func (c *nodePlugin) Admit(a admission.Attributes, o admission.ObjectInterfaces)
}
}
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"disabled by feature gate %s"
,
features
.
NodeLease
))
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"disabled by feature gate %s"
,
features
.
NodeLease
))
case
csiNode
Info
Resource
:
case
csiNodeResource
:
if
c
.
features
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
c
.
features
.
Enabled
(
features
.
CSINodeInfo
)
{
if
c
.
features
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
c
.
features
.
Enabled
(
features
.
CSINodeInfo
)
{
return
c
.
admitCSINode
Info
(
nodeName
,
a
)
return
c
.
admitCSINode
(
nodeName
,
a
)
}
}
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
))
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
))
...
@@ -530,8 +530,8 @@ func (r *nodePlugin) admitLease(nodeName string, a admission.Attributes) error {
...
@@ -530,8 +530,8 @@ func (r *nodePlugin) admitLease(nodeName string, a admission.Attributes) error {
return
nil
return
nil
}
}
func
(
c
*
nodePlugin
)
admitCSINode
Info
(
nodeName
string
,
a
admission
.
Attributes
)
error
{
func
(
c
*
nodePlugin
)
admitCSINode
(
nodeName
string
,
a
admission
.
Attributes
)
error
{
// the request must come from a node with the same name as the CSINode
Info
object
// the request must come from a node with the same name as the CSINode object
if
a
.
GetOperation
()
==
admission
.
Create
{
if
a
.
GetOperation
()
==
admission
.
Create
{
// a.GetName() won't return the name on create, so we drill down to the proposed object
// a.GetName() won't return the name on create, so we drill down to the proposed object
accessor
,
err
:=
meta
.
Accessor
(
a
.
GetObject
())
accessor
,
err
:=
meta
.
Accessor
(
a
.
GetObject
())
...
@@ -539,11 +539,11 @@ func (c *nodePlugin) admitCSINodeInfo(nodeName string, a admission.Attributes) e
...
@@ -539,11 +539,11 @@ func (c *nodePlugin) admitCSINodeInfo(nodeName string, a admission.Attributes) e
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"unable to access the object name"
))
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"unable to access the object name"
))
}
}
if
accessor
.
GetName
()
!=
nodeName
{
if
accessor
.
GetName
()
!=
nodeName
{
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"can only access CSINode
Info
with the same name as the requesting node"
))
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"can only access CSINode with the same name as the requesting node"
))
}
}
}
else
{
}
else
{
if
a
.
GetName
()
!=
nodeName
{
if
a
.
GetName
()
!=
nodeName
{
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"can only access CSINode
Info
with the same name as the requesting node"
))
return
admission
.
NewForbidden
(
a
,
fmt
.
Errorf
(
"can only access CSINode with the same name as the requesting node"
))
}
}
}
}
...
...
plugin/pkg/admission/noderestriction/admission_test.go
View file @
85867e56
...
@@ -33,11 +33,11 @@ import (
...
@@ -33,11 +33,11 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
corev1lister
"k8s.io/client-go/listers/core/v1"
corev1lister
"k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache"
csiv1alpha1
"k8s.io/csi-api/pkg/apis/csi/v1alpha1"
authenticationapi
"k8s.io/kubernetes/pkg/apis/authentication"
authenticationapi
"k8s.io/kubernetes/pkg/apis/authentication"
"k8s.io/kubernetes/pkg/apis/coordination"
"k8s.io/kubernetes/pkg/apis/coordination"
api
"k8s.io/kubernetes/pkg/apis/core"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/apis/policy"
storage
"k8s.io/kubernetes/pkg/apis/storage"
"k8s.io/kubernetes/pkg/auth/nodeidentifier"
"k8s.io/kubernetes/pkg/auth/nodeidentifier"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
...
@@ -306,14 +306,14 @@ func Test_nodePlugin_Admit(t *testing.T) {
...
@@ -306,14 +306,14 @@ func Test_nodePlugin_Admit(t *testing.T) {
},
},
}
}
csiNode
InfoResource
=
csiv1alpha1
.
Resource
(
"csinodeinfos"
)
.
WithVersion
(
"v1alph
a1"
)
csiNode
Resource
=
storage
.
Resource
(
"csinodes"
)
.
WithVersion
(
"v1bet
a1"
)
csiNode
InfoKind
=
schema
.
GroupVersionKind
{
Group
:
"csi.storage.k8s.io"
,
Version
:
"v1alpha1"
,
Kind
:
"CSINodeInfo
"
}
csiNode
Kind
=
schema
.
GroupVersionKind
{
Group
:
"storage.k8s.io"
,
Version
:
"v1beta1"
,
Kind
:
"CSINode
"
}
nodeInfo
=
&
csiv1alpha1
.
CSINodeInfo
{
nodeInfo
=
&
storage
.
CSINode
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"mynode"
,
Name
:
"mynode"
,
},
},
Spec
:
csiv1alpha1
.
CSINodeInfo
Spec
{
Spec
:
storage
.
CSINode
Spec
{
Drivers
:
[]
csiv1alpha1
.
CSIDriverInfoSpec
{
Drivers
:
[]
storage
.
CSINodeDriver
{
{
{
Name
:
"com.example.csi/mydriver"
,
Name
:
"com.example.csi/mydriver"
,
NodeID
:
"com.example.csi/mynode"
,
NodeID
:
"com.example.csi/mynode"
,
...
@@ -321,22 +321,13 @@ func Test_nodePlugin_Admit(t *testing.T) {
...
@@ -321,22 +321,13 @@ func Test_nodePlugin_Admit(t *testing.T) {
},
},
},
},
},
},
Status
:
csiv1alpha1
.
CSINodeInfoStatus
{
Drivers
:
[]
csiv1alpha1
.
CSIDriverInfoStatus
{
{
Name
:
"com.example.csi/mydriver"
,
Available
:
true
,
VolumePluginMechanism
:
csiv1alpha1
.
VolumePluginMechanismInTree
,
},
},
},
}
}
nodeInfoWrongName
=
&
csiv1alpha1
.
CSINodeInfo
{
nodeInfoWrongName
=
&
storage
.
CSINode
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
Spec
:
csiv1alpha1
.
CSINodeInfo
Spec
{
Spec
:
storage
.
CSINode
Spec
{
Drivers
:
[]
csiv1alpha1
.
CSIDriverInfoSpec
{
Drivers
:
[]
storage
.
CSINodeDriver
{
{
{
Name
:
"com.example.csi/mydriver"
,
Name
:
"com.example.csi/mydriver"
,
NodeID
:
"com.example.csi/foo"
,
NodeID
:
"com.example.csi/foo"
,
...
@@ -344,15 +335,6 @@ func Test_nodePlugin_Admit(t *testing.T) {
...
@@ -344,15 +335,6 @@ func Test_nodePlugin_Admit(t *testing.T) {
},
},
},
},
},
},
Status
:
csiv1alpha1
.
CSINodeInfoStatus
{
Drivers
:
[]
csiv1alpha1
.
CSIDriverInfoStatus
{
{
Name
:
"com.example.csi/mydriver"
,
Available
:
true
,
VolumePluginMechanism
:
csiv1alpha1
.
VolumePluginMechanismInTree
,
},
},
},
}
}
noExistingPodsIndex
=
cache
.
NewIndexer
(
cache
.
MetaNamespaceKeyFunc
,
nil
)
noExistingPodsIndex
=
cache
.
NewIndexer
(
cache
.
MetaNamespaceKeyFunc
,
nil
)
...
@@ -1183,46 +1165,46 @@ func Test_nodePlugin_Admit(t *testing.T) {
...
@@ -1183,46 +1165,46 @@ func Test_nodePlugin_Admit(t *testing.T) {
features
:
leaseEnabledFeature
,
features
:
leaseEnabledFeature
,
err
:
""
,
err
:
""
,
},
},
// CSINode
Info
// CSINode
{
{
name
:
"disallowed create CSINode
Info
- feature disabled"
,
name
:
"disallowed create CSINode - feature disabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nil
,
csiNode
InfoKind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nil
,
csiNode
Kind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNode
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
features
:
csiNodeInfoDisabledFeature
,
features
:
csiNodeInfoDisabledFeature
,
err
:
fmt
.
Sprintf
(
"forbidden: disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
),
err
:
fmt
.
Sprintf
(
"forbidden: disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
),
},
},
{
{
name
:
"disallowed create another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed create another node's CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nodeInfoWrongName
,
nil
,
csiNode
InfoKind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nodeInfoWrongName
,
nil
,
csiNode
Kind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNode
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
"forbidden: "
,
err
:
"forbidden: "
,
},
},
{
{
name
:
"disallowed update another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed update another node's CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nodeInfoWrongName
,
nodeInfoWrongName
,
csiNode
InfoKind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Update
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nodeInfoWrongName
,
nodeInfoWrongName
,
csiNode
Kind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNode
Resource
,
""
,
admission
.
Update
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
"forbidden: "
,
err
:
"forbidden: "
,
},
},
{
{
name
:
"disallowed delete another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed delete another node's CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nil
,
nil
,
csiNode
InfoKind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Delete
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nil
,
nil
,
csiNode
Kind
,
nodeInfoWrongName
.
Namespace
,
nodeInfoWrongName
.
Name
,
csiNode
Resource
,
""
,
admission
.
Delete
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
"forbidden: "
,
err
:
"forbidden: "
,
},
},
{
{
name
:
"allowed create node CSINode
Info
- feature enabled"
,
name
:
"allowed create node CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nil
,
csiNode
InfoKind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nil
,
csiNode
Kind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNode
Resource
,
""
,
admission
.
Create
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
""
,
err
:
""
,
},
},
{
{
name
:
"allowed update node CSINode
Info
- feature enabled"
,
name
:
"allowed update node CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nodeInfo
,
csiNode
InfoKind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Update
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nodeInfo
,
nodeInfo
,
csiNode
Kind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNode
Resource
,
""
,
admission
.
Update
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
""
,
err
:
""
,
},
},
{
{
name
:
"allowed delete node CSINode
Info
- feature enabled"
,
name
:
"allowed delete node CSINode - feature enabled"
,
attributes
:
admission
.
NewAttributesRecord
(
nil
,
nil
,
csiNode
InfoKind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNodeInfo
Resource
,
""
,
admission
.
Delete
,
false
,
mynode
),
attributes
:
admission
.
NewAttributesRecord
(
nil
,
nil
,
csiNode
Kind
,
nodeInfo
.
Namespace
,
nodeInfo
.
Name
,
csiNode
Resource
,
""
,
admission
.
Delete
,
false
,
mynode
),
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
err
:
""
,
err
:
""
,
},
},
...
...
plugin/pkg/auth/authorizer/node/BUILD
View file @
85867e56
...
@@ -56,7 +56,6 @@ go_library(
...
@@ -56,7 +56,6 @@ go_library(
"//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers/storage/v1:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
"//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library",
"//third_party/forked/gonum/graph:go_default_library",
"//third_party/forked/gonum/graph:go_default_library",
"//third_party/forked/gonum/graph/simple:go_default_library",
"//third_party/forked/gonum/graph/simple:go_default_library",
"//third_party/forked/gonum/graph/traverse:go_default_library",
"//third_party/forked/gonum/graph/traverse:go_default_library",
...
...
plugin/pkg/auth/authorizer/node/node_authorizer.go
View file @
85867e56
...
@@ -25,7 +25,6 @@ import (
...
@@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/authorization/authorizer"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
csiv1alpha1
"k8s.io/csi-api/pkg/apis/csi/v1alpha1"
coordapi
"k8s.io/kubernetes/pkg/apis/coordination"
coordapi
"k8s.io/kubernetes/pkg/apis/coordination"
api
"k8s.io/kubernetes/pkg/apis/core"
api
"k8s.io/kubernetes/pkg/apis/core"
storageapi
"k8s.io/kubernetes/pkg/apis/storage"
storageapi
"k8s.io/kubernetes/pkg/apis/storage"
...
@@ -68,14 +67,14 @@ func NewAuthorizer(graph *Graph, identifier nodeidentifier.NodeIdentifier, rules
...
@@ -68,14 +67,14 @@ func NewAuthorizer(graph *Graph, identifier nodeidentifier.NodeIdentifier, rules
}
}
var
(
var
(
configMapResource
=
api
.
Resource
(
"configmaps"
)
configMapResource
=
api
.
Resource
(
"configmaps"
)
secretResource
=
api
.
Resource
(
"secrets"
)
secretResource
=
api
.
Resource
(
"secrets"
)
pvcResource
=
api
.
Resource
(
"persistentvolumeclaims"
)
pvcResource
=
api
.
Resource
(
"persistentvolumeclaims"
)
pvResource
=
api
.
Resource
(
"persistentvolumes"
)
pvResource
=
api
.
Resource
(
"persistentvolumes"
)
vaResource
=
storageapi
.
Resource
(
"volumeattachments"
)
vaResource
=
storageapi
.
Resource
(
"volumeattachments"
)
svcAcctResource
=
api
.
Resource
(
"serviceaccounts"
)
svcAcctResource
=
api
.
Resource
(
"serviceaccounts"
)
leaseResource
=
coordapi
.
Resource
(
"leases"
)
leaseResource
=
coordapi
.
Resource
(
"leases"
)
csiNode
InfoResource
=
csiv1alpha1
.
Resource
(
"csinodeinfo
s"
)
csiNode
Resource
=
storageapi
.
Resource
(
"csinode
s"
)
)
)
func
(
r
*
NodeAuthorizer
)
Authorize
(
attrs
authorizer
.
Attributes
)
(
authorizer
.
Decision
,
string
,
error
)
{
func
(
r
*
NodeAuthorizer
)
Authorize
(
attrs
authorizer
.
Attributes
)
(
authorizer
.
Decision
,
string
,
error
)
{
...
@@ -122,9 +121,9 @@ func (r *NodeAuthorizer) Authorize(attrs authorizer.Attributes) (authorizer.Deci
...
@@ -122,9 +121,9 @@ func (r *NodeAuthorizer) Authorize(attrs authorizer.Attributes) (authorizer.Deci
return
r
.
authorizeLease
(
nodeName
,
attrs
)
return
r
.
authorizeLease
(
nodeName
,
attrs
)
}
}
return
authorizer
.
DecisionNoOpinion
,
fmt
.
Sprintf
(
"disabled by feature gate %s"
,
features
.
NodeLease
),
nil
return
authorizer
.
DecisionNoOpinion
,
fmt
.
Sprintf
(
"disabled by feature gate %s"
,
features
.
NodeLease
),
nil
case
csiNode
Info
Resource
:
case
csiNodeResource
:
if
r
.
features
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
r
.
features
.
Enabled
(
features
.
CSINodeInfo
)
{
if
r
.
features
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
r
.
features
.
Enabled
(
features
.
CSINodeInfo
)
{
return
r
.
authorizeCSINode
Info
(
nodeName
,
attrs
)
return
r
.
authorizeCSINode
(
nodeName
,
attrs
)
}
}
return
authorizer
.
DecisionNoOpinion
,
fmt
.
Sprintf
(
"disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
),
nil
return
authorizer
.
DecisionNoOpinion
,
fmt
.
Sprintf
(
"disabled by feature gates %s and %s"
,
features
.
KubeletPluginsWatcher
,
features
.
CSINodeInfo
),
nil
}
}
...
@@ -260,8 +259,8 @@ func (r *NodeAuthorizer) authorizeLease(nodeName string, attrs authorizer.Attrib
...
@@ -260,8 +259,8 @@ func (r *NodeAuthorizer) authorizeLease(nodeName string, attrs authorizer.Attrib
return
authorizer
.
DecisionAllow
,
""
,
nil
return
authorizer
.
DecisionAllow
,
""
,
nil
}
}
// authorizeCSINode
Info authorizes node requests to CSINodeInfo csi.storage.k8s.io/csinodeinfo
s
// authorizeCSINode
authorizes node requests to CSINode storage.k8s.io/csinode
s
func
(
r
*
NodeAuthorizer
)
authorizeCSINode
Info
(
nodeName
string
,
attrs
authorizer
.
Attributes
)
(
authorizer
.
Decision
,
string
,
error
)
{
func
(
r
*
NodeAuthorizer
)
authorizeCSINode
(
nodeName
string
,
attrs
authorizer
.
Attributes
)
(
authorizer
.
Decision
,
string
,
error
)
{
// allowed verbs: get, create, update, patch, delete
// allowed verbs: get, create, update, patch, delete
verb
:=
attrs
.
GetVerb
()
verb
:=
attrs
.
GetVerb
()
if
verb
!=
"get"
&&
if
verb
!=
"get"
&&
...
@@ -270,20 +269,20 @@ func (r *NodeAuthorizer) authorizeCSINodeInfo(nodeName string, attrs authorizer.
...
@@ -270,20 +269,20 @@ func (r *NodeAuthorizer) authorizeCSINodeInfo(nodeName string, attrs authorizer.
verb
!=
"patch"
&&
verb
!=
"patch"
&&
verb
!=
"delete"
{
verb
!=
"delete"
{
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
return
authorizer
.
DecisionNoOpinion
,
"can only get, create, update, patch, or delete a CSINode
Info
"
,
nil
return
authorizer
.
DecisionNoOpinion
,
"can only get, create, update, patch, or delete a CSINode"
,
nil
}
}
if
len
(
attrs
.
GetSubresource
())
>
0
{
if
len
(
attrs
.
GetSubresource
())
>
0
{
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
return
authorizer
.
DecisionNoOpinion
,
"cannot authorize CSINode
Info
subresources"
,
nil
return
authorizer
.
DecisionNoOpinion
,
"cannot authorize CSINode subresources"
,
nil
}
}
// the request must come from a node with the same name as the CSINode
Info
// the request must come from a node with the same name as the CSINode
// note we skip this check for create, since the authorizer doesn't know the name on create
// note we skip this check for create, since the authorizer doesn't know the name on create
// the noderestriction admission plugin is capable of performing this check at create time
// the noderestriction admission plugin is capable of performing this check at create time
if
verb
!=
"create"
&&
attrs
.
GetName
()
!=
nodeName
{
if
verb
!=
"create"
&&
attrs
.
GetName
()
!=
nodeName
{
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
klog
.
V
(
2
)
.
Infof
(
"NODE DENY: %s %#v"
,
nodeName
,
attrs
)
return
authorizer
.
DecisionNoOpinion
,
"can only access CSINode
Info
with the same name as the requesting node"
,
nil
return
authorizer
.
DecisionNoOpinion
,
"can only access CSINode with the same name as the requesting node"
,
nil
}
}
return
authorizer
.
DecisionAllow
,
""
,
nil
return
authorizer
.
DecisionAllow
,
""
,
nil
...
...
plugin/pkg/auth/authorizer/node/node_authorizer_test.go
View file @
85867e56
...
@@ -352,82 +352,82 @@ func TestAuthorizer(t *testing.T) {
...
@@ -352,82 +352,82 @@ func TestAuthorizer(t *testing.T) {
features
:
leaseEnabledFeature
,
features
:
leaseEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
// CSINode
Info
// CSINode
{
{
name
:
"disallowed CSINode
Info
- feature disabled"
,
name
:
"disallowed CSINode - feature disabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoDisabledFeature
,
features
:
csiNodeInfoDisabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed CSINode
Info
with subresource - feature enabled"
,
name
:
"disallowed CSINode with subresource - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
infos"
,
Subresource
:
"csiDrivers"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
s"
,
Subresource
:
"csiDrivers"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed get another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed get another node's CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node1"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node1"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed update another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed update another node's CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"update"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node1"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"update"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node1"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed patch another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed patch another node's CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"patch"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node1"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"patch"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node1"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed delete another node's CSINode
Info
- feature enabled"
,
name
:
"disallowed delete another node's CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"delete"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node1"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"delete"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node1"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed list CSINode
Info
s - feature enabled"
,
name
:
"disallowed list CSINodes - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"list"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"list"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"disallowed watch CSINode
Info
s - feature enabled"
,
name
:
"disallowed watch CSINodes - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"watch"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"watch"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionNoOpinion
,
expect
:
authorizer
.
DecisionNoOpinion
,
},
},
{
{
name
:
"allowed get CSINode
Info
- feature enabled"
,
name
:
"allowed get CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"get"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
{
{
name
:
"allowed create CSINode
Info
- feature enabled"
,
name
:
"allowed create CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"create"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"create"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
{
{
name
:
"allowed update CSINode
Info
- feature enabled"
,
name
:
"allowed update CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"update"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"update"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
{
{
name
:
"allowed patch CSINode
Info
- feature enabled"
,
name
:
"allowed patch CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"patch"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"patch"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
{
{
name
:
"allowed delete CSINode
Info
- feature enabled"
,
name
:
"allowed delete CSINode - feature enabled"
,
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"delete"
,
Resource
:
"csinode
infos"
,
APIGroup
:
"csi.
storage.k8s.io"
,
Name
:
"node0"
},
attrs
:
authorizer
.
AttributesRecord
{
User
:
node0
,
ResourceRequest
:
true
,
Verb
:
"delete"
,
Resource
:
"csinode
s"
,
APIGroup
:
"
storage.k8s.io"
,
Name
:
"node0"
},
features
:
csiNodeInfoEnabledFeature
,
features
:
csiNodeInfoEnabledFeature
,
expect
:
authorizer
.
DecisionAllow
,
expect
:
authorizer
.
DecisionAllow
,
},
},
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go
View file @
85867e56
...
@@ -74,7 +74,7 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
...
@@ -74,7 +74,7 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIPersistentVolume
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIPersistentVolume
)
{
role
.
Rules
=
append
(
role
.
Rules
,
rbacv1helpers
.
NewRule
(
"get"
,
"create"
,
"delete"
,
"list"
,
"watch"
)
.
Groups
(
storageGroup
)
.
Resources
(
"volumeattachments"
)
.
RuleOrDie
())
role
.
Rules
=
append
(
role
.
Rules
,
rbacv1helpers
.
NewRule
(
"get"
,
"create"
,
"delete"
,
"list"
,
"watch"
)
.
Groups
(
storageGroup
)
.
Resources
(
"volumeattachments"
)
.
RuleOrDie
())
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIDriverRegistry
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIDriverRegistry
)
{
role
.
Rules
=
append
(
role
.
Rules
,
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"
csi.
storage.k8s.io"
)
.
Resources
(
"csidrivers"
)
.
RuleOrDie
())
role
.
Rules
=
append
(
role
.
Rules
,
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"storage.k8s.io"
)
.
Resources
(
"csidrivers"
)
.
RuleOrDie
())
}
}
}
}
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
View file @
85867e56
...
@@ -160,13 +160,13 @@ func NodeRules() []rbacv1.PolicyRule {
...
@@ -160,13 +160,13 @@ func NodeRules() []rbacv1.PolicyRule {
volAttachRule
:=
rbacv1helpers
.
NewRule
(
"get"
)
.
Groups
(
storageGroup
)
.
Resources
(
"volumeattachments"
)
.
RuleOrDie
()
volAttachRule
:=
rbacv1helpers
.
NewRule
(
"get"
)
.
Groups
(
storageGroup
)
.
Resources
(
"volumeattachments"
)
.
RuleOrDie
()
nodePolicyRules
=
append
(
nodePolicyRules
,
volAttachRule
)
nodePolicyRules
=
append
(
nodePolicyRules
,
volAttachRule
)
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIDriverRegistry
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSIDriverRegistry
)
{
csiDriverRule
:=
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"
csi.
storage.k8s.io"
)
.
Resources
(
"csidrivers"
)
.
RuleOrDie
()
csiDriverRule
:=
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"storage.k8s.io"
)
.
Resources
(
"csidrivers"
)
.
RuleOrDie
()
nodePolicyRules
=
append
(
nodePolicyRules
,
csiDriverRule
)
nodePolicyRules
=
append
(
nodePolicyRules
,
csiDriverRule
)
}
}
}
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
KubeletPluginsWatcher
)
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSINodeInfo
)
{
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSINodeInfo
)
{
csiNodeInfoRule
:=
rbacv1helpers
.
NewRule
(
"get"
,
"create"
,
"update"
,
"patch"
,
"delete"
)
.
Groups
(
"
csi.storage.k8s.io"
)
.
Resources
(
"csinodeinfo
s"
)
.
RuleOrDie
()
csiNodeInfoRule
:=
rbacv1helpers
.
NewRule
(
"get"
,
"create"
,
"update"
,
"patch"
,
"delete"
)
.
Groups
(
"
storage.k8s.io"
)
.
Resources
(
"csinode
s"
)
.
RuleOrDie
()
nodePolicyRules
=
append
(
nodePolicyRules
,
csiNodeInfoRule
)
nodePolicyRules
=
append
(
nodePolicyRules
,
csiNodeInfoRule
)
}
}
...
@@ -514,7 +514,7 @@ func ClusterRoles() []rbacv1.ClusterRole {
...
@@ -514,7 +514,7 @@ func ClusterRoles() []rbacv1.ClusterRole {
rbacv1helpers
.
NewRule
(
"get"
,
"list"
,
"watch"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"nodes"
)
.
RuleOrDie
(),
rbacv1helpers
.
NewRule
(
"get"
,
"list"
,
"watch"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"nodes"
)
.
RuleOrDie
(),
}
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSINodeInfo
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
CSINodeInfo
)
{
externalProvisionerRules
=
append
(
externalProvisionerRules
,
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"
csi.storage.k8s.io"
)
.
Resources
(
"csinodeinfo
s"
)
.
RuleOrDie
())
externalProvisionerRules
=
append
(
externalProvisionerRules
,
rbacv1helpers
.
NewRule
(
"get"
,
"watch"
,
"list"
)
.
Groups
(
"
storage.k8s.io"
)
.
Resources
(
"csinode
s"
)
.
RuleOrDie
())
}
}
roles
=
append
(
roles
,
rbacv1
.
ClusterRole
{
roles
=
append
(
roles
,
rbacv1
.
ClusterRole
{
// a role for the csi external provisioner
// a role for the csi external provisioner
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
View file @
85867e56
...
@@ -532,6 +532,14 @@ items:
...
@@ -532,6 +532,14 @@ items:
-
get
-
get
-
list
-
list
-
watch
-
watch
-
apiGroups
:
-
storage.k8s.io
resources
:
-
csinodes
verbs
:
-
get
-
list
-
watch
-
apiVersion
:
rbac.authorization.k8s.io/v1
-
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRole
kind
:
ClusterRole
metadata
:
metadata
:
...
@@ -986,6 +994,24 @@ items:
...
@@ -986,6 +994,24 @@ items:
verbs
:
verbs
:
-
get
-
get
-
apiGroups
:
-
apiGroups
:
-
storage.k8s.io
resources
:
-
csidrivers
verbs
:
-
get
-
list
-
watch
-
apiGroups
:
-
storage.k8s.io
resources
:
-
csinodes
verbs
:
-
create
-
delete
-
get
-
patch
-
update
-
apiGroups
:
-
coordination.k8s.io
-
coordination.k8s.io
resources
:
resources
:
-
leases
-
leases
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/controller-roles.yaml
View file @
85867e56
...
@@ -58,6 +58,14 @@ items:
...
@@ -58,6 +58,14 @@ items:
-
get
-
get
-
list
-
list
-
watch
-
watch
-
apiGroups
:
-
storage.k8s.io
resources
:
-
csidrivers
verbs
:
-
get
-
list
-
watch
-
apiVersion
:
rbac.authorization.k8s.io/v1
-
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRole
kind
:
ClusterRole
metadata
:
metadata
:
...
...
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