@@ -26,26 +26,10 @@ import (
26
26
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
27
27
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
28
28
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
29
- "k8s.io/kubernetes/cmd/kubeadm/app/preflight"
30
29
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
31
- utilsexec "k8s.io/utils/exec"
32
30
)
33
31
34
32
var (
35
- kubeletConfigDownloadLongDesc = cmdutil .LongDesc (`
36
- Download the kubelet configuration from a ConfigMap of the form "kubelet-config-1.X" in the cluster,
37
- where X is the minor version of the kubelet. Either kubeadm autodetects the kubelet version by exec-ing
38
- "kubelet --version" or respects the --kubelet-version parameter.
39
- ` + cmdutil .AlphaDisclaimer )
40
-
41
- kubeletConfigDownloadExample = cmdutil .Examples (fmt .Sprintf (`
42
- # Download the kubelet configuration from the ConfigMap in the cluster. Autodetect the kubelet version.
43
- kubeadm alpha kubelet config download
44
-
45
- # Download the kubelet configuration from the ConfigMap in the cluster. Use a specific desired kubelet version.
46
- kubeadm alpha kubelet config download --kubelet-version %s
47
- ` , constants .CurrentKubernetesVersion ))
48
-
49
33
kubeletConfigEnableDynamicLongDesc = cmdutil .LongDesc (`
50
34
Enable or update dynamic kubelet configuration for a Node, against the kubelet-config-1.X ConfigMap in the cluster,
51
35
where X is the minor version of the desired kubelet version.
@@ -84,49 +68,10 @@ func newCmdKubeletConfig() *cobra.Command {
84
68
Long : cmdutil .MacroCommandLongDescription ,
85
69
}
86
70
87
- cmd .AddCommand (newCmdKubeletConfigDownload ())
88
71
cmd .AddCommand (newCmdKubeletConfigEnableDynamic ())
89
72
return cmd
90
73
}
91
74
92
- // newCmdKubeletConfigDownload calls cobra.Command for downloading the kubelet configuration from the kubelet-config-1.X ConfigMap in the cluster
93
- func newCmdKubeletConfigDownload () * cobra.Command {
94
- var kubeletVersionStr string
95
- // TODO: Be smarter about this and be able to load multiple kubeconfig files in different orders of precedence
96
- kubeConfigFile := constants .GetKubeletKubeConfigPath ()
97
-
98
- cmd := & cobra.Command {
99
- Use : "download" ,
100
- Short : "Download the kubelet configuration from the cluster ConfigMap kubelet-config-1.X, where X is the minor version of the kubelet" ,
101
- Long : kubeletConfigDownloadLongDesc ,
102
- Example : kubeletConfigDownloadExample ,
103
- RunE : func (cmd * cobra.Command , args []string ) error {
104
- kubeletVersion , err := getKubeletVersion (kubeletVersionStr )
105
- if err != nil {
106
- return err
107
- }
108
-
109
- client , err := kubeconfigutil .ClientSetFromFile (kubeConfigFile )
110
- if err != nil {
111
- return err
112
- }
113
-
114
- return kubeletphase .DownloadConfig (client , kubeletVersion , constants .KubeletRunDirectory )
115
- },
116
- }
117
-
118
- options .AddKubeConfigFlag (cmd .Flags (), & kubeConfigFile )
119
- cmd .Flags ().StringVar (& kubeletVersionStr , "kubelet-version" , kubeletVersionStr , "The desired version for the kubelet. Defaults to being autodetected from 'kubelet --version'." )
120
- return cmd
121
- }
122
-
123
- func getKubeletVersion (kubeletVersionStr string ) (* version.Version , error ) {
124
- if len (kubeletVersionStr ) > 0 {
125
- return version .ParseSemantic (kubeletVersionStr )
126
- }
127
- return preflight .GetKubeletVersion (utilsexec .New ())
128
- }
129
-
130
75
// newCmdKubeletConfigEnableDynamic calls cobra.Command for enabling dynamic kubelet configuration on node
131
76
// This feature is still in alpha and an experimental state
132
77
func newCmdKubeletConfigEnableDynamic () * cobra.Command {
0 commit comments