Skip to content

Commit bae11e5

Browse files
committed
Move ContainerRuntimeOptions flags to cmd/kubelet/app/options
1 parent 75bae3f commit bae11e5

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

cmd/kubelet/app/options/options.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
278278
mainfs.AddFlagSet(fs)
279279
}()
280280

281-
f.ContainerRuntimeOptions.AddFlags(fs)
281+
addContainerRuntimeFlags(fs, &f.ContainerRuntimeOptions)
282282
f.addOSFlags(fs)
283283

284284
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.")
@@ -326,6 +326,18 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
326326
fs.MarkDeprecated("experimental-allocatable-ignore-eviction", "will be removed in 1.25 or later.")
327327
}
328328

329+
// addContainerRuntimeFlags adds flags to the container runtime, according to ContainerRuntimeOptions.
330+
func addContainerRuntimeFlags(fs *pflag.FlagSet, o *kubeletconfig.ContainerRuntimeOptions) {
331+
// General settings.
332+
fs.StringVar(&o.RuntimeCgroups, "runtime-cgroups", o.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.")
333+
fs.StringVar(&o.PodSandboxImage, "pod-infra-container-image", o.PodSandboxImage, fmt.Sprintf("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image."))
334+
_ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.")
335+
336+
// Image credential provider settings.
337+
fs.StringVar(&o.ImageCredentialProviderConfigFile, "image-credential-provider-config", o.ImageCredentialProviderConfigFile, "The path to the credential provider plugin config file.")
338+
fs.StringVar(&o.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", o.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.")
339+
}
340+
329341
// AddKubeletConfigFlags adds flags for a specific kubeletconfig.KubeletConfiguration to the specified FlagSet
330342
func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfigapi.KubeletConfiguration) {
331343
fs := pflag.NewFlagSet("", pflag.ExitOnError)

pkg/kubelet/kubeletconfig/flags.go renamed to pkg/kubelet/kubeletconfig/types.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ limitations under the License.
1616

1717
package kubeletconfig
1818

19-
import (
20-
"fmt"
21-
22-
"github.com/spf13/pflag"
23-
)
24-
2519
// ContainerRuntimeOptions defines options for the container runtime.
2620
type ContainerRuntimeOptions struct {
2721
// General Options.
@@ -45,15 +39,3 @@ type ContainerRuntimeOptions struct {
4539
// +optional
4640
ImageCredentialProviderBinDir string
4741
}
48-
49-
// AddFlags adds flags to the container runtime, according to ContainerRuntimeOptions.
50-
func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) {
51-
// General settings.
52-
fs.StringVar(&s.RuntimeCgroups, "runtime-cgroups", s.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.")
53-
fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprintf("Specified image will not be pruned by the image garbage collector. CRI implementations have their own configuration to set this image."))
54-
_ = fs.MarkDeprecated("pod-infra-container-image", "will be removed in 1.35. Image garbage collector will get sandbox image information from CRI.")
55-
56-
// Image credential provider settings.
57-
fs.StringVar(&s.ImageCredentialProviderConfigFile, "image-credential-provider-config", s.ImageCredentialProviderConfigFile, "The path to the credential provider plugin config file.")
58-
fs.StringVar(&s.ImageCredentialProviderBinDir, "image-credential-provider-bin-dir", s.ImageCredentialProviderBinDir, "The path to the directory where credential provider plugin binaries are located.")
59-
}

0 commit comments

Comments
 (0)