Skip to content

Commit cc19fd3

Browse files
authored
Merge pull request #6 from xing-yang/snapshot_apis
Add Snapshot APIs
2 parents 36b1de0 + 3832c9d commit cc19fd3

File tree

17,732 files changed

+5086806
-0
lines changed

Some content is hidden

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

17,732 files changed

+5086806
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright 2018 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:deepcopy-gen=package
18+
19+
package v1alpha1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package v1alpha1
15+
16+
import (
17+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18+
"k8s.io/apimachinery/pkg/runtime"
19+
"k8s.io/apimachinery/pkg/runtime/schema"
20+
)
21+
22+
// GroupName is the group name use in this package.
23+
const GroupName = "snapshot.storage.k8s.io"
24+
25+
var (
26+
// SchemeBuilder is the new scheme builder
27+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
28+
// AddToScheme adds to scheme
29+
AddToScheme = SchemeBuilder.AddToScheme
30+
// SchemeGroupVersion is the group version used to register these objects.
31+
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
32+
)
33+
34+
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
35+
func Resource(resource string) schema.GroupResource {
36+
return SchemeGroupVersion.WithResource(resource).GroupResource()
37+
}
38+
39+
func init() {
40+
// We only register manually written functions here. The registration of the
41+
// generated functions takes place in the generated files. The separation
42+
// makes the code compile even when the generated files are missing.
43+
SchemeBuilder.Register(addKnownTypes)
44+
}
45+
46+
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
47+
func addKnownTypes(scheme *runtime.Scheme) error {
48+
scheme.AddKnownTypes(SchemeGroupVersion,
49+
&VolumeSnapshotClass{},
50+
&VolumeSnapshotClassList{},
51+
&VolumeSnapshot{},
52+
&VolumeSnapshotList{},
53+
&VolumeSnapshotContent{},
54+
&VolumeSnapshotContentList{},
55+
)
56+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
57+
return nil
58+
}
+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/*
2+
Copyright 2018 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+
core_v1 "k8s.io/api/core/v1"
21+
storage "k8s.io/api/storage/v1beta1"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
const (
26+
// VolumeSnapshotContentResourcePlural is "volumesnapshotcontents"
27+
VolumeSnapshotContentResourcePlural = "volumesnapshotcontents"
28+
// VolumeSnapshotResourcePlural is "volumesnapshots"
29+
VolumeSnapshotResourcePlural = "volumesnapshots"
30+
// VolumeSnapshotClassResourcePlural is "volumesnapshotclasses"
31+
VolumeSnapshotClassResourcePlural = "volumesnapshotclasses"
32+
)
33+
34+
// +genclient
35+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
36+
37+
// VolumeSnapshot is a user's request for taking a snapshot. Upon successful creation of the actual
38+
// snapshot by the volume provider it is bound to the corresponding VolumeSnapshotContent.
39+
// Only the VolumeSnapshot object is accessible to the user in the namespace.
40+
type VolumeSnapshot struct {
41+
metav1.TypeMeta `json:",inline"`
42+
// Standard object's metadata.
43+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
44+
// +optional
45+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
46+
47+
// Spec defines the desired characteristics of a snapshot requested by a user.
48+
Spec VolumeSnapshotSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
49+
50+
// Status represents the latest observed state of the snapshot
51+
// +optional
52+
Status VolumeSnapshotStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
53+
}
54+
55+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
56+
57+
// VolumeSnapshotList is a list of VolumeSnapshot objects
58+
type VolumeSnapshotList struct {
59+
metav1.TypeMeta `json:",inline"`
60+
// +optional
61+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
62+
63+
// Items is the list of VolumeSnapshots
64+
Items []VolumeSnapshot `json:"items" protobuf:"bytes,2,rep,name=items"`
65+
}
66+
67+
// VolumeSnapshotSpec describes the common attributes of a volume snapshot
68+
type VolumeSnapshotSpec struct {
69+
// Source has the information about where the snapshot is created from.
70+
// In Alpha version, only PersistentVolumeClaim is supported as the source.
71+
// If not specified, user can create VolumeSnapshotContent and bind it with VolumeSnapshot manually.
72+
// +optional
73+
Source *TypedLocalObjectReference `json:"source" protobuf:"bytes,1,opt,name=source"`
74+
75+
// SnapshotContentName binds the VolumeSnapshot object with the VolumeSnapshotContent
76+
// +optional
77+
SnapshotContentName string `json:"snapshotContentName" protobuf:"bytes,2,opt,name=snapshotContentName"`
78+
79+
// Name of the VolumeSnapshotClass used by the VolumeSnapshot. If not specified, a default snapshot class will
80+
// be used if it is available.
81+
// +optional
82+
VolumeSnapshotClassName string `json:"snapshotClassName" protobuf:"bytes,3,opt,name=snapshotClassName"`
83+
}
84+
85+
// VolumeSnapshotStatus is the status of the VolumeSnapshot
86+
type VolumeSnapshotStatus struct {
87+
// CreationTime is the time the snapshot was successfully created. If it is set,
88+
// it means the snapshot was created; Otherwise the snapshot was not created.
89+
// +optional
90+
CreationTime *metav1.Time `json:"createdAt" protobuf:"bytes,1,opt,name=createdAt"`
91+
92+
// Ready is set to true only if the snapshot is ready to use (e.g., finish uploading if
93+
// there is an uploading phase) and also VolumeSnapshot and its VolumeSnapshotContent
94+
// bind correctly with each other. If any of the above condition is not true, Ready is
95+
// set to false
96+
// +optional
97+
Ready bool `json:"ready" protobuf:"varint,2,opt,name=ready"`
98+
99+
// The last error encountered during create snapshot operation, if any.
100+
// This field must only be set by the entity completing the create snapshot
101+
// operation, i.e. the external-snapshotter.
102+
// +optional
103+
Error *storage.VolumeError
104+
}
105+
106+
// TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.
107+
// TODO: After TypedLocalObjectReference is merged into the in-tree core API, this will be replaced.
108+
type TypedLocalObjectReference struct {
109+
// Name of the referent.
110+
// +optional
111+
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
112+
// Kind of the referent.
113+
// +optional
114+
Kind string `json:"kind,omitempty" protobuf:"bytes,2,opt,name=kind"`
115+
}
116+
117+
// +genclient
118+
// +genclient:nonNamespaced
119+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
120+
121+
// VolumeSnapshotClass describes the parameters used by storage system when
122+
// provisioning VolumeSnapshots from PVCs.
123+
// The name of a VolumeSnapshotClass object is significant, and is how users can request a particular class.
124+
type VolumeSnapshotClass struct {
125+
metav1.TypeMeta `json:",inline"`
126+
// Standard object's metadata.
127+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
128+
// +optional
129+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
130+
131+
// Snapshotter is the driver expected to handle this VolumeSnapshotClass.
132+
Snapshotter string `json:"snapshotter" protobuf:"bytes,2,opt,name=snapshotter"`
133+
134+
// Parameters holds parameters for the snapshotter.
135+
// These values are opaque to the system and are passed directly
136+
// to the snapshotter.
137+
// +optional
138+
Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"`
139+
}
140+
141+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
142+
143+
// VolumeSnapshotClassList is a collection of snapshot classes.
144+
type VolumeSnapshotClassList struct {
145+
metav1.TypeMeta `json:",inline"`
146+
// Standard list metadata
147+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
148+
// +optional
149+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
150+
151+
// Items is the list of VolumeSnapshotClasses
152+
Items []VolumeSnapshotClass `json:"items" protobuf:"bytes,2,rep,name=items"`
153+
}
154+
155+
// +genclient
156+
// +genclient:nonNamespaced
157+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
158+
159+
// VolumeSnapshotContent represents the actual "on-disk" snapshot object
160+
type VolumeSnapshotContent struct {
161+
metav1.TypeMeta `json:",inline"`
162+
// Standard object's metadata.
163+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
164+
// +optional
165+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
166+
167+
// Spec represents the desired state of the snapshot data
168+
Spec VolumeSnapshotContentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
169+
}
170+
171+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
172+
173+
// VolumeSnapshotContentList is a list of VolumeSnapshotContent objects
174+
type VolumeSnapshotContentList struct {
175+
metav1.TypeMeta `json:",inline"`
176+
// +optional
177+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
178+
179+
// Items is the list of VolumeSnapshotContents
180+
Items []VolumeSnapshotContent `json:"items" protobuf:"bytes,2,rep,name=items"`
181+
}
182+
183+
// VolumeSnapshotContentSpec is the spec of the volume snapshot data
184+
type VolumeSnapshotContentSpec struct {
185+
// Source represents the location and type of the volume snapshot
186+
VolumeSnapshotSource `json:",inline" protobuf:"bytes,1,opt,name=volumeSnapshotSource"`
187+
188+
// VolumeSnapshotRef is part of bi-directional binding between VolumeSnapshot
189+
// and VolumeSnapshotContent. It becomes non-nil when bound.
190+
// +optional
191+
VolumeSnapshotRef *core_v1.ObjectReference `json:"volumeSnapshotRef" protobuf:"bytes,2,opt,name=volumeSnapshotRef"`
192+
193+
// PersistentVolumeRef represents the PersistentVolume that the snapshot has been
194+
// taken from. It becomes non-nil when VolumeSnapshot and VolumeSnapshotContent are bound.
195+
// +optional
196+
PersistentVolumeRef *core_v1.ObjectReference `json:"persistentVolumeRef" protobuf:"bytes,3,opt,name=persistentVolumeRef"`
197+
}
198+
199+
// VolumeSnapshotSource represents the actual location and type of the snapshot. Only one of its members may be specified.
200+
type VolumeSnapshotSource struct {
201+
// CSI (Container Storage Interface) represents storage that handled by an external CSI Volume Driver (Alpha feature).
202+
// +optional
203+
CSI *CSIVolumeSnapshotSource `json:"csiVolumeSnapshotSource,omitempty"`
204+
}
205+
206+
// Represents the source from CSI volume snapshot
207+
type CSIVolumeSnapshotSource struct {
208+
// Driver is the name of the driver to use for this snapshot.
209+
// Required.
210+
Driver string `json:"driver"`
211+
212+
// SnapshotHandle is the unique snapshot id returned by the CSI volume
213+
// plugin’s CreateSnapshot to refer to the snapshot on all subsequent calls.
214+
// Required.
215+
SnapshotHandle string `json:"snapshotHandle"`
216+
217+
// Timestamp when the point-in-time snapshot is taken on the storage
218+
// system. This timestamp will be generated by the CSI volume driver after
219+
// the snapshot is cut. The format of this field should be a Unix nanoseconds
220+
// time encoded as an int64. On Unix, the command `date +%s%N` returns
221+
// the current time in nanoseconds since 1970-01-01 00:00:00 UTC.
222+
// This field is REQUIRED.
223+
CreatedAt int64 `json:"createdAt,omitempty" protobuf:"varint,3,opt,name=createdAt"`
224+
}

0 commit comments

Comments
 (0)