Skip to content

Commit

Permalink
A custom slimmed down version of VolumeSource
Browse files Browse the repository at this point in the history
Slim down VolumeSource by removing deprecated and "removed"
fields from the struct. This will slim down our nested
use of ExtraMounts
  • Loading branch information
dprince committed Oct 14, 2024
1 parent e5c35d2 commit adc4267
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 56 deletions.
80 changes: 79 additions & 1 deletion modules/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,84 @@ const (
Compute PropagationType = "Compute"
)

// VolumeSource our slimmed down version of the VolumeSource struct with deprecated and "removed" fields removed to save space
type VolumeSource struct {
HostPath *corev1.HostPathVolumeSource `json:"hostPath,omitempty" protobuf:"bytes,1,opt,name=hostPath"`
// emptyDir represents a temporary directory that shares a pod's lifetime.
// More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir
// +optional
EmptyDir *corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty" protobuf:"bytes,2,opt,name=emptyDir"`
// secret represents a secret that should populate this volume.
// More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
// +optional
Secret *corev1.SecretVolumeSource `json:"secret,omitempty" protobuf:"bytes,6,opt,name=secret"`
// nfs represents an NFS mount on the host that shares a pod's lifetime
// More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
// +optional
NFS *corev1.NFSVolumeSource `json:"nfs,omitempty" protobuf:"bytes,7,opt,name=nfs"`
// iscsi represents an ISCSI Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
// More info: https://examples.k8s.io/volumes/iscsi/README.md
// +optional
ISCSI *corev1.ISCSIVolumeSource `json:"iscsi,omitempty" protobuf:"bytes,8,opt,name=iscsi"`
// persistentVolumeClaimVolumeSource represents a reference to a
// PersistentVolumeClaim in the same namespace.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
PersistentVolumeClaim *corev1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaim"`
// cephFS represents a Ceph FS mount on the host that shares a pod's lifetime
// +optional
CephFS *corev1.CephFSVolumeSource `json:"cephfs,omitempty" protobuf:"bytes,14,opt,name=cephfs"`
// flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running
// +optional
Flocker *corev1.FlockerVolumeSource `json:"flocker,omitempty" protobuf:"bytes,15,opt,name=flocker"`
// downwardAPI represents downward API about the pod that should populate this volume
// +optional
DownwardAPI *corev1.DownwardAPIVolumeSource `json:"downwardAPI,omitempty" protobuf:"bytes,16,opt,name=downwardAPI"`
// fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.
// +optional
FC *corev1.FCVolumeSource `json:"fc,omitempty" protobuf:"bytes,17,opt,name=fc"`
// configMap represents a configMap that should populate this volume
// +optional
ConfigMap *corev1.ConfigMapVolumeSource `json:"configMap,omitempty" protobuf:"bytes,19,opt,name=configMap"`
// quobyte represents a Quobyte mount on the host that shares a pod's lifetime
// +optional
Quobyte *corev1.QuobyteVolumeSource `json:"quobyte,omitempty" protobuf:"bytes,21,opt,name=quobyte"`
// photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine
PhotonPersistentDisk *corev1.PhotonPersistentDiskVolumeSource `json:"photonPersistentDisk,omitempty" protobuf:"bytes,23,opt,name=photonPersistentDisk"`
// projected items for all in one resources secrets, configmaps, and downward API
Projected *corev1.ProjectedVolumeSource `json:"projected,omitempty" protobuf:"bytes,26,opt,name=projected"`
// scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes.
// +optional
ScaleIO *corev1.ScaleIOVolumeSource `json:"scaleIO,omitempty" protobuf:"bytes,25,opt,name=scaleIO"`
// storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes.
// +optional
StorageOS *corev1.StorageOSVolumeSource `json:"storageos,omitempty" protobuf:"bytes,27,opt,name=storageos"`
// csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).
// +optional
CSI *corev1.CSIVolumeSource `json:"csi,omitempty" protobuf:"bytes,28,opt,name=csi"`
// ephemeral represents a volume that is handled by a cluster storage driver.
// The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts,
// and deleted when the pod is removed.
//
// +optional
Ephemeral *corev1.EphemeralVolumeSource `json:"ephemeral,omitempty" protobuf:"bytes,29,opt,name=ephemeral"`
// image represents an OCI object (a container image or artifact) pulled and mounted on the kubelet's host machine.
// The volume is resolved at pod startup depending on which PullPolicy value is provided:
//
//Image *corev1.ImageVolumeSource `json:"image,omitempty" protobuf:"bytes,30,opt,name=image"`
}

// Volume our slimmed down version of Volume
type Volume struct {
// +kubebuilder:validation:Required
// Name of the volume
Name string `json:"name"`
// +kubebuilder:validation:Required
// VolumeSource defines the source of a volume to be mounted
VolumeSource VolumeSource `json:"volumeSource"`
}

// VolMounts is the data structure used to expose Volumes and Mounts that can
// be added to a pod according to the defined Propagation policy
type VolMounts struct {
Expand All @@ -50,7 +128,7 @@ type VolMounts struct {
// +kubebuilder:validation:Optional
ExtraVolType ExtraVolType `json:"extraVolType,omitempty"`
// +kubebuilder:validation:Required
Volumes []corev1.Volume `json:"volumes"`
Volumes []Volume `json:"volumes"`
// +kubebuilder:validation:Required
Mounts []corev1.VolumeMount `json:"mounts"`
}
Expand Down
55 changes: 0 additions & 55 deletions modules/storage/zz_generated.deepcopy.go

This file was deleted.

0 comments on commit adc4267

Please sign in to comment.