Skip to content

Commit ebe8ea7

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#54463 from saad-ali/volumeAttachmentAPI
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Introduce new `VolumeAttachment` API Object **What this PR does / why we need it**: Introduce a new `VolumeAttachment` API Object. This object will be used by the CSI volume plugin to enable external attachers (see design [here](kubernetes/community#1258). In the future, existing volume plugins can be refactored to use this object as well. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: Part of issue kubernetes/enhancements#178 **Special notes for your reviewer**: None **Release note**: ```release-note NONE ```
2 parents bc22e20 + 9f294c1 commit ebe8ea7

File tree

93 files changed

+10661
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+10661
-9
lines changed

api/openapi-spec/swagger.json

+889
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/resourceListing.json

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/storage.k8s.io_v1alpha1.json

+1,272
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kube-apiserver/app/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ go_library(
2121
"//pkg/apis/core:go_default_library",
2222
"//pkg/apis/extensions:go_default_library",
2323
"//pkg/apis/networking:go_default_library",
24+
"//pkg/apis/storage:go_default_library",
2425
"//pkg/capabilities:go_default_library",
2526
"//pkg/client/clientset_generated/internalclientset:go_default_library",
2627
"//pkg/client/informers/informers_generated/internalversion:go_default_library",

cmd/kube-apiserver/app/aggregator.go

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
223223
{Group: "settings.k8s.io", Version: "v1alpha1"}: {group: 16900, version: 9},
224224
{Group: "storage.k8s.io", Version: "v1"}: {group: 16800, version: 15},
225225
{Group: "storage.k8s.io", Version: "v1beta1"}: {group: 16800, version: 9},
226+
{Group: "storage.k8s.io", Version: "v1alpha1"}: {group: 16800, version: 1},
226227
{Group: "apiextensions.k8s.io", Version: "v1beta1"}: {group: 16700, version: 9},
227228
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {group: 16700, version: 9},
228229
{Group: "scheduling.k8s.io", Version: "v1alpha1"}: {group: 16600, version: 9},

cmd/kube-apiserver/app/server.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import (
6464
"k8s.io/kubernetes/pkg/apis/batch"
6565
"k8s.io/kubernetes/pkg/apis/extensions"
6666
"k8s.io/kubernetes/pkg/apis/networking"
67+
"k8s.io/kubernetes/pkg/apis/storage"
6768
"k8s.io/kubernetes/pkg/capabilities"
6869
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
6970
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
@@ -556,7 +557,10 @@ func BuildStorageFactory(s *options.ServerRunOptions) (*serverstorage.DefaultSto
556557
s.Etcd.StorageConfig, s.Etcd.DefaultStorageMediaType, legacyscheme.Codecs,
557558
serverstorage.NewDefaultResourceEncodingConfig(legacyscheme.Registry), storageGroupsToEncodingVersion,
558559
// FIXME (soltysh): this GroupVersionResource override should be configurable
559-
[]schema.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v1beta1")},
560+
[]schema.GroupVersionResource{
561+
batch.Resource("cronjobs").WithVersion("v1beta1"),
562+
storage.Resource("volumeattachments").WithVersion("v1alpha1"),
563+
},
560564
master.DefaultAPIResourceConfigSource(), s.APIEnablement.RuntimeConfig)
561565
if err != nil {
562566
return nil, fmt.Errorf("error in initializing storage factory: %s", err)

docs/api-reference/storage.k8s.io/v1alpha1/definitions.html

+1,549
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api-reference/storage.k8s.io/v1alpha1/operations.html

+1,792
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/.golint_failures

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pkg/apis/storage
7373
pkg/apis/storage/util
7474
pkg/apis/storage/v1
7575
pkg/apis/storage/v1/util
76+
pkg/apis/storage/v1alpha1
7677
pkg/apis/storage/v1beta1
7778
pkg/apis/storage/v1beta1/util
7879
pkg/auth/authorizer/abac
@@ -458,6 +459,7 @@ staging/src/k8s.io/api/rbac/v1beta1
458459
staging/src/k8s.io/api/scheduling/v1alpha1
459460
staging/src/k8s.io/api/settings/v1alpha1
460461
staging/src/k8s.io/api/storage/v1
462+
staging/src/k8s.io/api/storage/v1alpha1
461463
staging/src/k8s.io/api/storage/v1beta1
462464
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr
463465
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1
@@ -669,6 +671,8 @@ staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1
669671
staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake
670672
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1
671673
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/fake
674+
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1
675+
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/fake
672676
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1
673677
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/fake
674678
staging/src/k8s.io/client-go/plugin/pkg/auth/authenticator/token/oidc/testing

hack/lib/init.sh

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ rbac.authorization.k8s.io/v1beta1 \
7676
rbac.authorization.k8s.io/v1alpha1 \
7777
scheduling.k8s.io/v1alpha1 \
7878
settings.k8s.io/v1alpha1 \
79+
storage.k8s.io/v1alpha1 \
7980
storage.k8s.io/v1beta1 \
8081
storage.k8s.io/v1 \
8182
}"

hack/update-generated-protobuf-dockerized.sh

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ PACKAGES=(
6767
k8s.io/api/imagepolicy/v1alpha1
6868
k8s.io/api/scheduling/v1alpha1
6969
k8s.io/api/settings/v1alpha1
70+
k8s.io/api/storage/v1alpha1
7071
k8s.io/api/storage/v1beta1
7172
k8s.io/api/storage/v1
7273
k8s.io/api/admissionregistration/v1alpha1

pkg/apis/storage/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ filegroup(
3737
"//pkg/apis/storage/install:all-srcs",
3838
"//pkg/apis/storage/util:all-srcs",
3939
"//pkg/apis/storage/v1:all-srcs",
40+
"//pkg/apis/storage/v1alpha1:all-srcs",
4041
"//pkg/apis/storage/v1beta1:all-srcs",
4142
"//pkg/apis/storage/validation:all-srcs",
4243
],

pkg/apis/storage/install/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ go_library(
1313
"//pkg/api/legacyscheme:go_default_library",
1414
"//pkg/apis/storage:go_default_library",
1515
"//pkg/apis/storage/v1:go_default_library",
16+
"//pkg/apis/storage/v1alpha1:go_default_library",
1617
"//pkg/apis/storage/v1beta1:go_default_library",
1718
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
1819
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",

pkg/apis/storage/install/install.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"k8s.io/kubernetes/pkg/api/legacyscheme"
2727
"k8s.io/kubernetes/pkg/apis/storage"
2828
"k8s.io/kubernetes/pkg/apis/storage/v1"
29+
"k8s.io/kubernetes/pkg/apis/storage/v1alpha1"
2930
"k8s.io/kubernetes/pkg/apis/storage/v1beta1"
3031
)
3132

@@ -37,14 +38,18 @@ func init() {
3738
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
3839
if err := announced.NewGroupMetaFactory(
3940
&announced.GroupMetaFactoryArgs{
40-
GroupName: storage.GroupName,
41-
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
42-
RootScopedKinds: sets.NewString("StorageClass"),
41+
GroupName: storage.GroupName,
42+
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version, v1alpha1.SchemeGroupVersion.Version},
43+
RootScopedKinds: sets.NewString(
44+
"StorageClass",
45+
"VolumeAttachment",
46+
),
4347
AddInternalObjectsToScheme: storage.AddToScheme,
4448
},
4549
announced.VersionToSchemeFunc{
46-
v1.SchemeGroupVersion.Version: v1.AddToScheme,
47-
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
50+
v1.SchemeGroupVersion.Version: v1.AddToScheme,
51+
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
52+
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme,
4853
},
4954
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
5055
panic(err)

pkg/apis/storage/register.go

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4646
scheme.AddKnownTypes(SchemeGroupVersion,
4747
&StorageClass{},
4848
&StorageClassList{},
49+
&VolumeAttachment{},
50+
&VolumeAttachmentList{},
4951
)
5052
return nil
5153
}

pkg/apis/storage/types.go

+107
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,110 @@ type StorageClassList struct {
8080
// Items is the list of StorageClasses
8181
Items []StorageClass
8282
}
83+
84+
// +genclient
85+
// +genclient:nonNamespaced
86+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
87+
88+
// Captures the intent to attach or detach the specified volume to/from
89+
// the specified node.
90+
//
91+
// VolumeAttachment objects are non-namespaced.
92+
type VolumeAttachment struct {
93+
metav1.TypeMeta
94+
95+
// Standard object metadata.
96+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
97+
// +optional
98+
metav1.ObjectMeta
99+
100+
// Specification of the desired attach/detach volume behavior.
101+
// Populated by the Kubernetes system.
102+
Spec VolumeAttachmentSpec
103+
104+
// Status of the VolumeAttachment request.
105+
// Populated by the entity completing the attach or detach
106+
// operation, i.e. the external-attacher.
107+
// +optional
108+
Status VolumeAttachmentStatus
109+
}
110+
111+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
112+
113+
// VolumeAttachmentList is a collection of VolumeAttachment objects.
114+
type VolumeAttachmentList struct {
115+
metav1.TypeMeta
116+
// Standard list metadata
117+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
118+
// +optional
119+
metav1.ListMeta
120+
121+
// Items is the list of VolumeAttachments
122+
Items []VolumeAttachment
123+
}
124+
125+
// The specification of a VolumeAttachment request.
126+
type VolumeAttachmentSpec struct {
127+
// Attacher indicates the name of the volume driver that MUST handle this
128+
// request. This is the name returned by GetPluginName().
129+
Attacher string
130+
131+
// Source represents the volume that should be attached.
132+
Source VolumeAttachmentSource
133+
134+
// The node that the volume should be attached to.
135+
NodeName string
136+
}
137+
138+
// VolumeAttachmentSource represents a volume that should be attached.
139+
// Right now only PersistenVolumes can be attached via external attacher,
140+
// in future we may allow also inline volumes in pods.
141+
// Exactly one member can be set.
142+
type VolumeAttachmentSource struct {
143+
// Name of the persistent volume to attach.
144+
// +optional
145+
PersistentVolumeName *string
146+
147+
// Placeholder for *VolumeSource to accommodate inline volumes in pods.
148+
}
149+
150+
// The status of a VolumeAttachment request.
151+
type VolumeAttachmentStatus struct {
152+
// Indicates the volume is successfully attached.
153+
// This field must only be set by the entity completing the attach
154+
// operation, i.e. the external-attacher.
155+
Attached bool
156+
157+
// Upon successful attach, this field is populated with any
158+
// information returned by the attach operation that must be passed
159+
// into subsequent WaitForAttach or Mount calls.
160+
// This field must only be set by the entity completing the attach
161+
// operation, i.e. the external-attacher.
162+
// +optional
163+
AttachmentMetadata map[string]string
164+
165+
// The last error encountered during attach operation, if any.
166+
// This field must only be set by the entity completing the attach
167+
// operation, i.e. the external-attacher.
168+
// +optional
169+
AttachError *VolumeError
170+
171+
// The last error encountered during detach operation, if any.
172+
// This field must only be set by the entity completing the detach
173+
// operation, i.e. the external-attacher.
174+
// +optional
175+
DetachError *VolumeError
176+
}
177+
178+
// Captures an error encountered during a volume operation.
179+
type VolumeError struct {
180+
// Time the error was encountered.
181+
// +optional
182+
Time metav1.Time
183+
184+
// String detailing the error encountered during Attach or Detach operation.
185+
// This string maybe logged, so it should not contain sensitive
186+
// information.
187+
// +optional
188+
Message string
189+
}

pkg/apis/storage/v1alpha1/BUILD

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = [
6+
"doc.go",
7+
"register.go",
8+
"zz_generated.conversion.go",
9+
"zz_generated.defaults.go",
10+
],
11+
importpath = "k8s.io/kubernetes/pkg/apis/storage/v1alpha1",
12+
visibility = ["//visibility:public"],
13+
deps = [
14+
"//pkg/apis/storage:go_default_library",
15+
"//vendor/k8s.io/api/storage/v1alpha1:go_default_library",
16+
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
17+
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
18+
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
19+
],
20+
)
21+
22+
filegroup(
23+
name = "package-srcs",
24+
srcs = glob(["**"]),
25+
tags = ["automanaged"],
26+
visibility = ["//visibility:private"],
27+
)
28+
29+
filegroup(
30+
name = "all-srcs",
31+
srcs = [":package-srcs"],
32+
tags = ["automanaged"],
33+
visibility = ["//visibility:public"],
34+
)

pkg/apis/storage/v1alpha1/doc.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/storage
18+
// +k8s:conversion-gen-external-types=../../../../vendor/k8s.io/api/storage/v1alpha1
19+
// +groupName=storage.k8s.io
20+
// +k8s:defaulter-gen=TypeMeta
21+
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/storage/v1alpha1
22+
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/storage/v1alpha1"

pkg/apis/storage/v1alpha1/register.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
storagev1alpha1 "k8s.io/api/storage/v1alpha1"
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
)
23+
24+
// GroupName is the group name use in this package
25+
const GroupName = "storage.k8s.io"
26+
27+
// SchemeGroupVersion is group version used to register these objects
28+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
29+
30+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
31+
func Resource(resource string) schema.GroupResource {
32+
return SchemeGroupVersion.WithResource(resource).GroupResource()
33+
}
34+
35+
var (
36+
localSchemeBuilder = &storagev1alpha1.SchemeBuilder
37+
AddToScheme = localSchemeBuilder.AddToScheme
38+
)

0 commit comments

Comments
 (0)