blob: 964bb5f7b17c87a4cead45644ac72161c8cdfd9d [file] [log] [blame]
sslobodrd046be82019-01-16 10:02:22 -05001/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1alpha1
18
19import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20
21// +genclient
22// +genclient:nonNamespaced
23// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
24
25// VolumeAttachment captures the intent to attach or detach the specified volume
26// to/from the specified node.
27//
28// VolumeAttachment objects are non-namespaced.
29type VolumeAttachment struct {
30 metav1.TypeMeta `json:",inline"`
31
32 // Standard object metadata.
33 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
34 // +optional
35 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
36
37 // Specification of the desired attach/detach volume behavior.
38 // Populated by the Kubernetes system.
39 Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
40
41 // Status of the VolumeAttachment request.
42 // Populated by the entity completing the attach or detach
43 // operation, i.e. the external-attacher.
44 // +optional
45 Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
46}
47
48// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
49
50// VolumeAttachmentList is a collection of VolumeAttachment objects.
51type VolumeAttachmentList struct {
52 metav1.TypeMeta `json:",inline"`
53 // Standard list metadata
54 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
55 // +optional
56 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
57
58 // Items is the list of VolumeAttachments
59 Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"`
60}
61
62// VolumeAttachmentSpec is the specification of a VolumeAttachment request.
63type VolumeAttachmentSpec struct {
64 // Attacher indicates the name of the volume driver that MUST handle this
65 // request. This is the name returned by GetPluginName().
66 Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"`
67
68 // Source represents the volume that should be attached.
69 Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"`
70
71 // The node that the volume should be attached to.
72 NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"`
73}
74
75// VolumeAttachmentSource represents a volume that should be attached.
76// Right now only PersistenVolumes can be attached via external attacher,
77// in future we may allow also inline volumes in pods.
78// Exactly one member can be set.
79type VolumeAttachmentSource struct {
80 // Name of the persistent volume to attach.
81 // +optional
82 PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
83
84 // Placeholder for *VolumeSource to accommodate inline volumes in pods.
85}
86
87// VolumeAttachmentStatus is the status of a VolumeAttachment request.
88type VolumeAttachmentStatus struct {
89 // Indicates the volume is successfully attached.
90 // This field must only be set by the entity completing the attach
91 // operation, i.e. the external-attacher.
92 Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"`
93
94 // Upon successful attach, this field is populated with any
95 // information returned by the attach operation that must be passed
96 // into subsequent WaitForAttach or Mount calls.
97 // This field must only be set by the entity completing the attach
98 // operation, i.e. the external-attacher.
99 // +optional
100 AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"`
101
102 // The last error encountered during attach operation, if any.
103 // This field must only be set by the entity completing the attach
104 // operation, i.e. the external-attacher.
105 // +optional
106 AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"`
107
108 // The last error encountered during detach operation, if any.
109 // This field must only be set by the entity completing the detach
110 // operation, i.e. the external-attacher.
111 // +optional
112 DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"`
113}
114
115// VolumeError captures an error encountered during a volume operation.
116type VolumeError struct {
117 // Time the error was encountered.
118 // +optional
119 Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
120
121 // String detailing the error encountered during Attach or Detach operation.
122 // This string maybe logged, so it should not contain sensitive
123 // information.
124 // +optional
125 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
126}