Skip to content

Commit 4bd651c

Browse files
authored
Introduce VolumeSnapshot API type (#1347)
1 parent 3db1624 commit 4bd651c

Some content is hidden

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

46 files changed

+4735
-193
lines changed

api/storage/v1alpha1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3737
&VolumePoolList{},
3838
&Volume{},
3939
&VolumeList{},
40+
&VolumeSnapshot{},
41+
&VolumeSnapshotList{},
4042
&BucketClass{},
4143
&BucketClassList{},
4244
&BucketPool{},

api/storage/v1alpha1/volume_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type VolumeSpec struct {
3232
// Resources is a description of the volume's resources and capacity.
3333
Resources corev1alpha1.ResourceList `json:"resources,omitempty"`
3434
// Image is an optional image to bootstrap the volume with.
35+
// To be deprecated
3536
Image string `json:"image,omitempty"`
3637
// ImagePullSecretRef is an optional secret for pulling the image of a volume.
3738
ImagePullSecretRef *corev1.LocalObjectReference `json:"imagePullSecretRef,omitempty"`
@@ -42,6 +43,16 @@ type VolumeSpec struct {
4243
Tolerations []commonv1alpha1.Toleration `json:"tolerations,omitempty"`
4344
// Encryption is an optional field which provides attributes to encrypt Volume.
4445
Encryption *VolumeEncryption `json:"encryption,omitempty"`
46+
// VolumeDataSource is the source where the storage for the Volume resides at.
47+
VolumeDataSource `json:",inline"`
48+
}
49+
50+
// VolumeDataSource specifies the source to use for a Volume.
51+
type VolumeDataSource struct {
52+
// VolumeSnapshotRef instructs to use the specified VolumeSnapshot as the data source.
53+
VolumeSnapshotRef *corev1.LocalObjectReference `json:"volumeSnapshotRef,omitempty"`
54+
// OSImage is an optional os image to bootstrap the volume.
55+
OSImage *string `json:"osImage,omitempty"`
4556
}
4657

4758
// VolumeAccess represents information on how to access a volume.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
corev1 "k8s.io/api/core/v1"
8+
"k8s.io/apimachinery/pkg/api/resource"
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
)
11+
12+
// VolumeSnapshotSpec defines the desired state of VolumeSnapshot
13+
type VolumeSnapshotSpec struct {
14+
// VolumeRef indicates which Volume to refer for VolumeSnapshot
15+
VolumeRef *corev1.LocalObjectReference `json:"volumeRef"`
16+
}
17+
18+
// VolumeSnapshotStatus defines the observed state of VolumeSnapshot
19+
type VolumeSnapshotStatus struct {
20+
// SnapshotID is the provider-specific snapshot ID in the format 'TYPE://SNAPSHOT_ID'.
21+
SnapshotID string `json:"snapshotID,omitempty"`
22+
// State represents the storage provider state of VolumeSnapshot
23+
State VolumeSnapshotState `json:"state,omitempty"`
24+
// LastStateTransitionTime is the last time the State transitioned between values.
25+
LastStateTransitionTime *metav1.Time `json:"lastStateTransitionTime,omitempty"`
26+
// Size is the storage size used by VolumeSnapshot
27+
Size *resource.Quantity `json:"size,omitempty"`
28+
}
29+
30+
// VolumeSnapshotState is the state of a VolumeSnapshot
31+
type VolumeSnapshotState string
32+
33+
const (
34+
// VolumeSnapshotStatePending reports whether a VolumeSnapshot is about to be ready.
35+
VolumeSnapshotStatePending VolumeSnapshotState = "Pending"
36+
// VolumeSnapshotStateReady reports whether a VolumeSnapshot is ready to be used.
37+
VolumeSnapshotStateReady VolumeSnapshotState = "Ready"
38+
// VolumeSnapshotStateFailed reports that a VolumeSnapshot is in failed state.
39+
VolumeSnapshotStateFailed VolumeSnapshotState = "Failed"
40+
)
41+
42+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
43+
// +genclient
44+
45+
// VolumeSnapshot is the Schema for the VolumeSnapshots API
46+
type VolumeSnapshot struct {
47+
metav1.TypeMeta `json:",inline"`
48+
metav1.ObjectMeta `json:"metadata,omitempty"`
49+
50+
Spec VolumeSnapshotSpec `json:"spec,omitempty"`
51+
Status VolumeSnapshotStatus `json:"status,omitempty"`
52+
}
53+
54+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
55+
56+
// VolumeSnapshotList contains a list of VolumeSnapshot
57+
type VolumeSnapshotList struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ListMeta `json:"metadata,omitempty"`
60+
Items []VolumeSnapshot `json:"items"`
61+
}

api/storage/v1alpha1/zz_generated.deepcopy.go

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/internal/internal.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/storage/v1alpha1/volumedatasource.go

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)