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
7b9d2c04
Commit
7b9d2c04
authored
Jan 22, 2018
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use v1beta1 VolumeAttachment
parent
8915e275
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
60 additions
and
44 deletions
+60
-44
config.go
pkg/kubeapiserver/authorizer/config.go
+1
-1
BUILD
pkg/master/BUILD
+1
-0
master_test.go
pkg/master/master_test.go
+3
-0
BUILD
pkg/volume/csi/BUILD
+2
-2
csi_attacher.go
pkg/volume/csi/csi_attacher.go
+6
-6
csi_attacher_test.go
pkg/volume/csi/csi_attacher_test.go
+7
-7
csi_mounter.go
pkg/volume/csi/csi_mounter.go
+1
-1
csi_mounter_test.go
pkg/volume/csi/csi_mounter_test.go
+2
-2
BUILD
plugin/pkg/auth/authorizer/node/BUILD
+3
-3
graph_populator.go
plugin/pkg/auth/authorizer/node/graph_populator.go
+4
-4
node_authorizer_test.go
plugin/pkg/auth/authorizer/node/node_authorizer_test.go
+5
-5
cluster-roles.yaml
...thorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
+6
-0
controller-roles.yaml
...rizer/rbac/bootstrappolicy/testdata/controller-roles.yaml
+10
-0
BUILD
test/integration/auth/BUILD
+1
-2
node_test.go
test/integration/auth/node_test.go
+5
-9
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+1
-0
master_utils.go
test/integration/framework/master_utils.go
+2
-2
No files found.
pkg/kubeapiserver/authorizer/config.go
View file @
7b9d2c04
...
...
@@ -82,7 +82,7 @@ func (config AuthorizationConfig) New() (authorizer.Authorizer, authorizer.RuleR
graph
,
config
.
InformerFactory
.
Core
()
.
InternalVersion
()
.
Pods
(),
config
.
InformerFactory
.
Core
()
.
InternalVersion
()
.
PersistentVolumes
(),
config
.
VersionedInformerFactory
.
Storage
()
.
V1
alph
a1
()
.
VolumeAttachments
(),
config
.
VersionedInformerFactory
.
Storage
()
.
V1
bet
a1
()
.
VolumeAttachments
(),
)
nodeAuthorizer
:=
node
.
NewAuthorizer
(
graph
,
nodeidentifier
.
NewDefaultNodeIdentifier
(),
bootstrappolicy
.
NodeRules
())
authorizers
=
append
(
authorizers
,
nodeAuthorizer
)
...
...
pkg/master/BUILD
View file @
7b9d2c04
...
...
@@ -132,6 +132,7 @@ go_test(
"//pkg/apis/core:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/rbac:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/client/clientset_generated/internalclientset/fake:go_default_library",
"//pkg/generated/openapi:go_default_library",
"//pkg/kubelet/client:go_default_library",
...
...
pkg/master/master_test.go
View file @
7b9d2c04
...
...
@@ -53,6 +53,7 @@ import (
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/apis/storage"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
"k8s.io/kubernetes/pkg/master/reconcilers"
certificatesrest
"k8s.io/kubernetes/pkg/registry/certificates/rest"
...
...
@@ -83,6 +84,8 @@ func setUp(t *testing.T) (*etcdtesting.EtcdTestServer, Config, informers.SharedI
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
*
testapi
.
Batch
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
// FIXME (soltysh): this GroupVersionResource override should be configurable
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"batch"
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
"storage.k8s.io"
,
Resource
:
"volumeattachments"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
apps
.
GroupName
,
*
testapi
.
Apps
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
apps
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
extensions
.
GroupName
,
*
testapi
.
Extensions
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
extensions
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetVersionEncoding
(
rbac
.
GroupName
,
*
testapi
.
Rbac
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
rbac
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
...
...
pkg/volume/csi/BUILD
View file @
7b9d2c04
...
...
@@ -20,7 +20,7 @@ go_library(
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/api/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
...
...
@@ -46,7 +46,7 @@ go_test(
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/api/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
pkg/volume/csi/csi_attacher.go
View file @
7b9d2c04
...
...
@@ -26,7 +26,7 @@ import (
"github.com/golang/glog"
"k8s.io/api/core/v1"
storage
"k8s.io/api/storage/v1
alph
a1"
storage
"k8s.io/api/storage/v1
bet
a1"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
meta
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -73,7 +73,7 @@ func (c *csiAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string
Status
:
storage
.
VolumeAttachmentStatus
{
Attached
:
false
},
}
_
,
err
=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
_
,
err
=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
alreadyExist
:=
false
if
err
!=
nil
{
if
!
apierrs
.
IsAlreadyExists
(
err
)
{
...
...
@@ -128,7 +128,7 @@ func (c *csiAttacher) waitForVolumeAttachment(volumeHandle, attachID string, tim
select
{
case
<-
ticker
.
C
:
glog
.
V
(
4
)
.
Info
(
log
(
"probing VolumeAttachment [id=%v]"
,
attachID
))
attach
,
err
:=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
attach
,
err
:=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
glog
.
Error
(
log
(
"attacher.WaitForAttach failed (will continue to try): %v"
,
err
))
continue
...
...
@@ -173,7 +173,7 @@ func (c *csiAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName types.No
attachID
:=
getAttachmentName
(
source
.
VolumeHandle
,
source
.
Driver
,
string
(
nodeName
))
glog
.
V
(
4
)
.
Info
(
log
(
"probing attachment status for VolumeAttachment %v"
,
attachID
))
attach
,
err
:=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
attach
,
err
:=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
glog
.
Error
(
log
(
"attacher.VolumesAreAttached failed for attach.ID=%v: %v"
,
attachID
,
err
))
continue
...
...
@@ -212,7 +212,7 @@ func (c *csiAttacher) Detach(volumeName string, nodeName types.NodeName) error {
driverName
:=
parts
[
0
]
volID
:=
parts
[
1
]
attachID
:=
getAttachmentName
(
volID
,
driverName
,
string
(
nodeName
))
if
err
:=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Delete
(
attachID
,
nil
);
err
!=
nil
{
if
err
:=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Delete
(
attachID
,
nil
);
err
!=
nil
{
glog
.
Error
(
log
(
"detacher.Detach failed to delete VolumeAttachment [%s]: %v"
,
attachID
,
err
))
return
err
}
...
...
@@ -236,7 +236,7 @@ func (c *csiAttacher) waitForVolumeDetachment(volumeHandle, attachID string) err
select
{
case
<-
ticker
.
C
:
glog
.
V
(
4
)
.
Info
(
log
(
"probing VolumeAttachment [id=%v]"
,
attachID
))
attach
,
err
:=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
attach
,
err
:=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
if
apierrs
.
IsNotFound
(
err
)
{
//object deleted or never existed, done
...
...
pkg/volume/csi/csi_attacher_test.go
View file @
7b9d2c04
...
...
@@ -22,7 +22,7 @@ import (
"testing"
"time"
storage
"k8s.io/api/storage/v1
alph
a1"
storage
"k8s.io/api/storage/v1
bet
a1"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
meta
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -129,7 +129,7 @@ func TestAttacherAttach(t *testing.T) {
// wait for attachment to be saved
var
attach
*
storage
.
VolumeAttachment
for
i
:=
0
;
i
<
100
;
i
++
{
attach
,
err
=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
tc
.
attachID
,
meta
.
GetOptions
{})
attach
,
err
=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
tc
.
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
if
apierrs
.
IsNotFound
(
err
)
{
<-
ticker
.
C
...
...
@@ -146,7 +146,7 @@ func TestAttacherAttach(t *testing.T) {
t
.
Error
(
"attachment not found"
)
}
attach
.
Status
.
Attached
=
true
_
,
err
=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Update
(
attach
)
_
,
err
=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Update
(
attach
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -188,7 +188,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) {
csiAttacher
.
waitSleepTime
=
tc
.
sleepTime
go
func
()
{
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to attach: %v"
,
err
)
}
...
...
@@ -239,7 +239,7 @@ func TestAttacherVolumesAreAttached(t *testing.T) {
attachID
:=
getAttachmentName
(
volName
,
testDriver
,
nodeName
)
attachment
:=
makeTestAttachment
(
attachID
,
nodeName
,
pv
.
GetName
())
attachment
.
Status
.
Attached
=
stat
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to attach: %v"
,
err
)
}
...
...
@@ -292,7 +292,7 @@ func TestAttacherDetach(t *testing.T) {
pv
:=
makeTestPV
(
"test-pv"
,
10
,
testDriver
,
tc
.
volID
)
spec
:=
volume
.
NewSpecFromPersistentVolume
(
pv
,
pv
.
Spec
.
PersistentVolumeSource
.
CSI
.
ReadOnly
)
attachment
:=
makeTestAttachment
(
tc
.
attachID
,
nodeName
,
"test-pv"
)
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
_
,
err
:=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to attach: %v"
,
err
)
}
...
...
@@ -307,7 +307,7 @@ func TestAttacherDetach(t *testing.T) {
if
!
tc
.
shouldFail
&&
err
!=
nil
{
t
.
Fatalf
(
"unexpected err: %v"
,
err
)
}
attach
,
err
:=
csiAttacher
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
tc
.
attachID
,
meta
.
GetOptions
{})
attach
,
err
:=
csiAttacher
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
tc
.
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
if
!
apierrs
.
IsNotFound
(
err
)
{
t
.
Fatalf
(
"unexpected err: %v"
,
err
)
...
...
pkg/volume/csi/csi_mounter.go
View file @
7b9d2c04
...
...
@@ -138,7 +138,7 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
// search for attachment by VolumeAttachment.Spec.Source.PersistentVolumeName
if
c
.
volumeInfo
==
nil
{
attachment
,
err
:=
c
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
attachment
,
err
:=
c
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
attachID
,
meta
.
GetOptions
{})
if
err
!=
nil
{
glog
.
Error
(
log
(
"mounter.SetupAt failed while getting volume attachment [id=%v]: %v"
,
attachID
,
err
))
return
err
...
...
pkg/volume/csi/csi_mounter_test.go
View file @
7b9d2c04
...
...
@@ -26,7 +26,7 @@ import (
"testing"
api
"k8s.io/api/core/v1"
storage
"k8s.io/api/storage/v1
alph
a1"
storage
"k8s.io/api/storage/v1
bet
a1"
meta
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
fakeclient
"k8s.io/client-go/kubernetes/fake"
...
...
@@ -135,7 +135,7 @@ func TestMounterSetUp(t *testing.T) {
DetachError
:
nil
,
},
}
_
,
err
=
csiMounter
.
k8s
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
_
,
err
=
csiMounter
.
k8s
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Create
(
attachment
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to setup VolumeAttachment: %v"
,
err
)
}
...
...
plugin/pkg/auth/authorizer/node/BUILD
View file @
7b9d2c04
...
...
@@ -16,7 +16,7 @@ go_test(
"//pkg/auth/nodeidentifier:go_default_library",
"//pkg/features:go_default_library",
"//plugin/pkg/auth/authorizer/rbac/bootstrappolicy:go_default_library",
"//vendor/k8s.io/api/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/api/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
...
...
@@ -46,11 +46,11 @@ go_library(
"//third_party/forked/gonum/graph/simple:go_default_library",
"//third_party/forked/gonum/graph/traverse:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/api/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/client-go/informers/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/client-go/informers/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
],
)
...
...
plugin/pkg/auth/authorizer/node/graph_populator.go
View file @
7b9d2c04
...
...
@@ -19,9 +19,9 @@ package node
import
(
"github.com/golang/glog"
storagev1
alpha1
"k8s.io/api/storage/v1alph
a1"
storagev1
beta1
"k8s.io/api/storage/v1bet
a1"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
storageinformers
"k8s.io/client-go/informers/storage/v1
alph
a1"
storageinformers
"k8s.io/client-go/informers/storage/v1
bet
a1"
"k8s.io/client-go/tools/cache"
api
"k8s.io/kubernetes/pkg/apis/core"
coreinformers
"k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/core/internalversion"
...
...
@@ -129,10 +129,10 @@ func (g *graphPopulator) addVolumeAttachment(obj interface{}) {
}
func
(
g
*
graphPopulator
)
updateVolumeAttachment
(
oldObj
,
obj
interface
{})
{
attachment
:=
obj
.
(
*
storagev1
alph
a1
.
VolumeAttachment
)
attachment
:=
obj
.
(
*
storagev1
bet
a1
.
VolumeAttachment
)
if
oldObj
!=
nil
{
// skip add if node name is identical
oldAttachment
:=
oldObj
.
(
*
storagev1
alph
a1
.
VolumeAttachment
)
oldAttachment
:=
oldObj
.
(
*
storagev1
bet
a1
.
VolumeAttachment
)
if
oldAttachment
.
Spec
.
NodeName
==
attachment
.
Spec
.
NodeName
{
return
}
...
...
plugin/pkg/auth/authorizer/node/node_authorizer_test.go
View file @
7b9d2c04
...
...
@@ -24,7 +24,7 @@ import (
"os"
storagev1
alpha1
"k8s.io/api/storage/v1alph
a1"
storagev1
beta1
"k8s.io/api/storage/v1bet
a1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/authentication/user"
"k8s.io/apiserver/pkg/authorization/authorizer"
...
...
@@ -429,7 +429,7 @@ func BenchmarkAuthorization(b *testing.B) {
}
}
func
populate
(
graph
*
Graph
,
pods
[]
*
api
.
Pod
,
pvs
[]
*
api
.
PersistentVolume
,
attachments
[]
*
storagev1
alph
a1
.
VolumeAttachment
)
{
func
populate
(
graph
*
Graph
,
pods
[]
*
api
.
Pod
,
pvs
[]
*
api
.
PersistentVolume
,
attachments
[]
*
storagev1
bet
a1
.
VolumeAttachment
)
{
p
:=
&
graphPopulator
{}
p
.
graph
=
graph
for
_
,
pod
:=
range
pods
{
...
...
@@ -447,10 +447,10 @@ func populate(graph *Graph, pods []*api.Pod, pvs []*api.PersistentVolume, attach
// the secret/configmap/pvc/node references in the pod and pv objects are named to indicate the connections between the objects.
// for example, secret0-pod0-node0 is a secret referenced by pod0 which is bound to node0.
// when populated into the graph, the node authorizer should allow node0 to access that secret, but not node1.
func
generate
(
opts
sampleDataOpts
)
([]
*
api
.
Pod
,
[]
*
api
.
PersistentVolume
,
[]
*
storagev1
alph
a1
.
VolumeAttachment
)
{
func
generate
(
opts
sampleDataOpts
)
([]
*
api
.
Pod
,
[]
*
api
.
PersistentVolume
,
[]
*
storagev1
bet
a1
.
VolumeAttachment
)
{
pods
:=
make
([]
*
api
.
Pod
,
0
,
opts
.
nodes
*
opts
.
podsPerNode
)
pvs
:=
make
([]
*
api
.
PersistentVolume
,
0
,
(
opts
.
nodes
*
opts
.
podsPerNode
*
opts
.
uniquePVCsPerPod
)
+
(
opts
.
sharedPVCsPerPod
*
opts
.
namespaces
))
attachments
:=
make
([]
*
storagev1
alph
a1
.
VolumeAttachment
,
0
,
opts
.
nodes
*
opts
.
attachmentsPerNode
)
attachments
:=
make
([]
*
storagev1
bet
a1
.
VolumeAttachment
,
0
,
opts
.
nodes
*
opts
.
attachmentsPerNode
)
for
n
:=
0
;
n
<
opts
.
nodes
;
n
++
{
nodeName
:=
fmt
.
Sprintf
(
"node%d"
,
n
)
...
...
@@ -508,7 +508,7 @@ func generate(opts sampleDataOpts) ([]*api.Pod, []*api.PersistentVolume, []*stor
pods
=
append
(
pods
,
pod
)
}
for
a
:=
0
;
a
<
opts
.
attachmentsPerNode
;
a
++
{
attachment
:=
&
storagev1
alph
a1
.
VolumeAttachment
{}
attachment
:=
&
storagev1
bet
a1
.
VolumeAttachment
{}
attachment
.
Name
=
fmt
.
Sprintf
(
"attachment%d-%s"
,
a
,
nodeName
)
attachment
.
Spec
.
NodeName
=
nodeName
attachments
=
append
(
attachments
,
attachment
)
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
View file @
7b9d2c04
...
...
@@ -1033,6 +1033,12 @@ items:
-
get
-
list
-
watch
-
apiGroups
:
-
storage.k8s.io
resources
:
-
volumeattachments
verbs
:
-
get
-
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRole
metadata
:
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/controller-roles.yaml
View file @
7b9d2c04
...
...
@@ -48,6 +48,16 @@ items:
-
create
-
patch
-
update
-
apiGroups
:
-
storage.k8s.io
resources
:
-
volumeattachments
verbs
:
-
create
-
delete
-
get
-
list
-
watch
-
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRole
metadata
:
...
...
test/integration/auth/BUILD
View file @
7b9d2c04
...
...
@@ -51,7 +51,7 @@ go_test(
"//test/integration/framework:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/authentication/v1beta1:go_default_library",
"//vendor/k8s.io/api/storage/v1
alph
a1:go_default_library",
"//vendor/k8s.io/api/storage/v1
bet
a1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
@@ -69,7 +69,6 @@ go_test(
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizerfactory:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server/storage:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature/testing:go_default_library",
"//vendor/k8s.io/apiserver/plugin/pkg/authenticator/token/tokentest:go_default_library",
...
...
test/integration/auth/node_test.go
View file @
7b9d2c04
...
...
@@ -23,7 +23,7 @@ import (
"testing"
"time"
storagev1
alpha1
"k8s.io/api/storage/v1alph
a1"
storagev1
beta1
"k8s.io/api/storage/v1bet
a1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -32,7 +32,6 @@ import (
"k8s.io/apiserver/pkg/authentication/request/bearertoken"
"k8s.io/apiserver/pkg/authentication/token/tokenfile"
"k8s.io/apiserver/pkg/authentication/user"
serverstorage
"k8s.io/apiserver/pkg/server/storage"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeaturetesting
"k8s.io/apiserver/pkg/util/feature/testing"
versionedinformers
"k8s.io/client-go/informers"
...
...
@@ -106,9 +105,6 @@ func TestNodeAuthorizer(t *testing.T) {
masterConfig
.
GenericConfig
.
Authorizer
=
nodeRBACAuthorizer
masterConfig
.
GenericConfig
.
AdmissionControl
=
nodeRestrictionAdmission
// enable testing volume attachments
masterConfig
.
ExtraConfig
.
APIResourceConfigSource
.
(
*
serverstorage
.
ResourceConfig
)
.
EnableVersions
(
storagev1alpha1
.
SchemeGroupVersion
)
_
,
_
,
closeFn
:=
framework
.
RunAMasterUsingServer
(
masterConfig
,
apiServer
,
h
)
defer
closeFn
()
...
...
@@ -140,11 +136,11 @@ func TestNodeAuthorizer(t *testing.T) {
t
.
Fatal
(
err
)
}
pvName
:=
"mypv"
if
_
,
err
:=
superuserClientExternal
.
StorageV1
alpha1
()
.
VolumeAttachments
()
.
Create
(
&
storagev1alph
a1
.
VolumeAttachment
{
if
_
,
err
:=
superuserClientExternal
.
StorageV1
beta1
()
.
VolumeAttachments
()
.
Create
(
&
storagev1bet
a1
.
VolumeAttachment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"myattachment"
},
Spec
:
storagev1
alph
a1
.
VolumeAttachmentSpec
{
Spec
:
storagev1
bet
a1
.
VolumeAttachmentSpec
{
Attacher
:
"foo"
,
Source
:
storagev1
alph
a1
.
VolumeAttachmentSource
{
PersistentVolumeName
:
&
pvName
},
Source
:
storagev1
bet
a1
.
VolumeAttachmentSource
{
PersistentVolumeName
:
&
pvName
},
NodeName
:
"node2"
,
},
});
err
!=
nil
{
...
...
@@ -204,7 +200,7 @@ func TestNodeAuthorizer(t *testing.T) {
}
getVolumeAttachment
:=
func
(
client
externalclientset
.
Interface
)
func
()
error
{
return
func
()
error
{
_
,
err
:=
client
.
StorageV1
alph
a1
()
.
VolumeAttachments
()
.
Get
(
"myattachment"
,
metav1
.
GetOptions
{})
_
,
err
:=
client
.
StorageV1
bet
a1
()
.
VolumeAttachments
()
.
Get
(
"myattachment"
,
metav1
.
GetOptions
{})
return
err
}
}
...
...
test/integration/etcd/etcd_storage_path_test.go
View file @
7b9d2c04
...
...
@@ -298,6 +298,7 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
gvr
(
"storage.k8s.io"
,
"v1alpha1"
,
"volumeattachments"
)
:
{
stub
:
`{"metadata": {"name": "va1"}, "spec": {"attacher": "gce", "nodeName": "localhost", "source": {"persistentVolumeName": "pv1"}}}`
,
expectedEtcdPath
:
"/registry/volumeattachments/va1"
,
expectedGVK
:
gvkP
(
"storage.k8s.io"
,
"v1beta1"
,
"VolumeAttachment"
),
},
// --
...
...
test/integration/framework/master_utils.go
View file @
7b9d2c04
...
...
@@ -236,9 +236,9 @@ func NewMasterConfig() *master.Config {
// we need to set both for the whole group and for cronjobs, separately
resourceEncoding
.
SetVersionEncoding
(
batch
.
GroupName
,
*
testapi
.
Batch
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
batch
.
GroupName
,
Resource
:
"cronjobs"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
"v1beta1"
},
schema
.
GroupVersion
{
Group
:
batch
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
//
volumeattachments only exist in storage.k8s.io/v1alpha1
//
we also need to set both for the storage group and for volumeattachments, separately
resourceEncoding
.
SetVersionEncoding
(
storage
.
GroupName
,
*
testapi
.
Storage
.
GroupVersion
(),
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
storage
.
GroupName
,
Resource
:
"volumeattachments"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
"v1
alph
a1"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
resourceEncoding
.
SetResourceEncoding
(
schema
.
GroupResource
{
Group
:
storage
.
GroupName
,
Resource
:
"volumeattachments"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
"v1
bet
a1"
},
schema
.
GroupVersion
{
Group
:
storage
.
GroupName
,
Version
:
runtime
.
APIVersionInternal
})
storageFactory
:=
serverstorage
.
NewDefaultStorageFactory
(
etcdOptions
.
StorageConfig
,
runtime
.
ContentTypeJSON
,
ns
,
resourceEncoding
,
master
.
DefaultAPIResourceConfigSource
(),
nil
)
storageFactory
.
SetSerializer
(
...
...
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