Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new VolumeAttachment API Object #54463

Merged
merged 2 commits into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
889 changes: 889 additions & 0 deletions api/openapi-spec/swagger.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions api/swagger-spec/resourceListing.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,272 changes: 1,272 additions & 0 deletions api/swagger-spec/storage.k8s.io_v1alpha1.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cmd/kube-apiserver/app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
"//pkg/apis/core:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/networking:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/capabilities:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/informers/informers_generated/internalversion:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions cmd/kube-apiserver/app/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
{Group: "settings.k8s.io", Version: "v1alpha1"}: {group: 16900, version: 9},
{Group: "storage.k8s.io", Version: "v1"}: {group: 16800, version: 15},
{Group: "storage.k8s.io", Version: "v1beta1"}: {group: 16800, version: 9},
{Group: "storage.k8s.io", Version: "v1alpha1"}: {group: 16800, version: 1},
{Group: "apiextensions.k8s.io", Version: "v1beta1"}: {group: 16700, version: 9},
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {group: 16700, version: 9},
{Group: "scheduling.k8s.io", Version: "v1alpha1"}: {group: 16600, version: 9},
Expand Down
6 changes: 5 additions & 1 deletion cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import (
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/networking"
"k8s.io/kubernetes/pkg/apis/storage"
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
Expand Down Expand Up @@ -556,7 +557,10 @@ func BuildStorageFactory(s *options.ServerRunOptions) (*serverstorage.DefaultSto
s.Etcd.StorageConfig, s.Etcd.DefaultStorageMediaType, legacyscheme.Codecs,
serverstorage.NewDefaultResourceEncodingConfig(legacyscheme.Registry), storageGroupsToEncodingVersion,
// FIXME (soltysh): this GroupVersionResource override should be configurable
[]schema.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v1beta1")},
[]schema.GroupVersionResource{
batch.Resource("cronjobs").WithVersion("v1beta1"),
storage.Resource("volumeattachments").WithVersion("v1alpha1"),
},
master.DefaultAPIResourceConfigSource(), s.APIEnablement.RuntimeConfig)
if err != nil {
return nil, fmt.Errorf("error in initializing storage factory: %s", err)
Expand Down
1,549 changes: 1,549 additions & 0 deletions docs/api-reference/storage.k8s.io/v1alpha1/definitions.html

Large diffs are not rendered by default.

1,792 changes: 1,792 additions & 0 deletions docs/api-reference/storage.k8s.io/v1alpha1/operations.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pkg/apis/storage
pkg/apis/storage/util
pkg/apis/storage/v1
pkg/apis/storage/v1/util
pkg/apis/storage/v1alpha1
pkg/apis/storage/v1beta1
pkg/apis/storage/v1beta1/util
pkg/auth/authorizer/abac
Expand Down Expand Up @@ -458,6 +459,7 @@ staging/src/k8s.io/api/rbac/v1beta1
staging/src/k8s.io/api/scheduling/v1alpha1
staging/src/k8s.io/api/settings/v1alpha1
staging/src/k8s.io/api/storage/v1
staging/src/k8s.io/api/storage/v1alpha1
staging/src/k8s.io/api/storage/v1beta1
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1
Expand Down Expand Up @@ -666,6 +668,8 @@ staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1
staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/fake
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/fake
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1
staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/fake
staging/src/k8s.io/client-go/plugin/pkg/auth/authenticator/token/oidc/testing
Expand Down
1 change: 1 addition & 0 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ rbac.authorization.k8s.io/v1beta1 \
rbac.authorization.k8s.io/v1alpha1 \
scheduling.k8s.io/v1alpha1 \
settings.k8s.io/v1alpha1 \
storage.k8s.io/v1alpha1 \
storage.k8s.io/v1beta1 \
storage.k8s.io/v1 \
}"
Expand Down
1 change: 1 addition & 0 deletions hack/update-generated-protobuf-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ PACKAGES=(
k8s.io/api/imagepolicy/v1alpha1
k8s.io/api/scheduling/v1alpha1
k8s.io/api/settings/v1alpha1
k8s.io/api/storage/v1alpha1
k8s.io/api/storage/v1beta1
k8s.io/api/storage/v1
k8s.io/api/admissionregistration/v1alpha1
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/storage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ filegroup(
"//pkg/apis/storage/install:all-srcs",
"//pkg/apis/storage/util:all-srcs",
"//pkg/apis/storage/v1:all-srcs",
"//pkg/apis/storage/v1alpha1:all-srcs",
"//pkg/apis/storage/v1beta1:all-srcs",
"//pkg/apis/storage/validation:all-srcs",
],
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/storage/install/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/storage:go_default_library",
"//pkg/apis/storage/v1:go_default_library",
"//pkg/apis/storage/v1alpha1:go_default_library",
"//pkg/apis/storage/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
Expand Down
15 changes: 10 additions & 5 deletions pkg/apis/storage/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/storage"
"k8s.io/kubernetes/pkg/apis/storage/v1"
"k8s.io/kubernetes/pkg/apis/storage/v1alpha1"
"k8s.io/kubernetes/pkg/apis/storage/v1beta1"
)

Expand All @@ -37,14 +38,18 @@ func init() {
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: storage.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
RootScopedKinds: sets.NewString("StorageClass"),
GroupName: storage.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version, v1alpha1.SchemeGroupVersion.Version},
RootScopedKinds: sets.NewString(
"StorageClass",
"VolumeAttachment",
),
AddInternalObjectsToScheme: storage.AddToScheme,
},
announced.VersionToSchemeFunc{
v1.SchemeGroupVersion.Version: v1.AddToScheme,
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
v1.SchemeGroupVersion.Version: v1.AddToScheme,
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/storage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&StorageClass{},
&StorageClassList{},
&VolumeAttachment{},
&VolumeAttachmentList{},
)
return nil
}
107 changes: 107 additions & 0 deletions pkg/apis/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,110 @@ type StorageClassList struct {
// Items is the list of StorageClasses
Items []StorageClass
}

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// 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

// Standard object metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta

// Specification of the desired attach/detach volume behavior.
// Populated by the Kubernetes system.
Spec VolumeAttachmentSpec

// Status of the VolumeAttachment request.
// Populated by the entity completing the attach or detach
// operation, i.e. the external-attacher.
// +optional
Status VolumeAttachmentStatus
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// VolumeAttachmentList is a collection of VolumeAttachment objects.
type VolumeAttachmentList struct {
metav1.TypeMeta
// Standard list metadata
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ListMeta

// Items is the list of VolumeAttachments
Items []VolumeAttachment
}

// 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

// Source represents the volume that should be attached.
Source VolumeAttachmentSource

// The node that the volume should be attached to.
NodeName string
}

// 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

// Placeholder for *VolumeSource to accommodate inline volumes in pods.
}

// 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

// 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

// 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

// 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
}

// Captures an error encountered during a volume operation.
type VolumeError struct {
// Time the error was encountered.
// +optional
Time metav1.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
}
34 changes: 34 additions & 0 deletions pkg/apis/storage/v1alpha1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"zz_generated.conversion.go",
"zz_generated.defaults.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/storage/v1alpha1",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/storage:go_default_library",
"//vendor/k8s.io/api/storage/v1alpha1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
22 changes: 22 additions & 0 deletions pkg/apis/storage/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/storage
// +k8s:conversion-gen-external-types=../../../../vendor/k8s.io/api/storage/v1alpha1
// +groupName=storage.k8s.io
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/storage/v1alpha1
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/storage/v1alpha1"
38 changes: 38 additions & 0 deletions pkg/apis/storage/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
storagev1alpha1 "k8s.io/api/storage/v1alpha1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName is the group name use in this package
const GroupName = "storage.k8s.io"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
localSchemeBuilder = &storagev1alpha1.SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)