Kubernetes: support "sizeLimit" option for emptyDir volumes
Description
Kubernetes executor already supports creating emptyDir volumes backed by memory using a node's tmpfs.
For this type of volume, Kubernetes itself now supports the sizeLimit
parameter by default, but the gitlab-runner Kubernetes executor does not.
We would like to use this option to create small emptyDir volumes for CI pipelines that test backup scenarios involving full volumes. As long as we are unable to specify size limits for these volumes, each of them uses 50% of a node's memory and we run the risk of going OOM on nodes running multiple such CI jobs.
Background:
By default, these emptyDir tmpfs volumes are sized to 50% of the node's available memory. Kubernetes also supports sizing these volumes, via the 'sizeLimit' parameter. This option is tied to a feature gate, which used to be disabled by default. However starting with Kubernetes 1.22, this feature gate is now enabled by default. Most cloud providers no longer support versions older than 1.22, so most k8s users already have this feature gate enabled.
Proposal
When specifying an emptyDir in kubernetes executor config, also allow a 'sizeLimit' option. If the backing k8s cluster supports the corresponding feature flag, the volume should be sized according to the config value. If the feature flag is not supported, the resulting volume should use the default k8s size of 50% of a node's memory.