@@ -32,6 +32,7 @@ type DeploymentOpt struct {
32
32
// files mounted at /etc/buildkitd
33
33
ConfigFiles map [string ][]byte
34
34
35
+ BuildKitRootFolderMemory string
35
36
Rootless bool
36
37
NodeSelector map [string ]string
37
38
CustomAnnotations map [string ]string
@@ -50,6 +51,7 @@ const (
50
51
containerName = "buildkitd"
51
52
AnnotationPlatform = "buildx.docker.com/platform"
52
53
LabelApp = "app"
54
+ memoryVolumeName = "buildkit-memory"
53
55
)
54
56
55
57
type ErrReservedAnnotationPlatform struct {}
@@ -247,6 +249,26 @@ func NewDeployment(opt *DeploymentOpt) (d *appsv1.Deployment, c []*corev1.Config
247
249
d .Spec .Template .Spec .Containers [0 ].Resources .Limits [corev1 .ResourceEphemeralStorage ] = limEphemeralStorage
248
250
}
249
251
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
+
250
272
return
251
273
}
252
274
0 commit comments