mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Migrate container runtime endpoint flag to config
Signed-off-by: Aditi Sharma <adi.sky17@gmail.com> Signed-off-by: Paco Xu <paco.xu@daocloud.io>
This commit is contained in:
parent
0e19bbb916
commit
214a0ee7b8
@ -98,10 +98,6 @@ type KubeletFlags struct {
|
|||||||
// Source: https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities
|
// Source: https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities
|
||||||
WindowsPriorityClass string
|
WindowsPriorityClass string
|
||||||
|
|
||||||
// remoteRuntimeEndpoint is the endpoint of remote runtime service
|
|
||||||
RemoteRuntimeEndpoint string
|
|
||||||
// remoteImageEndpoint is the endpoint of remote image service
|
|
||||||
RemoteImageEndpoint string
|
|
||||||
// experimentalMounterPath is the path of mounter binary. Leave empty to use the default mount path
|
// experimentalMounterPath is the path of mounter binary. Leave empty to use the default mount path
|
||||||
ExperimentalMounterPath string
|
ExperimentalMounterPath string
|
||||||
// This flag, if set, will avoid including `EvictionHard` limits while computing Node Allocatable.
|
// This flag, if set, will avoid including `EvictionHard` limits while computing Node Allocatable.
|
||||||
@ -323,9 +319,6 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
|
|||||||
|
|
||||||
fs.StringVar(&f.RootDirectory, "root-dir", f.RootDirectory, "Directory path for managing kubelet files (volume mounts,etc).")
|
fs.StringVar(&f.RootDirectory, "root-dir", f.RootDirectory, "Directory path for managing kubelet files (volume mounts,etc).")
|
||||||
|
|
||||||
fs.StringVar(&f.RemoteRuntimeEndpoint, "container-runtime-endpoint", f.RemoteRuntimeEndpoint, "The endpoint of remote runtime service. Unix Domain Sockets are supported on Linux, while npipe and tcp endpoints are supported on Windows. Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime'")
|
|
||||||
fs.StringVar(&f.RemoteImageEndpoint, "image-service-endpoint", f.RemoteImageEndpoint, "The endpoint of remote image service. If not specified, it will be the same with --container-runtime-endpoint by default. Unix Domain Socket are supported on Linux, while npipe and tcp endpoints are supported on Windows. Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime'")
|
|
||||||
|
|
||||||
// EXPERIMENTAL FLAGS
|
// EXPERIMENTAL FLAGS
|
||||||
bindableNodeLabels := cliflag.ConfigurationMap(f.NodeLabels)
|
bindableNodeLabels := cliflag.ConfigurationMap(f.NodeLabels)
|
||||||
fs.Var(&bindableNodeLabels, "node-labels", fmt.Sprintf("<Warning: Alpha feature> Labels to add when registering the node in the cluster. Labels must be key=value pairs separated by ','. Labels in the 'kubernetes.io' namespace must begin with an allowed prefix (%s) or be in the specifically allowed set (%s)", strings.Join(kubeletapis.KubeletLabelNamespaces(), ", "), strings.Join(kubeletapis.KubeletLabels(), ", ")))
|
fs.Var(&bindableNodeLabels, "node-labels", fmt.Sprintf("<Warning: Alpha feature> Labels to add when registering the node in the cluster. Labels must be key=value pairs separated by ','. Labels in the 'kubernetes.io' namespace must begin with an allowed prefix (%s) or be in the specifically allowed set (%s)", strings.Join(kubeletapis.KubeletLabelNamespaces(), ", "), strings.Join(kubeletapis.KubeletLabels(), ", ")))
|
||||||
@ -399,6 +392,10 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
|
|||||||
fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
|
fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
|
||||||
fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")
|
fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")
|
||||||
|
|
||||||
|
// runtime flags
|
||||||
|
fs.StringVar(&c.ContainerRuntimeEndpoint, "container-runtime-endpoint", c.ContainerRuntimeEndpoint, "The endpoint of container runtime service. Unix Domain Sockets are supported on Linux, while npipe and tcp endpoints are supported on Windows. Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime'")
|
||||||
|
fs.StringVar(&c.ImageServiceEndpoint, "image-service-endpoint", c.ImageServiceEndpoint, "The endpoint of container image service. If not specified, it will be the same with --container-runtime-endpoint by default. Unix Domain Socket are supported on Linux, while npipe and tcp endpoints are supported on Windows. Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime'")
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
fs.BoolVar(&c.Authentication.Anonymous.Enabled, "anonymous-auth", c.Authentication.Anonymous.Enabled, ""+
|
fs.BoolVar(&c.Authentication.Anonymous.Enabled, "anonymous-auth", c.Authentication.Anonymous.Enabled, ""+
|
||||||
"Enables anonymous requests to the Kubelet server. Requests that are not rejected by another "+
|
"Enables anonymous requests to the Kubelet server. Requests that are not rejected by another "+
|
||||||
|
@ -644,8 +644,8 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
|
|||||||
}
|
}
|
||||||
|
|
||||||
if kubeDeps.CAdvisorInterface == nil {
|
if kubeDeps.CAdvisorInterface == nil {
|
||||||
imageFsInfoProvider := cadvisor.NewImageFsInfoProvider(s.RemoteRuntimeEndpoint)
|
imageFsInfoProvider := cadvisor.NewImageFsInfoProvider(s.ContainerRuntimeEndpoint)
|
||||||
kubeDeps.CAdvisorInterface, err = cadvisor.New(imageFsInfoProvider, s.RootDirectory, cgroupRoots, cadvisor.UsingLegacyCadvisorStats(s.RemoteRuntimeEndpoint), s.LocalStorageCapacityIsolation)
|
kubeDeps.CAdvisorInterface, err = cadvisor.New(imageFsInfoProvider, s.RootDirectory, cgroupRoots, cadvisor.UsingLegacyCadvisorStats(s.ContainerRuntimeEndpoint), s.LocalStorageCapacityIsolation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -775,7 +775,7 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
|
|||||||
klog.InfoS("Failed to ApplyOOMScoreAdj", "err", err)
|
klog.InfoS("Failed to ApplyOOMScoreAdj", "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kubelet.PreInitRuntimeService(&s.KubeletConfiguration, kubeDeps, s.RemoteRuntimeEndpoint, s.RemoteImageEndpoint)
|
err = kubelet.PreInitRuntimeService(&s.KubeletConfiguration, kubeDeps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ func run(cmd *cobra.Command, config *hollowNodeConfig) error {
|
|||||||
|
|
||||||
var imageService internalapi.ImageManagerService = fakeRemoteRuntime.ImageService
|
var imageService internalapi.ImageManagerService = fakeRemoteRuntime.ImageService
|
||||||
if config.UseHostImageService {
|
if config.UseHostImageService {
|
||||||
imageService, err = remote.NewRemoteImageService(f.RemoteImageEndpoint, 15*time.Second, oteltrace.NewNoopTracerProvider())
|
imageService, err = remote.NewRemoteImageService(c.ContainerRuntimeEndpoint, 15*time.Second, oteltrace.NewNoopTracerProvider())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to init image service, error: %w", err)
|
return fmt.Errorf("Failed to init image service, error: %w", err)
|
||||||
}
|
}
|
||||||
|
16
pkg/generated/openapi/zz_generated.openapi.go
generated
16
pkg/generated/openapi/zz_generated.openapi.go
generated
@ -58629,7 +58629,23 @@ func schema_k8sio_kubelet_config_v1beta1_KubeletConfiguration(ref common.Referen
|
|||||||
Format: "",
|
Format: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"containerRuntimeEndpoint": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "ContainerRuntimeEndpoint is the endpoint of container runtime. unix domain sockets supported on Linux while npipes and tcp endpoints are supported for windows. Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime",
|
||||||
|
Default: "",
|
||||||
|
Type: []string{"string"},
|
||||||
|
Format: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"imageServiceEndpoint": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "ImageServiceEndpoint is the endpoint of container image service. If not specified the default value is ContainerRuntimeEndpoint",
|
||||||
|
Type: []string{"string"},
|
||||||
|
Format: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
Required: []string{"containerRuntimeEndpoint"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Dependencies: []string{
|
Dependencies: []string{
|
||||||
|
@ -107,6 +107,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
|||||||
obj.ConfigMapAndSecretChangeDetectionStrategy = "Watch"
|
obj.ConfigMapAndSecretChangeDetectionStrategy = "Watch"
|
||||||
obj.AllowedUnsafeSysctls = []string{}
|
obj.AllowedUnsafeSysctls = []string{}
|
||||||
obj.VolumePluginDir = kubeletconfigv1beta1.DefaultVolumePluginDir
|
obj.VolumePluginDir = kubeletconfigv1beta1.DefaultVolumePluginDir
|
||||||
|
obj.ContainerRuntimeEndpoint = "containerd.sock"
|
||||||
|
|
||||||
if obj.Logging.Format == "" {
|
if obj.Logging.Format == "" {
|
||||||
obj.Logging.Format = "text"
|
obj.Logging.Format = "text"
|
||||||
}
|
}
|
||||||
|
@ -281,6 +281,8 @@ var (
|
|||||||
"ShutdownGracePeriod.Duration",
|
"ShutdownGracePeriod.Duration",
|
||||||
"ShutdownGracePeriodCriticalPods.Duration",
|
"ShutdownGracePeriodCriticalPods.Duration",
|
||||||
"MemoryThrottlingFactor",
|
"MemoryThrottlingFactor",
|
||||||
|
"ContainerRuntimeEndpoint",
|
||||||
|
"ImageServiceEndpoint",
|
||||||
"Tracing.Endpoint",
|
"Tracing.Endpoint",
|
||||||
"Tracing.SamplingRatePerMillion",
|
"Tracing.SamplingRatePerMillion",
|
||||||
"LocalStorageCapacityIsolation",
|
"LocalStorageCapacityIsolation",
|
||||||
|
@ -17,6 +17,7 @@ cgroupsPerQOS: true
|
|||||||
configMapAndSecretChangeDetectionStrategy: Watch
|
configMapAndSecretChangeDetectionStrategy: Watch
|
||||||
containerLogMaxFiles: 5
|
containerLogMaxFiles: 5
|
||||||
containerLogMaxSize: 10Mi
|
containerLogMaxSize: 10Mi
|
||||||
|
containerRuntimeEndpoint: ""
|
||||||
contentType: application/vnd.kubernetes.protobuf
|
contentType: application/vnd.kubernetes.protobuf
|
||||||
cpuCFSQuota: true
|
cpuCFSQuota: true
|
||||||
cpuCFSQuotaPeriod: 100ms
|
cpuCFSQuotaPeriod: 100ms
|
||||||
|
@ -17,6 +17,7 @@ cgroupsPerQOS: true
|
|||||||
configMapAndSecretChangeDetectionStrategy: Watch
|
configMapAndSecretChangeDetectionStrategy: Watch
|
||||||
containerLogMaxFiles: 5
|
containerLogMaxFiles: 5
|
||||||
containerLogMaxSize: 10Mi
|
containerLogMaxSize: 10Mi
|
||||||
|
containerRuntimeEndpoint: ""
|
||||||
contentType: application/vnd.kubernetes.protobuf
|
contentType: application/vnd.kubernetes.protobuf
|
||||||
cpuCFSQuota: true
|
cpuCFSQuota: true
|
||||||
cpuCFSQuotaPeriod: 100ms
|
cpuCFSQuotaPeriod: 100ms
|
||||||
@ -42,6 +43,7 @@ httpCheckFrequency: 20s
|
|||||||
imageGCHighThresholdPercent: 85
|
imageGCHighThresholdPercent: 85
|
||||||
imageGCLowThresholdPercent: 80
|
imageGCLowThresholdPercent: 80
|
||||||
imageMinimumGCAge: 2m0s
|
imageMinimumGCAge: 2m0s
|
||||||
|
imageServiceEndpoint: containerd.sock
|
||||||
iptablesDropBit: 15
|
iptablesDropBit: 15
|
||||||
iptablesMasqueradeBit: 14
|
iptablesMasqueradeBit: 14
|
||||||
kind: KubeletConfiguration
|
kind: KubeletConfiguration
|
||||||
|
@ -450,6 +450,7 @@ type KubeletConfiguration struct {
|
|||||||
// registerNode enables automatic registration with the apiserver.
|
// registerNode enables automatic registration with the apiserver.
|
||||||
// +optional
|
// +optional
|
||||||
RegisterNode bool
|
RegisterNode bool
|
||||||
|
|
||||||
// Tracing specifies the versioned configuration for OpenTelemetry tracing clients.
|
// Tracing specifies the versioned configuration for OpenTelemetry tracing clients.
|
||||||
// See https://kep.k8s.io/2832 for more details.
|
// See https://kep.k8s.io/2832 for more details.
|
||||||
// +featureGate=KubeletTracing
|
// +featureGate=KubeletTracing
|
||||||
@ -465,6 +466,16 @@ type KubeletConfiguration struct {
|
|||||||
// disabled. Once disabled, user should not set request/limit for container's ephemeral storage, or sizeLimit for emptyDir.
|
// disabled. Once disabled, user should not set request/limit for container's ephemeral storage, or sizeLimit for emptyDir.
|
||||||
// +optional
|
// +optional
|
||||||
LocalStorageCapacityIsolation bool
|
LocalStorageCapacityIsolation bool
|
||||||
|
|
||||||
|
// ContainerRuntimeEndpoint is the endpoint of container runtime.
|
||||||
|
// unix domain sockets supported on Linux while npipes and tcp endpoints are supported for windows.
|
||||||
|
// Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime
|
||||||
|
ContainerRuntimeEndpoint string
|
||||||
|
|
||||||
|
// ImageServiceEndpoint is the endpoint of container image service.
|
||||||
|
// If not specified the default value is ContainerRuntimeEndpoint
|
||||||
|
// +optional
|
||||||
|
ImageServiceEndpoint string
|
||||||
}
|
}
|
||||||
|
|
||||||
// KubeletAuthorizationMode denotes the authorization mode for the kubelet
|
// KubeletAuthorizationMode denotes the authorization mode for the kubelet
|
||||||
|
@ -264,4 +264,7 @@ func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfigura
|
|||||||
if obj.LocalStorageCapacityIsolation == nil {
|
if obj.LocalStorageCapacityIsolation == nil {
|
||||||
obj.LocalStorageCapacityIsolation = utilpointer.BoolPtr(true)
|
obj.LocalStorageCapacityIsolation = utilpointer.BoolPtr(true)
|
||||||
}
|
}
|
||||||
|
if obj.ImageServiceEndpoint == "" && obj.ContainerRuntimeEndpoint != "" {
|
||||||
|
obj.ImageServiceEndpoint = obj.ContainerRuntimeEndpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,6 +512,8 @@ func autoConvert_v1beta1_KubeletConfiguration_To_config_KubeletConfiguration(in
|
|||||||
if err := v1.Convert_Pointer_bool_To_bool(&in.LocalStorageCapacityIsolation, &out.LocalStorageCapacityIsolation, s); err != nil {
|
if err := v1.Convert_Pointer_bool_To_bool(&in.LocalStorageCapacityIsolation, &out.LocalStorageCapacityIsolation, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.ContainerRuntimeEndpoint = in.ContainerRuntimeEndpoint
|
||||||
|
out.ImageServiceEndpoint = in.ImageServiceEndpoint
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,6 +693,8 @@ func autoConvert_config_KubeletConfiguration_To_v1beta1_KubeletConfiguration(in
|
|||||||
if err := v1.Convert_bool_To_Pointer_bool(&in.LocalStorageCapacityIsolation, &out.LocalStorageCapacityIsolation, s); err != nil {
|
if err := v1.Convert_bool_To_Pointer_bool(&in.LocalStorageCapacityIsolation, &out.LocalStorageCapacityIsolation, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.ContainerRuntimeEndpoint = in.ContainerRuntimeEndpoint
|
||||||
|
out.ImageServiceEndpoint = in.ImageServiceEndpoint
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,24 +300,16 @@ func makePodSourceConfig(kubeCfg *kubeletconfiginternal.KubeletConfiguration, ku
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PreInitRuntimeService will init runtime service before RunKubelet.
|
// PreInitRuntimeService will init runtime service before RunKubelet.
|
||||||
func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *Dependencies) error {
|
||||||
kubeDeps *Dependencies,
|
|
||||||
remoteRuntimeEndpoint string,
|
|
||||||
remoteImageEndpoint string) error {
|
|
||||||
// remoteImageEndpoint is same as remoteRuntimeEndpoint if not explicitly specified
|
|
||||||
if remoteRuntimeEndpoint != "" && remoteImageEndpoint == "" {
|
|
||||||
remoteImageEndpoint = remoteRuntimeEndpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if kubeDeps.RemoteRuntimeService, err = remote.NewRemoteRuntimeService(remoteRuntimeEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
|
if kubeDeps.RemoteRuntimeService, err = remote.NewRemoteRuntimeService(kubeCfg.ContainerRuntimeEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if kubeDeps.RemoteImageService, err = remote.NewRemoteImageService(remoteImageEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
|
if kubeDeps.RemoteImageService, err = remote.NewRemoteImageService(kubeCfg.ImageServiceEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeDeps.useLegacyCadvisorStats = cadvisor.UsingLegacyCadvisorStats(remoteRuntimeEndpoint)
|
kubeDeps.useLegacyCadvisorStats = cadvisor.UsingLegacyCadvisorStats(kubeCfg.ContainerRuntimeEndpoint)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,6 @@ func GetHollowKubeletConfig(opt *HollowKubeletOptions) (*options.KubeletFlags, *
|
|||||||
f.MaxPerPodContainerCount = 2
|
f.MaxPerPodContainerCount = 2
|
||||||
f.NodeLabels = opt.NodeLabels
|
f.NodeLabels = opt.NodeLabels
|
||||||
f.RegisterSchedulable = true
|
f.RegisterSchedulable = true
|
||||||
f.RemoteImageEndpoint = "unix:///run/containerd/containerd.sock"
|
|
||||||
|
|
||||||
// Config struct
|
// Config struct
|
||||||
c, err := options.NewKubeletConfiguration()
|
c, err := options.NewKubeletConfiguration()
|
||||||
@ -166,6 +165,7 @@ func GetHollowKubeletConfig(opt *HollowKubeletOptions) (*options.KubeletFlags, *
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.ImageServiceEndpoint = "unix:///run/containerd/containerd.sock"
|
||||||
c.StaticPodURL = ""
|
c.StaticPodURL = ""
|
||||||
c.EnableServer = true
|
c.EnableServer = true
|
||||||
c.Address = "0.0.0.0" /* bind address */
|
c.Address = "0.0.0.0" /* bind address */
|
||||||
|
@ -803,6 +803,16 @@ type KubeletConfiguration struct {
|
|||||||
// Default: true
|
// Default: true
|
||||||
// +optional
|
// +optional
|
||||||
LocalStorageCapacityIsolation *bool `json:"localStorageCapacityIsolation,omitempty"`
|
LocalStorageCapacityIsolation *bool `json:"localStorageCapacityIsolation,omitempty"`
|
||||||
|
|
||||||
|
// ContainerRuntimeEndpoint is the endpoint of container runtime.
|
||||||
|
// unix domain sockets supported on Linux while npipes and tcp endpoints are supported for windows.
|
||||||
|
// Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime
|
||||||
|
ContainerRuntimeEndpoint string `json:"containerRuntimeEndpoint"`
|
||||||
|
|
||||||
|
// ImageServiceEndpoint is the endpoint of container image service.
|
||||||
|
// If not specified the default value is ContainerRuntimeEndpoint
|
||||||
|
// +optional
|
||||||
|
ImageServiceEndpoint string `json:"imageServiceEndpoint,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type KubeletAuthorizationMode string
|
type KubeletAuthorizationMode string
|
||||||
|
Loading…
Reference in New Issue
Block a user