Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions driver/kubernetes/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg
if v != "" {
deploymentOpt.Qemu.Image = v
}
case "buildkit-root-volume-memory":
if v != "" {
deploymentOpt.BuildKitRootVolumeMemory = v
}
case "default-load":
defaultLoad, err = strconv.ParseBool(v)
if err != nil {
Expand Down
23 changes: 23 additions & 0 deletions driver/kubernetes/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type DeploymentOpt struct {
// files mounted at /etc/buildkitd
ConfigFiles map[string][]byte

BuildKitRootVolumeMemory string
Rootless bool
NodeSelector map[string]string
CustomAnnotations map[string]string
Expand All @@ -50,6 +51,8 @@ const (
containerName = "buildkitd"
AnnotationPlatform = "buildx.docker.com/platform"
LabelApp = "app"
rootVolumeName = "buildkit-memory"
rootVolumePath = "/var/lib/buildkit"
)

type ErrReservedAnnotationPlatform struct{}
Expand Down Expand Up @@ -247,6 +250,26 @@ func NewDeployment(opt *DeploymentOpt) (d *appsv1.Deployment, c []*corev1.Config
d.Spec.Template.Spec.Containers[0].Resources.Limits[corev1.ResourceEphemeralStorage] = limEphemeralStorage
}

if opt.BuildKitRootVolumeMemory != "" {
buildKitRootVolumeMemory, err := resource.ParseQuantity(opt.BuildKitRootVolumeMemory)
if err != nil {
return nil, nil, err
}
d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, corev1.Volume{
Name: rootVolumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: "Memory",
SizeLimit: &buildKitRootVolumeMemory,
},
},
})
d.Spec.Template.Spec.Containers[0].VolumeMounts = append(d.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
Name: rootVolumeName,
MountPath: rootVolumePath,
})
}

return
}

Expand Down