@@ -32,6 +32,7 @@ type DeploymentOpt struct {
3232 // files mounted at /etc/buildkitd
3333 ConfigFiles map [string ][]byte
3434
35+ BuildKitRootFolderMemory string
3536 Rootless bool
3637 NodeSelector map [string ]string
3738 CustomAnnotations map [string ]string
@@ -50,6 +51,7 @@ const (
5051 containerName = "buildkitd"
5152 AnnotationPlatform = "buildx.docker.com/platform"
5253 LabelApp = "app"
54+ memoryVolumeName = "buildkit-memory"
5355)
5456
5557type ErrReservedAnnotationPlatform struct {}
@@ -247,6 +249,26 @@ func NewDeployment(opt *DeploymentOpt) (d *appsv1.Deployment, c []*corev1.Config
247249 d .Spec .Template .Spec .Containers [0 ].Resources .Limits [corev1 .ResourceEphemeralStorage ] = limEphemeralStorage
248250 }
249251
252+ if opt .BuildKitRootFolderMemory != "" {
253+ buildKitRootFolderMemory , err := resource .ParseQuantity (opt .BuildKitRootFolderMemory )
254+ if err != nil {
255+ return nil , nil , err
256+ }
257+ d .Spec .Template .Spec .Volumes = append (d .Spec .Template .Spec .Volumes , corev1.Volume {
258+ Name : "buildkit-memory" ,
259+ VolumeSource : corev1.VolumeSource {
260+ EmptyDir : & corev1.EmptyDirVolumeSource {
261+ Medium : "Memory" ,
262+ SizeLimit : & buildKitRootFolderMemory ,
263+ },
264+ },
265+ })
266+ d .Spec .Template .Spec .Containers [0 ].VolumeMounts = append (d .Spec .Template .Spec .Containers [0 ].VolumeMounts , corev1.VolumeMount {
267+ Name : "buildkit-memory" ,
268+ MountPath : "/var/lib/buildkit" ,
269+ })
270+ }
271+
250272 return
251273}
252274
0 commit comments