diff --git a/cmd/kubeadm/app/phases/controlplane/volumes.go b/cmd/kubeadm/app/phases/controlplane/volumes.go index d83df4961d6..a9c69d01b91 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes.go @@ -30,9 +30,11 @@ import ( ) const ( - caCertsVolumeName = "ca-certs" - caCertsVolumePath = "/etc/ssl/certs" - caCertsPkiVolumeName = "ca-certs-etc-pki" + caCertsVolumeName = "ca-certs" + caCertsVolumePath = "/etc/ssl/certs" + caCertsPkiVolumeName = "ca-certs-etc-pki" + flexvolumeDirVolumeName = "flexvolume-dir" + flexvolumeDirVolumePath = "/usr/libexec/kubernetes/kubelet-plugins/volume/exec" ) // caCertsPkiVolumePath specifies the path that can be conditionally mounted into the apiserver and controller-manager containers @@ -68,6 +70,9 @@ func getHostPathVolumesForTheControlPlane(cfg *kubeadmapi.MasterConfiguration) c // Read-only mount for the controller manager kubeconfig file controllerManagerKubeConfigFile := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ControllerManagerKubeConfigFileName) 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) // HostPath volumes for the scheduler // Read-only mount for the scheduler kubeconfig file diff --git a/cmd/kubeadm/app/phases/controlplane/volumes_test.go b/cmd/kubeadm/app/phases/controlplane/volumes_test.go index ebe74eed569..af784c0e64b 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes_test.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes_test.go @@ -309,6 +309,15 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { }, }, }, + { + Name: "flexvolume-dir", + VolumeSource: v1.VolumeSource{ + HostPath: &v1.HostPathVolumeSource{ + Path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", + Type: &hostPathDirectoryOrCreate, + }, + }, + }, }, kubeadmconstants.KubeScheduler: { { @@ -351,6 +360,11 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { MountPath: "/etc/kubernetes/controller-manager.conf", ReadOnly: true, }, + { + Name: "flexvolume-dir", + MountPath: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", + ReadOnly: false, + }, }, kubeadmconstants.KubeScheduler: { { @@ -439,6 +453,15 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { }, }, }, + { + Name: "flexvolume-dir", + VolumeSource: v1.VolumeSource{ + HostPath: &v1.HostPathVolumeSource{ + Path: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", + Type: &hostPathDirectoryOrCreate, + }, + }, + }, }, kubeadmconstants.KubeScheduler: { { @@ -491,6 +514,11 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { MountPath: "/etc/kubernetes/controller-manager.conf", ReadOnly: true, }, + { + Name: "flexvolume-dir", + MountPath: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec", + ReadOnly: false, + }, }, kubeadmconstants.KubeScheduler: { {