-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubelet: group all container-runtime-specific flags/options into a separate struct #44061
Conversation
/cc @Random-Liu |
cmd/kubelet/app/options/options.go
Outdated
@@ -80,6 +80,7 @@ type KubeletFlags struct { | |||
type KubeletServer struct { | |||
KubeletFlags | |||
componentconfig.KubeletConfiguration | |||
DockerOptions *DockerOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not take DockerOptions
as an embedded field of KubeletServer
like KubeletFlags
? Then the fields of DockerOptions
can be directly accessed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. DockerOptions
may be nil in the future.
cmd/kubelet/app/server.go
Outdated
@@ -156,7 +156,7 @@ func UnsecuredKubeletDeps(s *options.KubeletServer) (*kubelet.KubeletDeps, error | |||
KubeClient: nil, | |||
ExternalKubeClient: nil, | |||
Mounter: mounter, | |||
NetworkPlugins: ProbeNetworkPlugins(s.NetworkPluginDir, s.CNIConfDir, s.CNIBinDir), | |||
NetworkPlugins: ProbeNetworkPlugins(s.DockerOptions.NetworkPluginDir, s.DockerOptions.CNIConfDir, s.DockerOptions.CNIBinDir), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If take DockerOptions
as an embedded field of KubeletServer
, these and other changes are not needed, as the fields of DockerOptions such as s.DockerOptions.NetworkPluginDir
can be directly accessed by s.NetworkPluginDir
like before.
Unfortunately some of the flags are shared by rktnetes, which complicates things. I am going to go through the list of options again. Tagging this as WIP. |
cmd/kubelet/app/options/docker.go
Outdated
DockerEndpoint string | ||
// networkPluginName is the name of the network plugin to be invoked for | ||
// various events in kubelet/pod lifecycle | ||
NetworkPluginName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we take these network flags as docker options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new CRI world, network plugins are container runtime details. kubelet is not aware of them.
The tricky part is that these are still consumed by rkt since they haven't switched to CRI. That's why I marked this PR as WIP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation!
cmd/kubelet/app/options/options.go
Outdated
@@ -248,8 +241,6 @@ func (c *kubeletConfiguration) addFlags(fs *pflag.FlagSet) { | |||
fs.BoolVar(&c.BabysitDaemons, "babysit-daemons", c.BabysitDaemons, "If true, the node has babysitter process monitoring docker and kubelet.") | |||
fs.MarkDeprecated("babysit-daemons", "Will be removed in a future version.") | |||
fs.Int32Var(&c.MaxPods, "max-pods", c.MaxPods, "Number of Pods that can run on this Kubelet.") | |||
// TODO(#40229): Remove the docker-exec-handler flag. | |||
fs.StringVar(&c.DockerExecHandlerName, "docker-exec-handler", c.DockerExecHandlerName, "Handler to use when executing a command in a container. Valid values are 'native' and 'nsenter'. Defaults to 'native'.") | |||
fs.MarkDeprecated("docker-exec-handler", "this flag will be removed and only the 'native' handler will be supported in the future.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the issue states, we can't really remove this yet.
Should |
And what about fields like:
This stuff seems pretty runtime-specific and probably shouldn't be fed through the Kubelet. |
The docker endpoint and exec handler are already included in the |
Please ping me when this is ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also use this PR to mark deprecated any runtime-related flags that are planned for removal from the Kubelet.
@mtaufen I changed the PR to include all runtime-specific flags. It's not complete though. I think it's ok as a start. Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, I had a few comments.
cmd/kubelet/app/options/options.go
Outdated
@@ -87,6 +83,7 @@ type KubeletFlags struct { | |||
// a kubelet. These can either be set via command line or directly. | |||
type KubeletServer struct { | |||
KubeletFlags | |||
ContainerRuntimeOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this PR, but very soon we'll have to actually name these sub-objects. It's getting very confusing what comes from where in KubeletServer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, would it make sense for these to be subordinate to the KubeletFlags object, rather than directly on the KubeletServer, given that they all come in as flags-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named it in the original PR but changed it to be consistent with other fields in the struct. Will switch it back.
Also, would it make sense for these to be subordinate to the KubeletFlags object, rather than directly on the KubeletServer, given that they all come in as flags-only?
Make sense. We still need to pass the container runtime options as a whole to kubelet, but I think that's fine. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's fine. Thanks!
pkg/kubemark/hollow_kubelet.go
Outdated
@@ -172,6 +175,6 @@ func GetHollowKubeletConfig( | |||
// have actually wanted the default). | |||
// The default will be present in the KubeletConfiguration contstructed above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this TODO as well. It's old and irrelevant these days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'll continue evaluate other options to see what can be moved to this new struct, but I think getting this in would help prevent people from adding more fields to KubeletConfig. |
Yeah, SGTM |
/lgtm |
/cc @gmarek for approval. |
@k8s-bot pull-kubernetes-unit test this |
1 similar comment
@k8s-bot pull-kubernetes-unit test this |
@k8s-bot pull-kubernetes-e2e-kops-aws test this I've been pasting the wrong one :-| |
/approve |
Assigned to @shyamjvs. I found a new victim to approve the kubemark changes before I have to rebase again :-) |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mtaufen, shyamjvs, yujuhong
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Do not store them in kubelet's configuration. Eventually, we would like to deprecate all these flags as they should not be part of kubelet.
Rebased and re-applying the lgtm & approved labels based on #44061 (comment) and #44061 (comment) |
Automatic merge from submit-queue |
They don't belong in the KubeletConfig.
This addresses #43253