From de3cf2522465a7a45180f3e196ddb734c3ad68bb Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Wed, 8 Nov 2017 07:05:29 -0800 Subject: [PATCH 1/2] Conditionally mount flexvolume --- cmd/kubeadm/app/phases/controlplane/volumes.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/phases/controlplane/volumes.go b/cmd/kubeadm/app/phases/controlplane/volumes.go index 690cd01a0ef..35edc211187 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes.go @@ -72,7 +72,9 @@ func getHostPathVolumesForTheControlPlane(cfg *kubeadmapi.MasterConfiguration) c mounts.NewHostPathMount(kubeadmconstants.KubeControllerManager, kubeadmconstants.KubeConfigVolumeName, controllerManagerKubeConfigFile, controllerManagerKubeConfigFile, true, &hostPathFileOrCreate) // Mount for the flexvolume directory (/usr/libexec/kubernetes/kubelet-plugins/volume/exec) directory // Flexvolume dir must NOT be readonly as it is used for third-party plugins to integrate with their storage backends via unix domain socket. - mounts.NewHostPathMount(kubeadmconstants.KubeControllerManager, flexvolumeDirVolumeName, flexvolumeDirVolumePath, flexvolumeDirVolumePath, false, &hostPathDirectoryOrCreate) + if stat, err := os.Stat(flexvolumeDirVolumePath); err == nil && stat.IsDir() { + mounts.NewHostPathMount(kubeadmconstants.KubeControllerManager, flexvolumeDirVolumeName, flexvolumeDirVolumePath, flexvolumeDirVolumePath, false, &hostPathDirectoryOrCreate) + } // HostPath volumes for the scheduler // Read-only mount for the scheduler kubeconfig file From 32f16d2cc286d4b093b3df7da0f3e50baaed28ae Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Tue, 14 Nov 2017 14:35:04 -0800 Subject: [PATCH 2/2] Don't test flexvolume-dir creation --- .../app/phases/controlplane/volumes_test.go | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/cmd/kubeadm/app/phases/controlplane/volumes_test.go b/cmd/kubeadm/app/phases/controlplane/volumes_test.go index e0032bdafa0..b2cdacadbaa 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes_test.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes_test.go @@ -306,15 +306,6 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { }, }, } - volMap[kubeadmconstants.KubeControllerManager]["flexvolume-dir"] = v1.Volume{ - Name: "flexvolume-dir", - VolumeSource: v1.VolumeSource{ - HostPath: &v1.HostPathVolumeSource{ - Path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", - Type: &hostPathDirectoryOrCreate, - }, - }, - } volMap[kubeadmconstants.KubeScheduler] = map[string]v1.Volume{} volMap[kubeadmconstants.KubeScheduler]["kubeconfig"] = v1.Volume{ Name: "kubeconfig", @@ -353,11 +344,6 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { MountPath: "/etc/kubernetes/controller-manager.conf", ReadOnly: true, } - volMountMap[kubeadmconstants.KubeControllerManager]["flexvolume-dir"] = v1.VolumeMount{ - Name: "flexvolume-dir", - MountPath: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", - ReadOnly: false, - } volMountMap[kubeadmconstants.KubeScheduler] = map[string]v1.VolumeMount{} volMountMap[kubeadmconstants.KubeScheduler]["kubeconfig"] = v1.VolumeMount{ Name: "kubeconfig", @@ -431,15 +417,6 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { }, }, } - volMap2[kubeadmconstants.KubeControllerManager]["flexvolume-dir"] = v1.Volume{ - Name: "flexvolume-dir", - VolumeSource: v1.VolumeSource{ - HostPath: &v1.HostPathVolumeSource{ - Path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", - Type: &hostPathDirectoryOrCreate, - }, - }, - } volMap2[kubeadmconstants.KubeScheduler] = map[string]v1.Volume{} volMap2[kubeadmconstants.KubeScheduler]["kubeconfig"] = v1.Volume{ Name: "kubeconfig", @@ -488,11 +465,6 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { MountPath: "/etc/kubernetes/controller-manager.conf", ReadOnly: true, } - volMountMap2[kubeadmconstants.KubeControllerManager]["flexvolume-dir"] = v1.VolumeMount{ - Name: "flexvolume-dir", - MountPath: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", - ReadOnly: false, - } volMountMap2[kubeadmconstants.KubeScheduler] = map[string]v1.VolumeMount{} volMountMap2[kubeadmconstants.KubeScheduler]["kubeconfig"] = v1.VolumeMount{ Name: "kubeconfig",