driver kubernetes: allow to work in a Memory mount to speed up things
Signed-off-by: Samuel Archambault <samuel.archambault@getmaintainx.com>
This commit is contained in:
@@ -286,6 +286,10 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg
|
|||||||
if v != "" {
|
if v != "" {
|
||||||
deploymentOpt.Qemu.Image = v
|
deploymentOpt.Qemu.Image = v
|
||||||
}
|
}
|
||||||
|
case "buildkit-root-volume-memory":
|
||||||
|
if v != "" {
|
||||||
|
deploymentOpt.BuildKitRootVolumeMemory = v
|
||||||
|
}
|
||||||
case "default-load":
|
case "default-load":
|
||||||
defaultLoad, err = strconv.ParseBool(v)
|
defaultLoad, err = strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type DeploymentOpt struct {
|
|||||||
// files mounted at /etc/buildkitd
|
// files mounted at /etc/buildkitd
|
||||||
ConfigFiles map[string][]byte
|
ConfigFiles map[string][]byte
|
||||||
|
|
||||||
|
BuildKitRootVolumeMemory string
|
||||||
Rootless bool
|
Rootless bool
|
||||||
NodeSelector map[string]string
|
NodeSelector map[string]string
|
||||||
CustomAnnotations map[string]string
|
CustomAnnotations map[string]string
|
||||||
@@ -50,6 +51,8 @@ const (
|
|||||||
containerName = "buildkitd"
|
containerName = "buildkitd"
|
||||||
AnnotationPlatform = "buildx.docker.com/platform"
|
AnnotationPlatform = "buildx.docker.com/platform"
|
||||||
LabelApp = "app"
|
LabelApp = "app"
|
||||||
|
rootVolumeName = "buildkit-memory"
|
||||||
|
rootVolumePath = "/var/lib/buildkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrReservedAnnotationPlatform struct{}
|
type ErrReservedAnnotationPlatform struct{}
|
||||||
@@ -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
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user