@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
16+ // +kubebuilder:object:generate:=true
1617
1718package storage
1819
@@ -40,6 +41,74 @@ const (
4041 Compute PropagationType = "Compute"
4142)
4243
44+ // VolumeSource our slimmed down version of the VolumeSource struct with deprecated and "removed" fields removed to save space
45+ type VolumeSource struct {
46+ HostPath * corev1.HostPathVolumeSource `json:"hostPath,omitempty" protobuf:"bytes,1,opt,name=hostPath"`
47+ // emptyDir represents a temporary directory that shares a pod's lifetime.
48+ // More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir
49+ // +optional
50+ EmptyDir * corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty" protobuf:"bytes,2,opt,name=emptyDir"`
51+ // secret represents a secret that should populate this volume.
52+ // More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
53+ // +optional
54+ Secret * corev1.SecretVolumeSource `json:"secret,omitempty" protobuf:"bytes,6,opt,name=secret"`
55+ // nfs represents an NFS mount on the host that shares a pod's lifetime
56+ // More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
57+ // +optional
58+ NFS * corev1.NFSVolumeSource `json:"nfs,omitempty" protobuf:"bytes,7,opt,name=nfs"`
59+ // iscsi represents an ISCSI Disk resource that is attached to a
60+ // kubelet's host machine and then exposed to the pod.
61+ // More info: https://examples.k8s.io/volumes/iscsi/README.md
62+ // +optional
63+ ISCSI * corev1.ISCSIVolumeSource `json:"iscsi,omitempty" protobuf:"bytes,8,opt,name=iscsi"`
64+ // persistentVolumeClaimVolumeSource represents a reference to a
65+ // PersistentVolumeClaim in the same namespace.
66+ // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
67+ // +optional
68+ PersistentVolumeClaim * corev1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaim"`
69+ // cephFS represents a Ceph FS mount on the host that shares a pod's lifetime
70+ // +optional
71+ CephFS * corev1.CephFSVolumeSource `json:"cephfs,omitempty" protobuf:"bytes,14,opt,name=cephfs"`
72+ // downwardAPI represents downward API about the pod that should populate this volume
73+ // +optional
74+ DownwardAPI * corev1.DownwardAPIVolumeSource `json:"downwardAPI,omitempty" protobuf:"bytes,16,opt,name=downwardAPI"`
75+ // fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.
76+ // +optional
77+ FC * corev1.FCVolumeSource `json:"fc,omitempty" protobuf:"bytes,17,opt,name=fc"`
78+ // configMap represents a configMap that should populate this volume
79+ // +optional
80+ ConfigMap * corev1.ConfigMapVolumeSource `json:"configMap,omitempty" protobuf:"bytes,19,opt,name=configMap"`
81+ // photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
82+ PhotonPersistentDisk * corev1.PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty" protobuf:"bytes,23,opt,name=photonPersistentDisk"`
83+ // projected items for all in one resources secrets, configmaps, and downward API
84+ Projected * corev1.ProjectedVolumeSource `json:"projected,omitempty" protobuf:"bytes,26,opt,name=projected"`
85+ // scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.
86+ // +optional
87+ ScaleIO * corev1.ScaleIOVolumeSource `json:"scaleIO,omitempty" protobuf:"bytes,25,opt,name=scaleIO"`
88+ // storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.
89+ // +optional
90+ StorageOS * corev1.StorageOSVolumeSource `json:"storageos,omitempty" protobuf:"bytes,27,opt,name=storageos"`
91+ // csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).
92+ // +optional
93+ CSI * corev1.CSIVolumeSource `json:"csi,omitempty" protobuf:"bytes,28,opt,name=csi"`
94+ // ephemeral represents a volume that is handled by a cluster storage driver.
95+ // The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts,
96+ // and deleted when the pod is removed.
97+ //
98+ // +optional
99+ Ephemeral * corev1.EphemeralVolumeSource `json:"ephemeral,omitempty" protobuf:"bytes,29,opt,name=ephemeral"`
100+ }
101+
102+ // Volume our slimmed down version of Volume
103+ type Volume struct {
104+ // +kubebuilder:validation:Required
105+ // Name of the volume
106+ Name string `json:"name"`
107+ // +kubebuilder:validation:Required
108+ // VolumeSource defines the source of a volume to be mounted
109+ VolumeSource VolumeSource `json:"volumeSource"`
110+ }
111+
43112// VolMounts is the data structure used to expose Volumes and Mounts that can
44113// be added to a pod according to the defined Propagation policy
45114type VolMounts struct {
@@ -50,7 +119,7 @@ type VolMounts struct {
50119 // +kubebuilder:validation:Optional
51120 ExtraVolType ExtraVolType `json:"extraVolType,omitempty"`
52121 // +kubebuilder:validation:Required
53- Volumes []corev1. Volume `json:"volumes"`
122+ Volumes []Volume `json:"volumes"`
54123 // +kubebuilder:validation:Required
55124 Mounts []corev1.VolumeMount `json:"mounts"`
56125}
@@ -82,3 +151,25 @@ func (v *VolMounts) Propagate(svc []PropagationType) []VolMounts {
82151
83152 return vl
84153}
154+
155+ // ConvertVolumeSource function to convert from a VolumeSource to a corev1.VolumeSource
156+ func ConvertVolumeSource (v * VolumeSource ) corev1.VolumeSource {
157+ return corev1.VolumeSource {
158+ HostPath : v .HostPath ,
159+ EmptyDir : v .EmptyDir ,
160+ Secret : v .Secret ,
161+ NFS : v .NFS ,
162+ ISCSI : v .ISCSI ,
163+ PersistentVolumeClaim : v .PersistentVolumeClaim ,
164+ CephFS : v .CephFS ,
165+ DownwardAPI : v .DownwardAPI ,
166+ FC : v .FC ,
167+ ConfigMap : v .ConfigMap ,
168+ PhotonPersistentDisk : v .PhotonPersistentDisk ,
169+ Projected : v .Projected ,
170+ ScaleIO : v .ScaleIO ,
171+ StorageOS : v .StorageOS ,
172+ CSI : v .CSI ,
173+ Ephemeral : v .Ephemeral ,
174+ }
175+ }
0 commit comments