From bd900111a8eb9ca4302c95c24d2a45c7311f2f7b Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Wed, 31 Jan 2024 16:21:18 -0800 Subject: [PATCH] Move ContainerRuntimeOptions flags to cmd/kubelet/app/options --- cmd/kubelet/app/options/options.go | 14 +++++++++++++- .../kubeletconfig/{flags.go => types.go} | 17 ----------------- 2 files changed, 13 insertions(+), 18 deletions(-) rename pkg/kubelet/kubeletconfig/{flags.go => types.go} (58%) diff --git a/cmd/kubelet/app/options/options.go b/cmd/kubelet/app/options/options.go index 6d446e1baba..8bc9f5becc4 100644 --- a/cmd/kubelet/app/options/options.go +++ b/cmd/kubelet/app/options/options.go @@ -273,7 +273,7 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) { mainfs.AddFlagSet(fs) }() - f.ContainerRuntimeOptions.AddFlags(fs) + addContainerRuntimeFlags(fs, &f.ContainerRuntimeOptions) f.addOSFlags(fs) fs.StringVar(&f.KubeletConfigFile, "config", f.KubeletConfigFile, "The Kubelet will load its initial configuration from this file. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this flag to use the built-in default configuration values. Command-line flags override configuration from this file.") @@ -317,6 +317,18 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) { fs.MarkDeprecated("experimental-allocatable-ignore-eviction", "will be removed in 1.25 or later.") } +// addContainerRuntimeFlags adds flags to the container runtime, according to ContainerRuntimeOptions. +func addContainerRuntimeFlags(fs *pflag.FlagSet, o *kubeletconfig.ContainerRuntimeOptions) { + // General settings. + fs.StringVar(&o.RuntimeCgroups, "runtime-cgroups", o.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.") + _ = fs.String("pod-infra-container-image", "", "Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.") + _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") + + // Image credential provider settings. + fs.StringVar(&o.ImageCredentialProviderConfigPath, "image-credential-provider-config", o.ImageCredentialProviderConfigPath, "Path to a credential provider plugin config file (JSON/YAML/YML) or a directory of such files (merged in lexicographical order; non-recursive search).") + fs.StringVar(&o.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", o.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.") +} + // AddKubeletConfigFlags adds flags for a specific kubeletconfig.KubeletConfiguration to the specified FlagSet func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfigapi.KubeletConfiguration) { fs := pflag.NewFlagSet("", pflag.ExitOnError) diff --git a/pkg/kubelet/kubeletconfig/flags.go b/pkg/kubelet/kubeletconfig/types.go similarity index 58% rename from pkg/kubelet/kubeletconfig/flags.go rename to pkg/kubelet/kubeletconfig/types.go index 758dcb4c64d..70b3e6054bc 100644 --- a/pkg/kubelet/kubeletconfig/flags.go +++ b/pkg/kubelet/kubeletconfig/types.go @@ -16,10 +16,6 @@ limitations under the License. package kubeletconfig -import ( - "github.com/spf13/pflag" -) - // ContainerRuntimeOptions defines options for the container runtime. type ContainerRuntimeOptions struct { // General Options. @@ -41,16 +37,3 @@ type ContainerRuntimeOptions struct { // +optional ImageCredentialProviderBinDir string } - -// AddFlags adds flags to the container runtime, according to ContainerRuntimeOptions. -func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) { - var tmp string - // General settings. - fs.StringVar(&s.RuntimeCgroups, "runtime-cgroups", s.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.") - fs.StringVar(&tmp, "pod-infra-container-image", "", "Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image.") - _ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.") - - // Image credential provider settings. - fs.StringVar(&s.ImageCredentialProviderConfigPath, "image-credential-provider-config", s.ImageCredentialProviderConfigPath, "Path to a credential provider plugin config file (JSON/YAML/YML) or a directory of such files (merged in lexicographical order; non-recursive search).") - fs.StringVar(&s.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", s.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.") -}