Commit 5d54c557 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #30212 from feiskyer/kuberuntime-flag

Automatic merge from submit-queue Kubelet: add --container-runtime-endpoint and --image-service-endpoint Flag `--container-runtime-endpoint` (overrides `--container-runtime`) is introduced to identify the unix socket file of the remote runtime service. And flag `--image-service-endpoint` is introduced to identify the unix socket file of the image service. This PR is part of #28789 Milestone 0. CC @yujuhong @Random-Liu
parents 5a98379b b36ace9a
...@@ -184,6 +184,8 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) { ...@@ -184,6 +184,8 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.Int32Var(&s.IPTablesDropBit, "iptables-drop-bit", s.IPTablesDropBit, "The bit of the fwmark space to mark packets for dropping. Must be within the range [0, 31].") fs.Int32Var(&s.IPTablesDropBit, "iptables-drop-bit", s.IPTablesDropBit, "The bit of the fwmark space to mark packets for dropping. Must be within the range [0, 31].")
// Flags intended for testing, not recommended used in production environments. // Flags intended for testing, not recommended used in production environments.
fs.StringVar(&s.RemoteRuntimeEndpoint, "container-runtime-endpoint", s.RemoteRuntimeEndpoint, "The unix socket endpoint of remote runtime service. If not empty, this option will override --container-runtime. This is an experimental feature. Intended for testing only.")
fs.StringVar(&s.RemoteImageEndpoint, "image-service-endpoint", s.RemoteImageEndpoint, "The unix socket endpoint of remote image service. If not specified, it will be the same with container-runtime-endpoint by default. This is an experimental feature. Intended for testing only.")
fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.") fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]") fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]")
fs.BoolVar(&s.Containerized, "containerized", s.Containerized, "Experimental support for running kubelet in a container. Intended for testing. [default=false]") fs.BoolVar(&s.Containerized, "containerized", s.Containerized, "Experimental support for running kubelet in a container. Intended for testing. [default=false]")
......
...@@ -226,6 +226,8 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) { ...@@ -226,6 +226,8 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
ConfigureCBR0: s.ConfigureCBR0, ConfigureCBR0: s.ConfigureCBR0,
ContainerManager: nil, ContainerManager: nil,
ContainerRuntime: s.ContainerRuntime, ContainerRuntime: s.ContainerRuntime,
RemoteRuntimeEndpoint: s.RemoteRuntimeEndpoint,
RemoteImageEndpoint: s.RemoteImageEndpoint,
RuntimeRequestTimeout: s.RuntimeRequestTimeout.Duration, RuntimeRequestTimeout: s.RuntimeRequestTimeout.Duration,
CPUCFSQuota: s.CPUCFSQuota, CPUCFSQuota: s.CPUCFSQuota,
DiskSpacePolicy: diskSpacePolicy, DiskSpacePolicy: diskSpacePolicy,
...@@ -877,6 +879,8 @@ type KubeletConfig struct { ...@@ -877,6 +879,8 @@ type KubeletConfig struct {
ConfigureCBR0 bool ConfigureCBR0 bool
ContainerManager cm.ContainerManager ContainerManager cm.ContainerManager
ContainerRuntime string ContainerRuntime string
RemoteRuntimeEndpoint string
RemoteImageEndpoint string
RuntimeRequestTimeout time.Duration RuntimeRequestTimeout time.Duration
CPUCFSQuota bool CPUCFSQuota bool
DiskSpacePolicy kubelet.DiskSpacePolicy DiskSpacePolicy kubelet.DiskSpacePolicy
...@@ -1025,6 +1029,8 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod ...@@ -1025,6 +1029,8 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
kc.CgroupsPerQOS, kc.CgroupsPerQOS,
kc.CgroupRoot, kc.CgroupRoot,
kc.ContainerRuntime, kc.ContainerRuntime,
kc.RemoteRuntimeEndpoint,
kc.RemoteImageEndpoint,
kc.RuntimeRequestTimeout, kc.RuntimeRequestTimeout,
kc.RktPath, kc.RktPath,
kc.RktAPIEndpoint, kc.RktAPIEndpoint,
......
...@@ -90,6 +90,7 @@ consumer-service-namespace ...@@ -90,6 +90,7 @@ consumer-service-namespace
contain-pod-resources contain-pod-resources
container-port container-port
container-runtime container-runtime
container-runtime-endpoint
controller-start-interval controller-start-interval
cors-allowed-origins cors-allowed-origins
cpu-cfs-quota cpu-cfs-quota
...@@ -223,6 +224,7 @@ image-gc-high-threshold ...@@ -223,6 +224,7 @@ image-gc-high-threshold
image-gc-low-threshold image-gc-low-threshold
image-project image-project
image-pull-policy image-pull-policy
image-service-endpoint
include-extended-apis include-extended-apis
included-types-overrides included-types-overrides
input-base input-base
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -279,6 +279,10 @@ type KubeletConfiguration struct { ...@@ -279,6 +279,10 @@ type KubeletConfiguration struct {
CgroupRoot string `json:"cgroupRoot,omitempty"` CgroupRoot string `json:"cgroupRoot,omitempty"`
// containerRuntime is the container runtime to use. // containerRuntime is the container runtime to use.
ContainerRuntime string `json:"containerRuntime"` ContainerRuntime string `json:"containerRuntime"`
// remoteRuntimeEndpoint is the endpoint of remote runtime service
RemoteRuntimeEndpoint string `json:"remoteRuntimeEndpoint"`
// remoteImageEndpoint is the endpoint of remote image service
RemoteImageEndpoint string `json:"remoteImageEndpoint"`
// runtimeRequestTimeout is the timeout for all runtime requests except long running // runtimeRequestTimeout is the timeout for all runtime requests except long running
// requests - pull, logs, exec and attach. // requests - pull, logs, exec and attach.
RuntimeRequestTimeout unversioned.Duration `json:"runtimeRequestTimeout,omitempty"` RuntimeRequestTimeout unversioned.Duration `json:"runtimeRequestTimeout,omitempty"`
......
...@@ -334,6 +334,10 @@ type KubeletConfiguration struct { ...@@ -334,6 +334,10 @@ type KubeletConfiguration struct {
CgroupsPerQOS *bool `json:"CgroupsPerQOS,omitempty"` CgroupsPerQOS *bool `json:"CgroupsPerQOS,omitempty"`
// containerRuntime is the container runtime to use. // containerRuntime is the container runtime to use.
ContainerRuntime string `json:"containerRuntime"` ContainerRuntime string `json:"containerRuntime"`
// remoteRuntimeEndpoint is the endpoint of remote runtime service
RemoteRuntimeEndpoint string `json:"remoteRuntimeEndpoint"`
// remoteImageEndpoint is the endpoint of remote image service
RemoteImageEndpoint string `json:"remoteImageEndpoint"`
// runtimeRequestTimeout is the timeout for all runtime requests except long running // runtimeRequestTimeout is the timeout for all runtime requests except long running
// requests - pull, logs, exec and attach. // requests - pull, logs, exec and attach.
RuntimeRequestTimeout unversioned.Duration `json:"runtimeRequestTimeout"` RuntimeRequestTimeout unversioned.Duration `json:"runtimeRequestTimeout"`
......
...@@ -244,6 +244,8 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_componentconfig_KubeletConfigu ...@@ -244,6 +244,8 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_componentconfig_KubeletConfigu
return err return err
} }
out.ContainerRuntime = in.ContainerRuntime out.ContainerRuntime = in.ContainerRuntime
out.RemoteRuntimeEndpoint = in.RemoteRuntimeEndpoint
out.RemoteImageEndpoint = in.RemoteImageEndpoint
out.RuntimeRequestTimeout = in.RuntimeRequestTimeout out.RuntimeRequestTimeout = in.RuntimeRequestTimeout
out.RktPath = in.RktPath out.RktPath = in.RktPath
out.RktAPIEndpoint = in.RktAPIEndpoint out.RktAPIEndpoint = in.RktAPIEndpoint
...@@ -418,6 +420,8 @@ func autoConvert_componentconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigu ...@@ -418,6 +420,8 @@ func autoConvert_componentconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigu
out.SystemCgroups = in.SystemCgroups out.SystemCgroups = in.SystemCgroups
out.CgroupRoot = in.CgroupRoot out.CgroupRoot = in.CgroupRoot
out.ContainerRuntime = in.ContainerRuntime out.ContainerRuntime = in.ContainerRuntime
out.RemoteRuntimeEndpoint = in.RemoteRuntimeEndpoint
out.RemoteImageEndpoint = in.RemoteImageEndpoint
out.RuntimeRequestTimeout = in.RuntimeRequestTimeout out.RuntimeRequestTimeout = in.RuntimeRequestTimeout
out.RktPath = in.RktPath out.RktPath = in.RktPath
out.RktAPIEndpoint = in.RktAPIEndpoint out.RktAPIEndpoint = in.RktAPIEndpoint
......
...@@ -254,6 +254,8 @@ func DeepCopy_v1alpha1_KubeletConfiguration(in interface{}, out interface{}, c * ...@@ -254,6 +254,8 @@ func DeepCopy_v1alpha1_KubeletConfiguration(in interface{}, out interface{}, c *
out.CgroupsPerQOS = nil out.CgroupsPerQOS = nil
} }
out.ContainerRuntime = in.ContainerRuntime out.ContainerRuntime = in.ContainerRuntime
out.RemoteRuntimeEndpoint = in.RemoteRuntimeEndpoint
out.RemoteImageEndpoint = in.RemoteImageEndpoint
out.RuntimeRequestTimeout = in.RuntimeRequestTimeout out.RuntimeRequestTimeout = in.RuntimeRequestTimeout
out.RktPath = in.RktPath out.RktPath = in.RktPath
out.RktAPIEndpoint = in.RktAPIEndpoint out.RktAPIEndpoint = in.RktAPIEndpoint
......
...@@ -266,6 +266,8 @@ func DeepCopy_componentconfig_KubeletConfiguration(in interface{}, out interface ...@@ -266,6 +266,8 @@ func DeepCopy_componentconfig_KubeletConfiguration(in interface{}, out interface
out.SystemCgroups = in.SystemCgroups out.SystemCgroups = in.SystemCgroups
out.CgroupRoot = in.CgroupRoot out.CgroupRoot = in.CgroupRoot
out.ContainerRuntime = in.ContainerRuntime out.ContainerRuntime = in.ContainerRuntime
out.RemoteRuntimeEndpoint = in.RemoteRuntimeEndpoint
out.RemoteImageEndpoint = in.RemoteImageEndpoint
out.RuntimeRequestTimeout = in.RuntimeRequestTimeout out.RuntimeRequestTimeout = in.RuntimeRequestTimeout
out.RktPath = in.RktPath out.RktPath = in.RktPath
out.RktAPIEndpoint = in.RktAPIEndpoint out.RktAPIEndpoint = in.RktAPIEndpoint
......
...@@ -54,6 +54,7 @@ import ( ...@@ -54,6 +54,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/events" "k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/pkg/kubelet/eviction" "k8s.io/kubernetes/pkg/kubelet/eviction"
"k8s.io/kubernetes/pkg/kubelet/images" "k8s.io/kubernetes/pkg/kubelet/images"
"k8s.io/kubernetes/pkg/kubelet/kuberuntime"
"k8s.io/kubernetes/pkg/kubelet/lifecycle" "k8s.io/kubernetes/pkg/kubelet/lifecycle"
"k8s.io/kubernetes/pkg/kubelet/metrics" "k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/kubelet/network" "k8s.io/kubernetes/pkg/kubelet/network"
...@@ -61,6 +62,7 @@ import ( ...@@ -61,6 +62,7 @@ import (
kubepod "k8s.io/kubernetes/pkg/kubelet/pod" kubepod "k8s.io/kubernetes/pkg/kubelet/pod"
"k8s.io/kubernetes/pkg/kubelet/prober" "k8s.io/kubernetes/pkg/kubelet/prober"
proberesults "k8s.io/kubernetes/pkg/kubelet/prober/results" proberesults "k8s.io/kubernetes/pkg/kubelet/prober/results"
"k8s.io/kubernetes/pkg/kubelet/remote"
"k8s.io/kubernetes/pkg/kubelet/rkt" "k8s.io/kubernetes/pkg/kubelet/rkt"
"k8s.io/kubernetes/pkg/kubelet/server" "k8s.io/kubernetes/pkg/kubelet/server"
"k8s.io/kubernetes/pkg/kubelet/server/stats" "k8s.io/kubernetes/pkg/kubelet/server/stats"
...@@ -212,6 +214,8 @@ func NewMainKubelet( ...@@ -212,6 +214,8 @@ func NewMainKubelet(
CgroupsPerQOS bool, CgroupsPerQOS bool,
cgroupRoot string, cgroupRoot string,
containerRuntime string, containerRuntime string,
remoteRuntimeEndpoint string,
remoteImageEndpoint string,
runtimeRequestTimeout time.Duration, runtimeRequestTimeout time.Duration,
rktPath string, rktPath string,
rktAPIEndpoint string, rktAPIEndpoint string,
...@@ -415,6 +419,15 @@ func NewMainKubelet( ...@@ -415,6 +419,15 @@ func NewMainKubelet(
klet.podCache = kubecontainer.NewCache() klet.podCache = kubecontainer.NewCache()
klet.podManager = kubepod.NewBasicPodManager(kubepod.NewBasicMirrorClient(klet.kubeClient)) klet.podManager = kubepod.NewBasicPodManager(kubepod.NewBasicMirrorClient(klet.kubeClient))
if remoteRuntimeEndpoint != "" {
containerRuntime = "remote"
// remoteImageEndpoint is same as remoteRuntimeEndpoint if not explicitly specified
if remoteImageEndpoint == "" {
remoteImageEndpoint = remoteRuntimeEndpoint
}
}
// Initialize the runtime. // Initialize the runtime.
switch containerRuntime { switch containerRuntime {
case "docker": case "docker":
...@@ -479,6 +492,32 @@ func NewMainKubelet( ...@@ -479,6 +492,32 @@ func NewMainKubelet(
return nil, err return nil, err
} }
klet.containerRuntime = rktRuntime klet.containerRuntime = rktRuntime
case "remote":
remoteRuntimeService, err := remote.NewRemoteRuntimeService(remoteRuntimeEndpoint, runtimeRequestTimeout)
if err != nil {
return nil, err
}
remoteImageService, err := remote.NewRemoteImageService(remoteImageEndpoint, runtimeRequestTimeout)
if err != nil {
return nil, err
}
klet.containerRuntime, err = kuberuntime.NewKubeGenericRuntimeManager(
kubecontainer.FilterEventRecorder(recorder),
klet.livenessManager,
containerRefManager,
osInterface,
klet.networkPlugin,
klet,
klet.httpClient,
imageBackOff,
serializeImagePulls,
klet.cpuCFSQuota,
remoteRuntimeService,
remoteImageService,
)
if err != nil {
return nil, err
}
default: default:
return nil, fmt.Errorf("unsupported container runtime %q specified", containerRuntime) return nil, fmt.Errorf("unsupported container runtime %q specified", containerRuntime)
} }
......
...@@ -22,13 +22,13 @@ import ( ...@@ -22,13 +22,13 @@ import (
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/client/record" "k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/credentialprovider"
internalApi "k8s.io/kubernetes/pkg/kubelet/api" internalApi "k8s.io/kubernetes/pkg/kubelet/api"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" "k8s.io/kubernetes/pkg/kubelet/images"
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
"k8s.io/kubernetes/pkg/kubelet/network" "k8s.io/kubernetes/pkg/kubelet/network"
nettest "k8s.io/kubernetes/pkg/kubelet/network/testing"
proberesults "k8s.io/kubernetes/pkg/kubelet/prober/results" proberesults "k8s.io/kubernetes/pkg/kubelet/prober/results"
kubetypes "k8s.io/kubernetes/pkg/types" kubetypes "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/flowcontrol" "k8s.io/kubernetes/pkg/util/flowcontrol"
...@@ -76,27 +76,36 @@ func (f *fakeRuntimeHelper) GetExtraSupplementalGroupsForPod(pod *api.Pod) []int ...@@ -76,27 +76,36 @@ func (f *fakeRuntimeHelper) GetExtraSupplementalGroupsForPod(pod *api.Pod) []int
return nil return nil
} }
func NewFakeKubeRuntimeManager(runtimeService internalApi.RuntimeService, imageService internalApi.ImageManagerService) (*kubeGenericRuntimeManager, error) { func NewFakeKubeRuntimeManager(runtimeService internalApi.RuntimeService, imageService internalApi.ImageManagerService, networkPlugin network.NetworkPlugin, osInterface kubecontainer.OSInterface) (*kubeGenericRuntimeManager, error) {
networkPlugin, _ := network.InitNetworkPlugin( recorder := &record.FakeRecorder{}
[]network.NetworkPlugin{}, kubeRuntimeManager := &kubeGenericRuntimeManager{
"", recorder: recorder,
nettest.NewFakeHost(nil), cpuCFSQuota: false,
componentconfig.HairpinNone, livenessManager: proberesults.NewManager(),
"10.0.0.0/8", containerRefManager: kubecontainer.NewRefManager(),
) osInterface: osInterface,
networkPlugin: networkPlugin,
return NewKubeGenericRuntimeManager( runtimeHelper: &fakeRuntimeHelper{},
&record.FakeRecorder{}, runtimeService: runtimeService,
proberesults.NewManager(), imageService: imageService,
kubecontainer.NewRefManager(), keyring: credentialprovider.NewDockerKeyring(),
&containertest.FakeOS{}, }
networkPlugin,
&fakeRuntimeHelper{}, typedVersion, err := runtimeService.Version(kubeRuntimeAPIVersion)
&fakeHTTP{}, if err != nil {
return nil, err
}
kubeRuntimeManager.runtimeName = typedVersion.GetRuntimeName()
kubeRuntimeManager.imagePuller = images.NewImageManager(
kubecontainer.FilterEventRecorder(recorder),
kubeRuntimeManager,
flowcontrol.NewBackOff(time.Second, 300*time.Second), flowcontrol.NewBackOff(time.Second, 300*time.Second),
false, false)
false, kubeRuntimeManager.runner = lifecycle.NewHandlerRunner(
runtimeService, &fakeHTTP{},
imageService, kubeRuntimeManager,
) kubeRuntimeManager)
return kubeRuntimeManager, nil
} }
...@@ -96,7 +96,7 @@ func NewKubeGenericRuntimeManager( ...@@ -96,7 +96,7 @@ func NewKubeGenericRuntimeManager(
cpuCFSQuota bool, cpuCFSQuota bool,
runtimeService internalApi.RuntimeService, runtimeService internalApi.RuntimeService,
imageService internalApi.ImageManagerService, imageService internalApi.ImageManagerService,
) (*kubeGenericRuntimeManager, error) { ) (kubecontainer.Runtime, error) {
kubeRuntimeManager := &kubeGenericRuntimeManager{ kubeRuntimeManager := &kubeGenericRuntimeManager{
recorder: recorder, recorder: recorder,
cpuCFSQuota: cpuCFSQuota, cpuCFSQuota: cpuCFSQuota,
......
...@@ -20,13 +20,25 @@ import ( ...@@ -20,13 +20,25 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/apis/componentconfig"
apitest "k8s.io/kubernetes/pkg/kubelet/api/testing" apitest "k8s.io/kubernetes/pkg/kubelet/api/testing"
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
"k8s.io/kubernetes/pkg/kubelet/network"
nettest "k8s.io/kubernetes/pkg/kubelet/network/testing"
) )
func createTestFakeRuntimeManager() (*apitest.FakeRuntimeService, *apitest.FakeImageService, *kubeGenericRuntimeManager, error) { func createTestFakeRuntimeManager() (*apitest.FakeRuntimeService, *apitest.FakeImageService, *kubeGenericRuntimeManager, error) {
fakeRuntimeService := apitest.NewFakeRuntimeService() fakeRuntimeService := apitest.NewFakeRuntimeService()
fakeImageService := apitest.NewFakeImageService() fakeImageService := apitest.NewFakeImageService()
manager, err := NewFakeKubeRuntimeManager(fakeRuntimeService, fakeImageService) networkPlugin, _ := network.InitNetworkPlugin(
[]network.NetworkPlugin{},
"",
nettest.NewFakeHost(nil),
componentconfig.HairpinNone,
"10.0.0.0/8",
)
osInterface := &containertest.FakeOS{}
manager, err := NewFakeKubeRuntimeManager(fakeRuntimeService, fakeImageService, networkPlugin, osInterface)
return fakeRuntimeService, fakeImageService, manager, err return fakeRuntimeService, fakeImageService, manager, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment