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