@@ -32,6 +32,7 @@ type DeploymentOpt struct {
3232 // files mounted at /etc/buildkitd
3333 ConfigFiles map [string ][]byte
3434
35+ BuildKitRootVolumeMemory string
3536 Rootless bool
3637 NodeSelector map [string ]string
3738 CustomAnnotations map [string ]string
@@ -50,6 +51,8 @@ const (
5051 containerName = "buildkitd"
5152 AnnotationPlatform = "buildx.docker.com/platform"
5253 LabelApp = "app"
54+ rootVolumeName = "buildkit-memory"
55+ rootVolumePath = "/var/lib/buildkit"
5356)
5457
5558type ErrReservedAnnotationPlatform struct {}
@@ -247,6 +250,26 @@ func NewDeployment(opt *DeploymentOpt) (d *appsv1.Deployment, c []*corev1.Config
247250 d .Spec .Template .Spec .Containers [0 ].Resources .Limits [corev1 .ResourceEphemeralStorage ] = limEphemeralStorage
248251 }
249252
253+ if opt .BuildKitRootVolumeMemory != "" {
254+ buildKitRootVolumeMemory , err := resource .ParseQuantity (opt .BuildKitRootVolumeMemory )
255+ if err != nil {
256+ return nil , nil , err
257+ }
258+ d .Spec .Template .Spec .Volumes = append (d .Spec .Template .Spec .Volumes , corev1.Volume {
259+ Name : rootVolumeName ,
260+ VolumeSource : corev1.VolumeSource {
261+ EmptyDir : & corev1.EmptyDirVolumeSource {
262+ Medium : "Memory" ,
263+ SizeLimit : & buildKitRootVolumeMemory ,
264+ },
265+ },
266+ })
267+ d .Spec .Template .Spec .Containers [0 ].VolumeMounts = append (d .Spec .Template .Spec .Containers [0 ].VolumeMounts , corev1.VolumeMount {
268+ Name : rootVolumeName ,
269+ MountPath : rootVolumePath ,
270+ })
271+ }
272+
250273 return
251274}
252275
0 commit comments