Add ability to set the MTU size of the docker in docker container (#385)

* adding abilitiy to set docker in docker MTU size

* safeguards to only set MTU env var if it is set
This commit is contained in:
Brandon Kimbrough 2021-03-11 18:44:49 -05:00 committed by GitHub
parent 3d62e73f8c
commit 2273b198a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 0 deletions

View File

@ -92,6 +92,8 @@ type RunnerSpec struct {
DockerdWithinRunnerContainer *bool `json:"dockerdWithinRunnerContainer,omitempty"`
// +optional
DockerEnabled *bool `json:"dockerEnabled,omitempty"`
// +optional
DockerMTU *int64 `json:"dockerMTU,omitempty"`
}
// ValidateRepository validates repository field.

View File

@ -689,6 +689,11 @@ func (in *RunnerSpec) DeepCopyInto(out *RunnerSpec) {
*out = new(bool)
**out = **in
}
if in.DockerMTU != nil {
in, out := &in.DockerMTU, &out.DockerMTU
*out = new(int64)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunnerSpec.

View File

@ -433,6 +433,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -433,6 +433,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -398,6 +398,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -433,6 +433,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -433,6 +433,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -398,6 +398,9 @@ spec:
type: array
dockerEnabled:
type: boolean
dockerMTU:
format: int64
type: integer
dockerdContainerResources:
description: ResourceRequirements describes the compute resource requirements.
properties:

View File

@ -530,6 +530,15 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
},
}
if mtu := runner.Spec.DockerMTU; mtu != nil && dockerdInRunner {
pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, []corev1.EnvVar{
{
Name: "MTU",
Value: fmt.Sprintf("%d", *runner.Spec.DockerMTU),
},
}...)
}
if !dockerdInRunner && dockerEnabled {
runnerVolumeName := "runner"
runnerVolumeMountPath := "/runner"
@ -612,6 +621,15 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
Resources: runner.Spec.DockerdContainerResources,
})
if mtu := runner.Spec.DockerMTU; mtu != nil {
pod.Spec.Containers[1].Env = append(pod.Spec.Containers[1].Env, []corev1.EnvVar{
{
Name: "DOCKERD_ROOTLESS_ROOTLESSKIT_MTU",
Value: fmt.Sprintf("%d", *runner.Spec.DockerMTU),
},
}...)
}
}
if len(runner.Spec.Containers) != 0 {

View File

@ -33,5 +33,9 @@ for process in "${processes[@]}"; do
fi
done
if [ -n "${MTU}" ]; then
ifconfig docker0 mtu ${MTU} up
fi
# Wait processes to be running
entrypoint.sh