mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-02 01:39:02 +00:00
Merge pull request #83098 from ddebroy/disable-intree
CSI Migration phase 2: disable probing of in-tree plugins
This commit is contained in:
@@ -86,6 +86,7 @@ go_library(
|
||||
"//pkg/volume/cinder:go_default_library",
|
||||
"//pkg/volume/configmap:go_default_library",
|
||||
"//pkg/volume/csi:go_default_library",
|
||||
"//pkg/volume/csimigration:go_default_library",
|
||||
"//pkg/volume/downwardapi:go_default_library",
|
||||
"//pkg/volume/emptydir:go_default_library",
|
||||
"//pkg/volume/fc:go_default_library",
|
||||
@@ -138,8 +139,10 @@ go_library(
|
||||
"//staging/src/k8s.io/client-go/util/keyutil:go_default_library",
|
||||
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/featuregate:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/version:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/version/verflag:go_default_library",
|
||||
"//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library",
|
||||
"//staging/src/k8s.io/kubelet/config/v1beta1:go_default_library",
|
||||
"//vendor/github.com/coreos/go-systemd/daemon:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
|
@@ -22,6 +22,8 @@ import (
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/aws"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/azure"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/gcp"
|
||||
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/utils/exec"
|
||||
|
||||
// Volume plugins
|
||||
@@ -53,7 +55,7 @@ import (
|
||||
)
|
||||
|
||||
// ProbeVolumePlugins collects all volume plugins into an easy to use list.
|
||||
func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
func ProbeVolumePlugins(featureGate featuregate.FeatureGate) ([]volume.VolumePlugin, error) {
|
||||
allPlugins := []volume.VolumePlugin{}
|
||||
|
||||
// The list of plugins to probe is decided by the kubelet binary, not
|
||||
@@ -62,7 +64,11 @@ func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
//
|
||||
// Kubelet does not currently need to configure volume plugins.
|
||||
// If/when it does, see kube-controller-manager/app/plugins.go for example of using volume.VolumeConfig
|
||||
allPlugins = appendLegacyProviderVolumes(allPlugins)
|
||||
var err error
|
||||
allPlugins, err = appendLegacyProviderVolumes(allPlugins, featureGate)
|
||||
if err != nil {
|
||||
return allPlugins, err
|
||||
}
|
||||
allPlugins = append(allPlugins, emptydir.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, hostpath.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||
@@ -83,7 +89,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
allPlugins = append(allPlugins, local.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, csi.ProbeVolumePlugins()...)
|
||||
return allPlugins
|
||||
return allPlugins, nil
|
||||
}
|
||||
|
||||
// GetDynamicPluginProber gets the probers of dynamically discoverable plugins
|
||||
|
@@ -19,21 +19,61 @@ limitations under the License.
|
||||
package app
|
||||
|
||||
import (
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/csi-translation-lib/plugins"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/awsebs"
|
||||
"k8s.io/kubernetes/pkg/volume/azure_dd"
|
||||
"k8s.io/kubernetes/pkg/volume/azure_file"
|
||||
"k8s.io/kubernetes/pkg/volume/cinder"
|
||||
"k8s.io/kubernetes/pkg/volume/csimigration"
|
||||
"k8s.io/kubernetes/pkg/volume/gcepd"
|
||||
"k8s.io/kubernetes/pkg/volume/vsphere_volume"
|
||||
)
|
||||
|
||||
func appendLegacyProviderVolumes(allPlugins []volume.VolumePlugin) []volume.VolumePlugin {
|
||||
allPlugins = append(allPlugins, awsebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_file.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gcepd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
return allPlugins
|
||||
type probeFn func() []volume.VolumePlugin
|
||||
|
||||
func appendPluginBasedOnMigrationFeatureFlags(plugins []volume.VolumePlugin, inTreePluginName string, featureGate featuregate.FeatureGate, pluginMigration, pluginMigrationComplete featuregate.Feature, fn probeFn) ([]volume.VolumePlugin, error) {
|
||||
// Skip appending the in-tree plugin to the list of plugins to be probed/initialized
|
||||
// if the CSIMigration feature flag and plugin specific feature flag indicating
|
||||
// CSI migration is complete
|
||||
err := csimigration.CheckMigrationFeatureFlags(featureGate, pluginMigration, pluginMigrationComplete)
|
||||
if err != nil {
|
||||
klog.Warningf("Unexpected CSI Migration Feature Flags combination detected: %v. CSI Migration may not take effect", err)
|
||||
// TODO: fail and return here once alpha only tests can set the feature flags for a plugin correctly
|
||||
}
|
||||
if featureGate.Enabled(features.CSIMigration) && featureGate.Enabled(pluginMigration) && featureGate.Enabled(pluginMigrationComplete) {
|
||||
klog.Infof("Skip registration of plugin %s since feature flag %v is enabled", inTreePluginName, pluginMigrationComplete)
|
||||
return plugins, nil
|
||||
}
|
||||
plugins = append(plugins, fn()...)
|
||||
return plugins, nil
|
||||
}
|
||||
|
||||
type pluginInfo struct {
|
||||
pluginMigrationFeature featuregate.Feature
|
||||
pluginMigrationCompleteFeature featuregate.Feature
|
||||
pluginProbeFunction probeFn
|
||||
}
|
||||
|
||||
func appendLegacyProviderVolumes(allPlugins []volume.VolumePlugin, featureGate featuregate.FeatureGate) ([]volume.VolumePlugin, error) {
|
||||
pluginMigrationStatus := make(map[string]pluginInfo)
|
||||
pluginMigrationStatus[plugins.AWSEBSInTreePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationAWS, pluginMigrationCompleteFeature: features.CSIMigrationAWSComplete, pluginProbeFunction: awsebs.ProbeVolumePlugins}
|
||||
pluginMigrationStatus[plugins.GCEPDInTreePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationGCE, pluginMigrationCompleteFeature: features.CSIMigrationGCEComplete, pluginProbeFunction: gcepd.ProbeVolumePlugins}
|
||||
pluginMigrationStatus[plugins.CinderInTreePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationOpenStack, pluginMigrationCompleteFeature: features.CSIMigrationOpenStackComplete, pluginProbeFunction: cinder.ProbeVolumePlugins}
|
||||
pluginMigrationStatus[plugins.AzureDiskInTreePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationAzureDisk, pluginMigrationCompleteFeature: features.CSIMigrationAzureDiskComplete, pluginProbeFunction: azure_dd.ProbeVolumePlugins}
|
||||
pluginMigrationStatus[plugins.AzureFileInTreePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationAzureFile, pluginMigrationCompleteFeature: features.CSIMigrationAzureFileComplete, pluginProbeFunction: azure_file.ProbeVolumePlugins}
|
||||
|
||||
var err error
|
||||
for pluginName, pluginInfo := range pluginMigrationStatus {
|
||||
allPlugins, err = appendPluginBasedOnMigrationFeatureFlags(allPlugins, pluginName, featureGate, pluginInfo.pluginMigrationFeature, pluginInfo.pluginMigrationCompleteFeature, pluginInfo.pluginProbeFunction)
|
||||
if err != nil {
|
||||
return allPlugins, err
|
||||
}
|
||||
}
|
||||
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
return allPlugins, nil
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ import (
|
||||
"k8s.io/client-go/util/keyutil"
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/component-base/version"
|
||||
"k8s.io/component-base/version/verflag"
|
||||
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
|
||||
@@ -247,7 +248,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||
}
|
||||
|
||||
// use kubeletServer to construct the default KubeletDeps
|
||||
kubeletDeps, err := UnsecuredDependencies(kubeletServer)
|
||||
kubeletDeps, err := UnsecuredDependencies(kubeletServer, utilfeature.DefaultFeatureGate)
|
||||
if err != nil {
|
||||
klog.Fatal(err)
|
||||
}
|
||||
@@ -268,7 +269,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||
|
||||
// run the kubelet
|
||||
klog.V(5).Infof("KubeletConfiguration: %#v", kubeletServer.KubeletConfiguration)
|
||||
if err := Run(kubeletServer, kubeletDeps, stopCh); err != nil {
|
||||
if err := Run(kubeletServer, kubeletDeps, utilfeature.DefaultFeatureGate, stopCh); err != nil {
|
||||
klog.Fatal(err)
|
||||
}
|
||||
},
|
||||
@@ -362,7 +363,7 @@ func loadConfigFile(name string) (*kubeletconfiginternal.KubeletConfiguration, e
|
||||
|
||||
// UnsecuredDependencies returns a Dependencies suitable for being run, or an error if the server setup
|
||||
// is not valid. It will not start any background processes, and does not include authentication/authorization
|
||||
func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, error) {
|
||||
func UnsecuredDependencies(s *options.KubeletServer, featureGate featuregate.FeatureGate) (*kubelet.Dependencies, error) {
|
||||
// Initialize the TLS Options
|
||||
tlsOptions, err := InitializeTLS(&s.KubeletFlags, &s.KubeletConfiguration)
|
||||
if err != nil {
|
||||
@@ -383,6 +384,10 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
|
||||
}
|
||||
}
|
||||
|
||||
plugins, err := ProbeVolumePlugins(featureGate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &kubelet.Dependencies{
|
||||
Auth: nil, // default does not enforce auth[nz]
|
||||
CAdvisorInterface: nil, // cadvisor.New launches background processes (bg http.ListenAndServe, and some bg cleaners), not set here
|
||||
@@ -397,7 +402,7 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
|
||||
Subpather: subpather,
|
||||
OOMAdjuster: oom.NewOOMAdjuster(),
|
||||
OSInterface: kubecontainer.RealOS{},
|
||||
VolumePlugins: ProbeVolumePlugins(),
|
||||
VolumePlugins: plugins,
|
||||
DynamicPluginProber: GetDynamicPluginProber(s.VolumePluginDir, pluginRunner),
|
||||
TLSOptions: tlsOptions}, nil
|
||||
}
|
||||
@@ -406,13 +411,13 @@ func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, err
|
||||
// The kubeDeps argument may be nil - if so, it is initialized from the settings on KubeletServer.
|
||||
// Otherwise, the caller is assumed to have set up the Dependencies object and a default one will
|
||||
// not be generated.
|
||||
func Run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan struct{}) error {
|
||||
func Run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, featureGate featuregate.FeatureGate, stopCh <-chan struct{}) error {
|
||||
// To help debugging, immediately log version
|
||||
klog.Infof("Version: %+v", version.Get())
|
||||
if err := initForOS(s.KubeletFlags.WindowsService); err != nil {
|
||||
return fmt.Errorf("failed OS init: %v", err)
|
||||
}
|
||||
if err := run(s, kubeDeps, stopCh); err != nil {
|
||||
if err := run(s, kubeDeps, featureGate, stopCh); err != nil {
|
||||
return fmt.Errorf("failed to run Kubelet: %v", err)
|
||||
}
|
||||
return nil
|
||||
@@ -469,7 +474,7 @@ func makeEventRecorder(kubeDeps *kubelet.Dependencies, nodeName types.NodeName)
|
||||
}
|
||||
}
|
||||
|
||||
func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan struct{}) (err error) {
|
||||
func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, featureGate featuregate.FeatureGate, stopCh <-chan struct{}) (err error) {
|
||||
// Set global feature gates based on the value on the initial KubeletServer
|
||||
err = utilfeature.DefaultMutableFeatureGate.SetFromMap(s.KubeletConfiguration.FeatureGates)
|
||||
if err != nil {
|
||||
@@ -511,7 +516,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan
|
||||
}
|
||||
|
||||
if kubeDeps == nil {
|
||||
kubeDeps, err = UnsecuredDependencies(s)
|
||||
kubeDeps, err = UnsecuredDependencies(s, featureGate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user