k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kubelet/app/plugins.go (about)

     1  /*
     2  Copyright 2014 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package app
    18  
    19  // This file exists to force the desired plugin implementations to be linked.
    20  import (
    21  	"k8s.io/component-base/featuregate"
    22  	"k8s.io/utils/exec"
    23  
    24  	// Volume plugins
    25  	"k8s.io/kubernetes/pkg/volume"
    26  	"k8s.io/kubernetes/pkg/volume/configmap"
    27  	"k8s.io/kubernetes/pkg/volume/csi"
    28  	"k8s.io/kubernetes/pkg/volume/downwardapi"
    29  	"k8s.io/kubernetes/pkg/volume/emptydir"
    30  	"k8s.io/kubernetes/pkg/volume/fc"
    31  	"k8s.io/kubernetes/pkg/volume/flexvolume"
    32  	"k8s.io/kubernetes/pkg/volume/git_repo"
    33  	"k8s.io/kubernetes/pkg/volume/hostpath"
    34  	"k8s.io/kubernetes/pkg/volume/iscsi"
    35  	"k8s.io/kubernetes/pkg/volume/local"
    36  	"k8s.io/kubernetes/pkg/volume/nfs"
    37  	"k8s.io/kubernetes/pkg/volume/projected"
    38  	"k8s.io/kubernetes/pkg/volume/secret"
    39  )
    40  
    41  // ProbeVolumePlugins collects all volume plugins into an easy to use list.
    42  func ProbeVolumePlugins(featureGate featuregate.FeatureGate) ([]volume.VolumePlugin, error) {
    43  	allPlugins := []volume.VolumePlugin{}
    44  
    45  	// The list of plugins to probe is decided by the kubelet binary, not
    46  	// by dynamic linking or other "magic".  Plugins will be analyzed and
    47  	// initialized later.
    48  	//
    49  	// Kubelet does not currently need to configure volume plugins.
    50  	// If/when it does, see kube-controller-manager/app/plugins.go for example of using volume.VolumeConfig
    51  	var err error
    52  	allPlugins, err = appendLegacyProviderVolumes(allPlugins, featureGate)
    53  	if err != nil {
    54  		return allPlugins, err
    55  	}
    56  	allPlugins = append(allPlugins, emptydir.ProbeVolumePlugins()...)
    57  	allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
    58  	allPlugins = append(allPlugins, hostpath.ProbeVolumePlugins(volume.VolumeConfig{})...)
    59  	allPlugins = append(allPlugins, nfs.ProbeVolumePlugins(volume.VolumeConfig{})...)
    60  	allPlugins = append(allPlugins, secret.ProbeVolumePlugins()...)
    61  	allPlugins = append(allPlugins, iscsi.ProbeVolumePlugins()...)
    62  	allPlugins = append(allPlugins, downwardapi.ProbeVolumePlugins()...)
    63  	allPlugins = append(allPlugins, fc.ProbeVolumePlugins()...)
    64  	allPlugins = append(allPlugins, configmap.ProbeVolumePlugins()...)
    65  	allPlugins = append(allPlugins, projected.ProbeVolumePlugins()...)
    66  	allPlugins = append(allPlugins, local.ProbeVolumePlugins()...)
    67  	allPlugins = append(allPlugins, csi.ProbeVolumePlugins()...)
    68  	return allPlugins, nil
    69  }
    70  
    71  // GetDynamicPluginProber gets the probers of dynamically discoverable plugins
    72  // for kubelet.
    73  // Currently only Flexvolume plugins are dynamically discoverable.
    74  func GetDynamicPluginProber(pluginDir string, runner exec.Interface) volume.DynamicPluginProber {
    75  	return flexvolume.GetDynamicPluginProber(pluginDir, runner)
    76  }