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
d45a4180
Commit
d45a4180
authored
Jan 18, 2018
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Beta VolumeAttachment API
parent
494664a7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
13 deletions
+142
-13
server.go
cmd/kube-apiserver/app/server.go
+1
-1
storage_storage.go
pkg/registry/storage/rest/storage_storage.go
+4
-0
BUILD
pkg/registry/storage/volumeattachment/storage/BUILD
+1
-0
storage_test.go
...registry/storage/volumeattachment/storage/storage_test.go
+19
-12
register.go
staging/src/k8s.io/api/storage/v1beta1/register.go
+3
-0
types.go
staging/src/k8s.io/api/storage/v1beta1/types.go
+107
-0
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+7
-0
No files found.
cmd/kube-apiserver/app/server.go
View file @
d45a4180
...
@@ -586,7 +586,7 @@ func BuildStorageFactory(s *options.ServerRunOptions, apiResourceConfig *servers
...
@@ -586,7 +586,7 @@ func BuildStorageFactory(s *options.ServerRunOptions, apiResourceConfig *servers
// FIXME (soltysh): this GroupVersionResource override should be configurable
// FIXME (soltysh): this GroupVersionResource override should be configurable
[]
schema
.
GroupVersionResource
{
[]
schema
.
GroupVersionResource
{
batch
.
Resource
(
"cronjobs"
)
.
WithVersion
(
"v1beta1"
),
batch
.
Resource
(
"cronjobs"
)
.
WithVersion
(
"v1beta1"
),
storage
.
Resource
(
"volumeattachments"
)
.
WithVersion
(
"v1
alph
a1"
),
storage
.
Resource
(
"volumeattachments"
)
.
WithVersion
(
"v1
bet
a1"
),
admissionregistration
.
Resource
(
"initializerconfigurations"
)
.
WithVersion
(
"v1alpha1"
),
admissionregistration
.
Resource
(
"initializerconfigurations"
)
.
WithVersion
(
"v1alpha1"
),
},
},
apiResourceConfig
)
apiResourceConfig
)
...
...
pkg/registry/storage/rest/storage_storage.go
View file @
d45a4180
...
@@ -69,6 +69,10 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag
...
@@ -69,6 +69,10 @@ func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorag
storageClassStorage
:=
storageclassstore
.
NewREST
(
restOptionsGetter
)
storageClassStorage
:=
storageclassstore
.
NewREST
(
restOptionsGetter
)
storage
[
"storageclasses"
]
=
storageClassStorage
storage
[
"storageclasses"
]
=
storageClassStorage
// volumeattachments
volumeAttachmentStorage
:=
volumeattachmentstore
.
NewREST
(
restOptionsGetter
)
storage
[
"volumeattachments"
]
=
volumeAttachmentStorage
return
storage
return
storage
}
}
...
...
pkg/registry/storage/volumeattachment/storage/BUILD
View file @
d45a4180
...
@@ -24,6 +24,7 @@ go_test(
...
@@ -24,6 +24,7 @@ go_test(
"//pkg/apis/storage:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/registry/registrytest:go_default_library",
"//pkg/registry/registrytest:go_default_library",
"//vendor/k8s.io/api/storage/v1alpha1:go_default_library",
"//vendor/k8s.io/api/storage/v1alpha1:go_default_library",
"//vendor/k8s.io/api/storage/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
...
...
pkg/registry/storage/volumeattachment/storage/storage_test.go
View file @
d45a4180
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"testing"
"testing"
storageapiv1alpha1
"k8s.io/api/storage/v1alpha1"
storageapiv1alpha1
"k8s.io/api/storage/v1alpha1"
storageapiv1beta1
"k8s.io/api/storage/v1beta1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
...
@@ -61,8 +62,9 @@ func validNewVolumeAttachment(name string) *storageapi.VolumeAttachment {
...
@@ -61,8 +62,9 @@ func validNewVolumeAttachment(name string) *storageapi.VolumeAttachment {
}
}
func
TestCreate
(
t
*
testing
.
T
)
{
func
TestCreate
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions exception v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
@@ -91,8 +93,9 @@ func TestCreate(t *testing.T) {
...
@@ -91,8 +93,9 @@ func TestCreate(t *testing.T) {
}
}
func
TestUpdate
(
t
*
testing
.
T
)
{
func
TestUpdate
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions except v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
@@ -119,8 +122,9 @@ func TestUpdate(t *testing.T) {
...
@@ -119,8 +122,9 @@ func TestUpdate(t *testing.T) {
}
}
func
TestDelete
(
t
*
testing
.
T
)
{
func
TestDelete
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions except v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
@@ -132,8 +136,9 @@ func TestDelete(t *testing.T) {
...
@@ -132,8 +136,9 @@ func TestDelete(t *testing.T) {
}
}
func
TestGet
(
t
*
testing
.
T
)
{
func
TestGet
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions except v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
@@ -145,8 +150,9 @@ func TestGet(t *testing.T) {
...
@@ -145,8 +150,9 @@ func TestGet(t *testing.T) {
}
}
func
TestList
(
t
*
testing
.
T
)
{
func
TestList
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions except v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
@@ -158,8 +164,9 @@ func TestList(t *testing.T) {
...
@@ -158,8 +164,9 @@ func TestList(t *testing.T) {
}
}
func
TestWatch
(
t
*
testing
.
T
)
{
func
TestWatch
(
t
*
testing
.
T
)
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
{
if
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1alpha1
.
SchemeGroupVersion
&&
// skip the test for all versions except v1alpha1
*
testapi
.
Storage
.
GroupVersion
()
!=
storageapiv1beta1
.
SchemeGroupVersion
{
// skip the test for all versions exception v1alpha1 and v1beta1
return
return
}
}
...
...
staging/src/k8s.io/api/storage/v1beta1/register.go
View file @
d45a4180
...
@@ -46,6 +46,9 @@ func addKnownTypes(scheme *runtime.Scheme) error {
...
@@ -46,6 +46,9 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
StorageClass
{},
&
StorageClass
{},
&
StorageClassList
{},
&
StorageClassList
{},
&
VolumeAttachment
{},
&
VolumeAttachmentList
{},
)
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
...
...
staging/src/k8s.io/api/storage/v1beta1/types.go
View file @
d45a4180
...
@@ -96,3 +96,110 @@ const (
...
@@ -96,3 +96,110 @@ const (
// binding will occur during Pod scheduing.
// binding will occur during Pod scheduing.
VolumeBindingWaitForFirstConsumer
VolumeBindingMode
=
"WaitForFirstConsumer"
VolumeBindingWaitForFirstConsumer
VolumeBindingMode
=
"WaitForFirstConsumer"
)
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// VolumeAttachment captures the intent to attach or detach the specified volume
// to/from the specified node.
//
// VolumeAttachment objects are non-namespaced.
type
VolumeAttachment
struct
{
metav1
.
TypeMeta
`json:",inline"`
// Standard object metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1
.
ObjectMeta
`json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Specification of the desired attach/detach volume behavior.
// Populated by the Kubernetes system.
Spec
VolumeAttachmentSpec
`json:"spec" protobuf:"bytes,2,opt,name=spec"`
// Status of the VolumeAttachment request.
// Populated by the entity completing the attach or detach
// operation, i.e. the external-attacher.
// +optional
Status
VolumeAttachmentStatus
`json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// VolumeAttachmentList is a collection of VolumeAttachment objects.
type
VolumeAttachmentList
struct
{
metav1
.
TypeMeta
`json:",inline"`
// Standard list metadata
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1
.
ListMeta
`json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of VolumeAttachments
Items
[]
VolumeAttachment
`json:"items" protobuf:"bytes,2,rep,name=items"`
}
// VolumeAttachmentSpec is the specification of a VolumeAttachment request.
type
VolumeAttachmentSpec
struct
{
// Attacher indicates the name of the volume driver that MUST handle this
// request. This is the name returned by GetPluginName().
Attacher
string
`json:"attacher" protobuf:"bytes,1,opt,name=attacher"`
// Source represents the volume that should be attached.
Source
VolumeAttachmentSource
`json:"source" protobuf:"bytes,2,opt,name=source"`
// The node that the volume should be attached to.
NodeName
string
`json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"`
}
// VolumeAttachmentSource represents a volume that should be attached.
// Right now only PersistenVolumes can be attached via external attacher,
// in future we may allow also inline volumes in pods.
// Exactly one member can be set.
type
VolumeAttachmentSource
struct
{
// Name of the persistent volume to attach.
// +optional
PersistentVolumeName
*
string
`json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
// Placeholder for *VolumeSource to accommodate inline volumes in pods.
}
// VolumeAttachmentStatus is the status of a VolumeAttachment request.
type
VolumeAttachmentStatus
struct
{
// Indicates the volume is successfully attached.
// This field must only be set by the entity completing the attach
// operation, i.e. the external-attacher.
Attached
bool
`json:"attached" protobuf:"varint,1,opt,name=attached"`
// Upon successful attach, this field is populated with any
// information returned by the attach operation that must be passed
// into subsequent WaitForAttach or Mount calls.
// This field must only be set by the entity completing the attach
// operation, i.e. the external-attacher.
// +optional
AttachmentMetadata
map
[
string
]
string
`json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"`
// The last error encountered during attach operation, if any.
// This field must only be set by the entity completing the attach
// operation, i.e. the external-attacher.
// +optional
AttachError
*
VolumeError
`json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"`
// The last error encountered during detach operation, if any.
// This field must only be set by the entity completing the detach
// operation, i.e. the external-attacher.
// +optional
DetachError
*
VolumeError
`json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"`
}
// VolumeError captures an error encountered during a volume operation.
type
VolumeError
struct
{
// Time the error was encountered.
// +optional
Time
metav1
.
Time
`json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
// String detailing the error encountered during Attach or Detach operation.
// This string maybe logged, so it should not contain sensitive
// information.
// +optional
Message
string
`json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}
test/integration/etcd/etcd_storage_path_test.go
View file @
d45a4180
...
@@ -302,6 +302,13 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
...
@@ -302,6 +302,13 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
// --
// --
// k8s.io/kubernetes/pkg/apis/storage/v1beta1
// k8s.io/kubernetes/pkg/apis/storage/v1beta1
gvr
(
"storage.k8s.io"
,
"v1beta1"
,
"volumeattachments"
)
:
{
stub
:
`{"metadata": {"name": "va2"}, "spec": {"attacher": "gce", "nodeName": "localhost", "source": {"persistentVolumeName": "pv2"}}}`
,
expectedEtcdPath
:
"/registry/volumeattachments/va2"
,
},
// --
// k8s.io/kubernetes/pkg/apis/storage/v1beta1
gvr
(
"storage.k8s.io"
,
"v1beta1"
,
"storageclasses"
)
:
{
gvr
(
"storage.k8s.io"
,
"v1beta1"
,
"storageclasses"
)
:
{
stub
:
`{"metadata": {"name": "sc1"}, "provisioner": "aws"}`
,
stub
:
`{"metadata": {"name": "sc1"}, "provisioner": "aws"}`
,
expectedEtcdPath
:
"/registry/storageclasses/sc1"
,
expectedEtcdPath
:
"/registry/storageclasses/sc1"
,
...
...
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