Windows: Fixes termination-file mounting for containerd

If Containerd is used on Windows, then we can also mount individual
files into containers (e.g.: termination-log files), which was not
possible with Docker.

Checks if the container runtime is containerd, and if it is, then also
mount the termination-log file.
This commit is contained in:
Claudiu Belu
2019-09-04 09:16:21 -07:00
parent 3a50184421
commit d4d7f58362
7 changed files with 40 additions and 5 deletions

View File

@@ -471,9 +471,10 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Contai
}
opts.Mounts = append(opts.Mounts, mounts...)
// Disabling adding TerminationMessagePath on Windows as these files would be mounted as docker volume and
// Docker for Windows has a bug where only directories can be mounted
if len(container.TerminationMessagePath) != 0 && runtime.GOOS != "windows" {
// adding TerminationMessagePath on Windows is only allowed if ContainerD is used. Individual files cannot
// be mounted as volumes using Docker for Windows.
supportsSingleFileMapping := kl.containerRuntime.SupportsSingleFileMapping()
if len(container.TerminationMessagePath) != 0 && supportsSingleFileMapping {
p := kl.getPodContainerDir(pod.UID, container.Name)
if err := os.MkdirAll(p, 0750); err != nil {
klog.Errorf("Error on creating %q: %v", p, err)