blob: 7ec1e908f476ad0d009cc334b90efb975692f101 [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001/*
2Copyright 2016 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 v1beta1
18
19import (
20 "k8s.io/api/core/v1"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22)
23
24// +genclient
25// +genclient:nonNamespaced
26// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27
28// StorageClass describes the parameters for a class of storage for
29// which PersistentVolumes can be dynamically provisioned.
30//
31// StorageClasses are non-namespaced; the name of the storage class
32// according to etcd is in ObjectMeta.Name.
33type StorageClass struct {
34 metav1.TypeMeta `json:",inline"`
35 // Standard object's metadata.
36 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
37 // +optional
38 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
39
40 // Provisioner indicates the type of the provisioner.
41 Provisioner string `json:"provisioner" protobuf:"bytes,2,opt,name=provisioner"`
42
43 // Parameters holds the parameters for the provisioner that should
44 // create volumes of this storage class.
45 // +optional
46 Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"`
47
48 // Dynamically provisioned PersistentVolumes of this storage class are
49 // created with this reclaimPolicy. Defaults to Delete.
50 // +optional
51 ReclaimPolicy *v1.PersistentVolumeReclaimPolicy `json:"reclaimPolicy,omitempty" protobuf:"bytes,4,opt,name=reclaimPolicy,casttype=k8s.io/api/core/v1.PersistentVolumeReclaimPolicy"`
52
53 // Dynamically provisioned PersistentVolumes of this storage class are
54 // created with these mountOptions, e.g. ["ro", "soft"]. Not validated -
55 // mount of the PVs will simply fail if one is invalid.
56 // +optional
57 MountOptions []string `json:"mountOptions,omitempty" protobuf:"bytes,5,opt,name=mountOptions"`
58
59 // AllowVolumeExpansion shows whether the storage class allow volume expand
60 // +optional
61 AllowVolumeExpansion *bool `json:"allowVolumeExpansion,omitempty" protobuf:"varint,6,opt,name=allowVolumeExpansion"`
62
63 // VolumeBindingMode indicates how PersistentVolumeClaims should be
64 // provisioned and bound. When unset, VolumeBindingImmediate is used.
65 // This field is alpha-level and is only honored by servers that enable
66 // the VolumeScheduling feature.
67 // +optional
68 VolumeBindingMode *VolumeBindingMode `json:"volumeBindingMode,omitempty" protobuf:"bytes,7,opt,name=volumeBindingMode"`
69
70 // Restrict the node topologies where volumes can be dynamically provisioned.
71 // Each volume plugin defines its own supported topology specifications.
72 // An empty TopologySelectorTerm list means there is no topology restriction.
73 // This field is alpha-level and is only honored by servers that enable
74 // the DynamicProvisioningScheduling feature.
75 // +optional
76 AllowedTopologies []v1.TopologySelectorTerm `json:"allowedTopologies,omitempty" protobuf:"bytes,8,rep,name=allowedTopologies"`
77}
78
79// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
80
81// StorageClassList is a collection of storage classes.
82type StorageClassList struct {
83 metav1.TypeMeta `json:",inline"`
84 // Standard list metadata
85 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
86 // +optional
87 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
88
89 // Items is the list of StorageClasses
90 Items []StorageClass `json:"items" protobuf:"bytes,2,rep,name=items"`
91}
92
93// VolumeBindingMode indicates how PersistentVolumeClaims should be bound.
94type VolumeBindingMode string
95
96const (
97 // VolumeBindingImmediate indicates that PersistentVolumeClaims should be
98 // immediately provisioned and bound. This is the default mode.
99 VolumeBindingImmediate VolumeBindingMode = "Immediate"
100
101 // VolumeBindingWaitForFirstConsumer indicates that PersistentVolumeClaims
102 // should not be provisioned and bound until the first Pod is created that
103 // references the PeristentVolumeClaim. The volume provisioning and
104 // binding will occur during Pod scheduing.
105 VolumeBindingWaitForFirstConsumer VolumeBindingMode = "WaitForFirstConsumer"
106)
107
108// +genclient
109// +genclient:nonNamespaced
110// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
111
112// VolumeAttachment captures the intent to attach or detach the specified volume
113// to/from the specified node.
114//
115// VolumeAttachment objects are non-namespaced.
116type VolumeAttachment struct {
117 metav1.TypeMeta `json:",inline"`
118
119 // Standard object metadata.
120 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
121 // +optional
122 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
123
124 // Specification of the desired attach/detach volume behavior.
125 // Populated by the Kubernetes system.
126 Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
127
128 // Status of the VolumeAttachment request.
129 // Populated by the entity completing the attach or detach
130 // operation, i.e. the external-attacher.
131 // +optional
132 Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
133}
134
135// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
136
137// VolumeAttachmentList is a collection of VolumeAttachment objects.
138type VolumeAttachmentList struct {
139 metav1.TypeMeta `json:",inline"`
140 // Standard list metadata
141 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
142 // +optional
143 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
144
145 // Items is the list of VolumeAttachments
146 Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"`
147}
148
149// VolumeAttachmentSpec is the specification of a VolumeAttachment request.
150type VolumeAttachmentSpec struct {
151 // Attacher indicates the name of the volume driver that MUST handle this
152 // request. This is the name returned by GetPluginName().
153 Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"`
154
155 // Source represents the volume that should be attached.
156 Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"`
157
158 // The node that the volume should be attached to.
159 NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"`
160}
161
162// VolumeAttachmentSource represents a volume that should be attached.
163// Right now only PersistenVolumes can be attached via external attacher,
164// in future we may allow also inline volumes in pods.
165// Exactly one member can be set.
166type VolumeAttachmentSource struct {
167 // Name of the persistent volume to attach.
168 // +optional
169 PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
170
171 // Placeholder for *VolumeSource to accommodate inline volumes in pods.
172}
173
174// VolumeAttachmentStatus is the status of a VolumeAttachment request.
175type VolumeAttachmentStatus struct {
176 // Indicates the volume is successfully attached.
177 // This field must only be set by the entity completing the attach
178 // operation, i.e. the external-attacher.
179 Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"`
180
181 // Upon successful attach, this field is populated with any
182 // information returned by the attach operation that must be passed
183 // into subsequent WaitForAttach or Mount calls.
184 // This field must only be set by the entity completing the attach
185 // operation, i.e. the external-attacher.
186 // +optional
187 AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"`
188
189 // The last error encountered during attach operation, if any.
190 // This field must only be set by the entity completing the attach
191 // operation, i.e. the external-attacher.
192 // +optional
193 AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"`
194
195 // The last error encountered during detach operation, if any.
196 // This field must only be set by the entity completing the detach
197 // operation, i.e. the external-attacher.
198 // +optional
199 DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"`
200}
201
202// VolumeError captures an error encountered during a volume operation.
203type VolumeError struct {
204 // Time the error was encountered.
205 // +optional
206 Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
207
208 // String detailing the error encountered during Attach or Detach operation.
209 // This string maybe logged, so it should not contain sensitive
210 // information.
211 // +optional
212 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
213}