remove a flag check that was introduced in #112542; address several comments

Signed-off-by: Paco Xu <paco.xu@daocloud.io>
This commit is contained in:
Paco Xu 2022-10-12 02:09:19 +08:00
parent 214a0ee7b8
commit f28f40e521
14 changed files with 31 additions and 23 deletions

View File

@ -189,13 +189,6 @@ func ValidateKubeletFlags(f *KubeletFlags) error {
return fmt.Errorf("unsupported CRI runtime: %q, only %q is currently supported", f.ContainerRuntime, kubetypes.RemoteContainerRuntime)
}
// Note: maybe we can test it for being a valid socket address as an additional improvement.
// The only problem with it will be that some setups may not specify 'unix://' prefix.
// So just check empty for back compat.
if f.RemoteRuntimeEndpoint == "" {
return fmt.Errorf("the container runtime endpoint address was not specified or empty, use --container-runtime-endpoint to set")
}
return nil
}

View File

@ -183,8 +183,7 @@ func TestValidateKubeletFlags(t *testing.T) {
ContainerRuntimeOptions: config.ContainerRuntimeOptions{
ContainerRuntime: kubetypes.RemoteContainerRuntime,
},
RemoteRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
NodeLabels: tt.labels,
NodeLabels: tt.labels,
})
if tt.error && err == nil {

View File

@ -254,7 +254,7 @@ func run(cmd *cobra.Command, config *hollowNodeConfig) error {
var imageService internalapi.ImageManagerService = fakeRemoteRuntime.ImageService
if config.UseHostImageService {
imageService, err = remote.NewRemoteImageService(c.ContainerRuntimeEndpoint, 15*time.Second, oteltrace.NewNoopTracerProvider())
imageService, err = remote.NewRemoteImageService(c.ImageServiceEndpoint, 15*time.Second, oteltrace.NewNoopTracerProvider())
if err != nil {
return fmt.Errorf("Failed to init image service, error: %w", err)
}

View File

@ -58631,7 +58631,7 @@ func schema_k8sio_kubelet_config_v1beta1_KubeletConfiguration(ref common.Referen
},
"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",
Description: "ContainerRuntimeEndpoint is the endpoint of container runtime. 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'",
Default: "",
Type: []string{"string"},
Format: "",
@ -58639,7 +58639,7 @@ func schema_k8sio_kubelet_config_v1beta1_KubeletConfiguration(ref common.Referen
},
"imageServiceEndpoint": {
SchemaProps: spec.SchemaProps{
Description: "ImageServiceEndpoint is the endpoint of container image service. If not specified the default value is ContainerRuntimeEndpoint",
Description: "ImageServiceEndpoint is the endpoint of container image service. 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'. If not specified, the value in containerRuntimeEndpoint is used.",
Type: []string{"string"},
Format: "",
},

View File

@ -107,7 +107,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
obj.ConfigMapAndSecretChangeDetectionStrategy = "Watch"
obj.AllowedUnsafeSysctls = []string{}
obj.VolumePluginDir = kubeletconfigv1beta1.DefaultVolumePluginDir
obj.ContainerRuntimeEndpoint = "containerd.sock"
obj.ContainerRuntimeEndpoint = "unix:///run/containerd/containerd.sock"
if obj.Logging.Format == "" {
obj.Logging.Format = "text"

View File

@ -17,7 +17,7 @@ cgroupsPerQOS: true
configMapAndSecretChangeDetectionStrategy: Watch
containerLogMaxFiles: 5
containerLogMaxSize: 10Mi
containerRuntimeEndpoint: ""
containerRuntimeEndpoint: unix:///run/containerd/containerd.sock
contentType: application/vnd.kubernetes.protobuf
cpuCFSQuota: true
cpuCFSQuotaPeriod: 100ms

View File

@ -17,7 +17,7 @@ cgroupsPerQOS: true
configMapAndSecretChangeDetectionStrategy: Watch
containerLogMaxFiles: 5
containerLogMaxSize: 10Mi
containerRuntimeEndpoint: ""
containerRuntimeEndpoint: unix:///run/containerd/containerd.sock
contentType: application/vnd.kubernetes.protobuf
cpuCFSQuota: true
cpuCFSQuotaPeriod: 100ms
@ -43,7 +43,6 @@ httpCheckFrequency: 20s
imageGCHighThresholdPercent: 85
imageGCLowThresholdPercent: 80
imageMinimumGCAge: 2m0s
imageServiceEndpoint: containerd.sock
iptablesDropBit: 15
iptablesMasqueradeBit: 14
kind: KubeletConfiguration

View File

@ -469,7 +469,7 @@ type KubeletConfiguration struct {
// 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
// Examples:'unix:///path/to/runtime.sock', 'npipe:////./pipe/runtime'
ContainerRuntimeEndpoint string
// ImageServiceEndpoint is the endpoint of container image service.

View File

@ -264,7 +264,7 @@ func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfigura
if obj.LocalStorageCapacityIsolation == nil {
obj.LocalStorageCapacityIsolation = utilpointer.BoolPtr(true)
}
if obj.ImageServiceEndpoint == "" && obj.ContainerRuntimeEndpoint != "" {
obj.ImageServiceEndpoint = obj.ContainerRuntimeEndpoint
if obj.ContainerRuntimeEndpoint == "" {
obj.ContainerRuntimeEndpoint = "unix:///run/containerd/containerd.sock"
}
}

View File

@ -78,6 +78,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
ImageMinimumGCAge: metav1.Duration{Duration: 2 * time.Minute},
ImageGCHighThresholdPercent: utilpointer.Int32Ptr(85),
ImageGCLowThresholdPercent: utilpointer.Int32Ptr(80),
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
VolumeStatsAggPeriod: metav1.Duration{Duration: time.Minute},
CgroupsPerQOS: utilpointer.BoolPtr(true),
CgroupDriver: "cgroupfs",
@ -173,6 +174,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
NodeStatusUpdateFrequency: zeroDuration,
NodeStatusReportFrequency: zeroDuration,
NodeLeaseDurationSeconds: 0,
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ImageMinimumGCAge: zeroDuration,
ImageGCHighThresholdPercent: utilpointer.Int32(0),
ImageGCLowThresholdPercent: utilpointer.Int32(0),
@ -285,6 +287,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second},
NodeStatusReportFrequency: metav1.Duration{Duration: 5 * time.Minute},
NodeLeaseDurationSeconds: 40,
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ImageMinimumGCAge: metav1.Duration{Duration: 2 * time.Minute},
ImageGCHighThresholdPercent: utilpointer.Int32(0),
ImageGCLowThresholdPercent: utilpointer.Int32(0),
@ -394,6 +397,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 60 * time.Second},
NodeStatusReportFrequency: metav1.Duration{Duration: 60 * time.Second},
NodeLeaseDurationSeconds: 1,
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ImageMinimumGCAge: metav1.Duration{Duration: 60 * time.Second},
ImageGCHighThresholdPercent: utilpointer.Int32(1),
ImageGCLowThresholdPercent: utilpointer.Int32(1),
@ -538,6 +542,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 60 * time.Second},
NodeStatusReportFrequency: metav1.Duration{Duration: 60 * time.Second},
NodeLeaseDurationSeconds: 1,
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ImageMinimumGCAge: metav1.Duration{Duration: 60 * time.Second},
ImageGCHighThresholdPercent: utilpointer.Int32(1),
ImageGCLowThresholdPercent: utilpointer.Int32(1),
@ -674,6 +679,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
NodeStatusUpdateFrequency: metav1.Duration{Duration: 1 * time.Minute},
NodeStatusReportFrequency: metav1.Duration{Duration: 1 * time.Minute},
NodeLeaseDurationSeconds: 40,
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
ImageMinimumGCAge: metav1.Duration{Duration: 2 * time.Minute},
ImageGCHighThresholdPercent: utilpointer.Int32Ptr(85),
ImageGCLowThresholdPercent: utilpointer.Int32Ptr(80),

View File

@ -257,5 +257,9 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration, featur
allErrors = append(allErrors, fmt.Errorf("invalid configuration: memoryThrottlingFactor %v must be greater than 0 and less than or equal to 1.0", *kc.MemoryThrottlingFactor))
}
if kc.ContainerRuntimeEndpoint == "" {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: the containerRuntimeEndpoint was not specified or empty"))
}
return utilerrors.NewAggregate(allErrors)
}

View File

@ -73,6 +73,7 @@ var (
Logging: logsapi.LoggingConfiguration{
Format: "text",
},
ContainerRuntimeEndpoint: "unix:///run/containerd/containerd.sock",
}
)

View File

@ -301,11 +301,15 @@ func makePodSourceConfig(kubeCfg *kubeletconfiginternal.KubeletConfiguration, ku
// PreInitRuntimeService will init runtime service before RunKubelet.
func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *Dependencies) error {
remoteImageEndpoint := kubeCfg.ImageServiceEndpoint
if remoteImageEndpoint == "" && kubeCfg.ContainerRuntimeEndpoint != "" {
remoteImageEndpoint = kubeCfg.ContainerRuntimeEndpoint
}
var err error
if kubeDeps.RemoteRuntimeService, err = remote.NewRemoteRuntimeService(kubeCfg.ContainerRuntimeEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
return err
}
if kubeDeps.RemoteImageService, err = remote.NewRemoteImageService(kubeCfg.ImageServiceEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
if kubeDeps.RemoteImageService, err = remote.NewRemoteImageService(remoteImageEndpoint, kubeCfg.RuntimeRequestTimeout.Duration, kubeDeps.TracerProvider); err != nil {
return err
}

View File

@ -805,12 +805,14 @@ type KubeletConfiguration struct {
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
// 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'
ContainerRuntimeEndpoint string `json:"containerRuntimeEndpoint"`
// ImageServiceEndpoint is the endpoint of container image service.
// If not specified the default value is ContainerRuntimeEndpoint
// 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'.
// If not specified, the value in containerRuntimeEndpoint is used.
// +optional
ImageServiceEndpoint string `json:"imageServiceEndpoint,omitempty"`
}