Skip to content

Commit 3cc4be3

Browse files
committed
Use reduced version of core/v1 Volume spec
Modern kubernetes use CSI volume provisioners for complex storage. But standard volumes specs still contains obsolete/removed types. This bloats Ysaurus spec because core/v1 Volume is embedded multiple times. Remove deprecated and obscure volume sources: - awsElasticBlockStore - azureDisk - azureFile - cephfs - cinder - flexVolume - flocker - gcePersistentDisk - gitRepo - glusterfs - photonPersistentDisk - portworxVolume - projected - rbd - scaleIO - storageos - vsphereVolume Keep these volume sources: - hostPath - emptyDir - secret - nfs - iscsi - persistentVolumeClaim - downwardAPI - fc - configMap - csi - ephemeral - image In future we could easily add and remove these types. Link: https://kubernetes.io/docs/concepts/storage/volumes/ Signed-off-by: Konstantin Khlebnikov <[email protected]>
1 parent b6dd187 commit 3cc4be3

17 files changed

+412
-33275
lines changed

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ linters:
287287
- gocritic
288288
text: "ifElseChain: rewrite if-else to switch statement"
289289

290+
- path: api/v1/ytsaurus_types.go
291+
text: "json\\(camel\\): got 'downwardAPI' want 'downwardApi'"
292+
290293
- path: 'main\.go'
291294
linters:
292295
- gochecknoglobals

api/v1/ytsaurus_types.go

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,110 @@ type EmbeddedPersistentVolumeClaim struct {
4040
Spec corev1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
4141
}
4242

43+
// Volume is a reduced version of core/v1 Volume.
44+
// Represents a named volume in a pod that may be accessed by any container in the pod.
45+
type Volume struct {
46+
// name of the volume.
47+
// Must be a DNS_LABEL and unique within the pod.
48+
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
49+
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
50+
// volumeSource represents the location and type of the mounted volume.
51+
// If not specified, the Volume is implied to be an EmptyDir.
52+
// This implied behavior is deprecated and will be removed in a future version.
53+
VolumeSource `json:",inline" protobuf:"bytes,2,opt,name=volumeSource"`
54+
}
55+
56+
// VolumeSource is a reduced version of core/v1 VolumeSource.
57+
// Represents the source of a volume to mount.
58+
// Only one of its members may be specified.
59+
type VolumeSource struct {
60+
// hostPath represents a pre-existing file or directory on the host
61+
// machine that is directly exposed to the container. This is generally
62+
// used for system agents or other privileged things that are allowed
63+
// to see the host machine. Most containers will NOT need this.
64+
// More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath
65+
// +optional
66+
HostPath *corev1.HostPathVolumeSource `json:"hostPath,omitempty" protobuf:"bytes,1,opt,name=hostPath"`
67+
// emptyDir represents a temporary directory that shares a pod's lifetime.
68+
// More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir
69+
// +optional
70+
EmptyDir *corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty" protobuf:"bytes,2,opt,name=emptyDir"`
71+
// secret represents a secret that should populate this volume.
72+
// More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
73+
// +optional
74+
Secret *corev1.SecretVolumeSource `json:"secret,omitempty" protobuf:"bytes,6,opt,name=secret"`
75+
// nfs represents an NFS mount on the host that shares a pod's lifetime
76+
// More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs
77+
// +optional
78+
NFS *corev1.NFSVolumeSource `json:"nfs,omitempty" protobuf:"bytes,7,opt,name=nfs"`
79+
// iscsi represents an ISCSI Disk resource that is attached to a
80+
// kubelet's host machine and then exposed to the pod.
81+
// More info: https://examples.k8s.io/volumes/iscsi/README.md
82+
// +optional
83+
ISCSI *corev1.ISCSIVolumeSource `json:"iscsi,omitempty" protobuf:"bytes,8,opt,name=iscsi"`
84+
// persistentVolumeClaimVolumeSource represents a reference to a
85+
// PersistentVolumeClaim in the same namespace.
86+
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
87+
// +optional
88+
PersistentVolumeClaim *corev1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty" protobuf:"bytes,10,opt,name=persistentVolumeClaim"`
89+
// downwardAPI represents downward API about the pod that should populate this volume
90+
// +optional
91+
DownwardAPI *corev1.DownwardAPIVolumeSource `json:"downwardAPI,omitempty" protobuf:"bytes,16,opt,name=downwardAPI"`
92+
// fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod.
93+
// +optional
94+
FC *corev1.FCVolumeSource `json:"fc,omitempty" protobuf:"bytes,17,opt,name=fc"`
95+
// configMap represents a configMap that should populate this volume
96+
// +optional
97+
ConfigMap *corev1.ConfigMapVolumeSource `json:"configMap,omitempty" protobuf:"bytes,19,opt,name=configMap"`
98+
// csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).
99+
// +optional
100+
CSI *corev1.CSIVolumeSource `json:"csi,omitempty" protobuf:"bytes,28,opt,name=csi"`
101+
// ephemeral represents a volume that is handled by a cluster storage driver.
102+
// The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts,
103+
// and deleted when the pod is removed.
104+
//
105+
// Use this if:
106+
// a) the volume is only needed while the pod runs,
107+
// b) features of normal volumes like restoring from snapshot or capacity
108+
// tracking are needed,
109+
// c) the storage driver is specified through a storage class, and
110+
// d) the storage driver supports dynamic volume provisioning through
111+
// a PersistentVolumeClaim (see EphemeralVolumeSource for more
112+
// information on the connection between this volume type
113+
// and PersistentVolumeClaim).
114+
//
115+
// Use PersistentVolumeClaim or one of the vendor-specific
116+
// APIs for volumes that persist for longer than the lifecycle
117+
// of an individual pod.
118+
//
119+
// Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to
120+
// be used that way - see the documentation of the driver for
121+
// more information.
122+
//
123+
// A pod can use both types of ephemeral volumes and
124+
// persistent volumes at the same time.
125+
//
126+
// +optional
127+
Ephemeral *corev1.EphemeralVolumeSource `json:"ephemeral,omitempty" protobuf:"bytes,29,opt,name=ephemeral"`
128+
// image represents an OCI object (a container image or artifact) pulled and mounted on the kubelet's host machine.
129+
// The volume is resolved at pod startup depending on which PullPolicy value is provided:
130+
//
131+
// - Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails.
132+
// - Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn't present.
133+
// - IfNotPresent: the kubelet pulls if the reference isn't already present on disk. Container creation will fail if the reference isn't present and the pull fails.
134+
//
135+
// The volume gets re-resolved if the pod gets deleted and recreated, which means that new remote content will become available on pod recreation.
136+
// A failure to resolve or pull the image during pod startup will block containers from starting and may add significant latency. Failures will be retried using normal volume backoff and will be reported on the pod reason and message.
137+
// The types of objects that may be mounted by this volume are defined by the container runtime implementation on a host machine and at minimum must include all valid types supported by the container image field.
138+
// The OCI object gets mounted in a single directory (spec.containers[*].volumeMounts.mountPath) by merging the manifest layers in the same way as for container images.
139+
// The volume will be mounted read-only (ro) and non-executable files (noexec).
140+
// Sub path mounts for containers are not supported (spec.containers[*].volumeMounts.subpath).
141+
// The field spec.securityContext.fsGroupChangePolicy has no effect on this volume type.
142+
// +featureGate=ImageVolume
143+
// +optional
144+
Image *corev1.ImageVolumeSource `json:"image,omitempty" protobuf:"bytes,30,opt,name=image"`
145+
}
146+
43147
// EmbeddedObjectMetadata contains a subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
44148
// Only fields which are relevant to embedded resources are included.
45149
type EmbeddedObjectMetadata struct {
@@ -267,7 +371,7 @@ type InstanceSpec struct {
267371
// Specifies wrapper for component container command.
268372
//+optional
269373
EntrypointWrapper []string `json:"entrypointWrapper,omitempty"`
270-
Volumes []corev1.Volume `json:"volumes,omitempty"`
374+
Volumes []Volume `json:"volumes,omitempty"`
271375
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
272376
//+optional
273377
ReadinessProbeParams *HealthcheckProbeParams `json:"readinessProbeParams,omitempty"`

api/v1/zz_generated.deepcopy.go

Lines changed: 92 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)