blob: 76ad6dc0dd8af15d0d8e33edc55a78b8be87f9f8 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
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 (
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// VolumeAttachment captures the intent to attach or detach the specified volume
29// to/from the specified node.
30//
31// VolumeAttachment objects are non-namespaced.
32type VolumeAttachment struct {
33 metav1.TypeMeta `json:",inline"`
34
35 // Standard object 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 // Specification of the desired attach/detach volume behavior.
41 // Populated by the Kubernetes system.
42 Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
43
44 // Status of the VolumeAttachment request.
45 // Populated by the entity completing the attach or detach
46 // operation, i.e. the external-attacher.
47 // +optional
48 Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
49}
50
51// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
52
53// VolumeAttachmentList is a collection of VolumeAttachment objects.
54type VolumeAttachmentList struct {
55 metav1.TypeMeta `json:",inline"`
56 // Standard list metadata
57 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
58 // +optional
59 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
60
61 // Items is the list of VolumeAttachments
62 Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"`
63}
64
65// VolumeAttachmentSpec is the specification of a VolumeAttachment request.
66type VolumeAttachmentSpec struct {
67 // Attacher indicates the name of the volume driver that MUST handle this
68 // request. This is the name returned by GetPluginName().
69 Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"`
70
71 // Source represents the volume that should be attached.
72 Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"`
73
74 // The node that the volume should be attached to.
75 NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"`
76}
77
78// VolumeAttachmentSource represents a volume that should be attached.
79// Right now only PersistenVolumes can be attached via external attacher,
80// in future we may allow also inline volumes in pods.
81// Exactly one member can be set.
82type VolumeAttachmentSource struct {
83 // Name of the persistent volume to attach.
84 // +optional
85 PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
86
87 // inlineVolumeSpec contains all the information necessary to attach
88 // a persistent volume defined by a pod's inline VolumeSource. This field
89 // is populated only for the CSIMigration feature. It contains
90 // translated fields from a pod's inline VolumeSource to a
91 // PersistentVolumeSpec. This field is alpha-level and is only
92 // honored by servers that enabled the CSIMigration feature.
93 // +optional
94 InlineVolumeSpec *v1.PersistentVolumeSpec `json:"inlineVolumeSpec,omitempty" protobuf:"bytes,2,opt,name=inlineVolumeSpec"`
95}
96
97// VolumeAttachmentStatus is the status of a VolumeAttachment request.
98type VolumeAttachmentStatus struct {
99 // Indicates the volume is successfully attached.
100 // This field must only be set by the entity completing the attach
101 // operation, i.e. the external-attacher.
102 Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"`
103
104 // Upon successful attach, this field is populated with any
105 // information returned by the attach operation that must be passed
106 // into subsequent WaitForAttach or Mount calls.
107 // This field must only be set by the entity completing the attach
108 // operation, i.e. the external-attacher.
109 // +optional
110 AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"`
111
112 // The last error encountered during attach operation, if any.
113 // This field must only be set by the entity completing the attach
114 // operation, i.e. the external-attacher.
115 // +optional
116 AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"`
117
118 // The last error encountered during detach operation, if any.
119 // This field must only be set by the entity completing the detach
120 // operation, i.e. the external-attacher.
121 // +optional
122 DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"`
123}
124
125// VolumeError captures an error encountered during a volume operation.
126type VolumeError struct {
127 // Time the error was encountered.
128 // +optional
129 Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"`
130
131 // String detailing the error encountered during Attach or Detach operation.
132 // This string maybe logged, so it should not contain sensitive
133 // information.
134 // +optional
135 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
136}