mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Remove the deprecated AuthPath from KubeletServer
It has been deprecated for two releases (1.2 and 1.3).
This commit is contained in:
parent
0afaeab9b1
commit
7ae1458ab0
@ -67,7 +67,6 @@ func NewKubeletServer() *KubeletServer {
|
|||||||
config := componentconfig.KubeletConfiguration{}
|
config := componentconfig.KubeletConfiguration{}
|
||||||
api.Scheme.Convert(&v1alpha1.KubeletConfiguration{}, &config, nil)
|
api.Scheme.Convert(&v1alpha1.KubeletConfiguration{}, &config, nil)
|
||||||
return &KubeletServer{
|
return &KubeletServer{
|
||||||
AuthPath: util.NewStringFlag("/var/lib/kubelet/kubernetes_auth"), // deprecated
|
|
||||||
KubeConfig: util.NewStringFlag("/var/lib/kubelet/kubeconfig"),
|
KubeConfig: util.NewStringFlag("/var/lib/kubelet/kubeconfig"),
|
||||||
RequireKubeConfig: false, // in 1.5, default to true
|
RequireKubeConfig: false, // in 1.5, default to true
|
||||||
KubeletConfiguration: config,
|
KubeletConfiguration: config,
|
||||||
|
@ -505,28 +505,6 @@ func InitializeTLS(kc *componentconfig.KubeletConfiguration) (*server.TLSOptions
|
|||||||
return tlsOptions, nil
|
return tlsOptions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func authPathClientConfig(s *options.KubeletServer, useDefaults bool) (*restclient.Config, error) {
|
|
||||||
authInfo, err := clientauth.LoadFromFile(s.AuthPath.Value())
|
|
||||||
// If loading the default auth path, for backwards compatibility keep going
|
|
||||||
// with the default auth.
|
|
||||||
if err != nil {
|
|
||||||
if !useDefaults {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
glog.Warningf("Could not load kubernetes auth path %s: %v. Continuing with defaults.", s.AuthPath, err)
|
|
||||||
}
|
|
||||||
if authInfo == nil {
|
|
||||||
// authInfo didn't load correctly - continue with defaults.
|
|
||||||
authInfo = &clientauth.Info{}
|
|
||||||
}
|
|
||||||
authConfig, err := authInfo.MergeWithConfig(restclient.Config{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
authConfig.Host = s.APIServerList[0]
|
|
||||||
return &authConfig, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func kubeconfigClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
func kubeconfigClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||||
if s.RequireKubeConfig {
|
if s.RequireKubeConfig {
|
||||||
// Ignores the values of s.APIServerList
|
// Ignores the values of s.APIServerList
|
||||||
@ -542,11 +520,10 @@ func kubeconfigClientConfig(s *options.KubeletServer) (*restclient.Config, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createClientConfig creates a client configuration from the command line
|
// createClientConfig creates a client configuration from the command line
|
||||||
// arguments. If either --auth-path or --kubeconfig is explicitly set, it
|
// arguments. If --kubeconfig is explicitly set, it will be used. If it is
|
||||||
// will be used (setting both is an error). If neither are set first attempt
|
// not set, we attempt to load the default kubeconfig file, and if we cannot,
|
||||||
// to load the default kubeconfig file, then the default auth path file, and
|
// we fall back to the default client with no auth - this fallback does not, in
|
||||||
// fall back to the default auth (none) without an error.
|
// and of itself, constitute an error.
|
||||||
// TODO(roberthbailey): Remove support for --auth-path
|
|
||||||
func createClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
func createClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||||
if s.RequireKubeConfig {
|
if s.RequireKubeConfig {
|
||||||
return kubeconfigClientConfig(s)
|
return kubeconfigClientConfig(s)
|
||||||
@ -562,20 +539,22 @@ func createClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
|||||||
glog.Infof("Multiple api servers specified. Picking first one")
|
glog.Infof("Multiple api servers specified. Picking first one")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.KubeConfig.Provided() && s.AuthPath.Provided() {
|
|
||||||
return nil, fmt.Errorf("cannot specify both --kubeconfig and --auth-path")
|
|
||||||
}
|
|
||||||
if s.KubeConfig.Provided() {
|
if s.KubeConfig.Provided() {
|
||||||
return kubeconfigClientConfig(s)
|
return kubeconfigClientConfig(s)
|
||||||
}
|
}
|
||||||
if s.AuthPath.Provided() {
|
// If KubeConfig was not provided, try to load the default file, then fall back
|
||||||
return authPathClientConfig(s, false)
|
// to a default auth config.
|
||||||
}
|
|
||||||
// Try the kubeconfig default first, falling back to the auth path default.
|
|
||||||
clientConfig, err := kubeconfigClientConfig(s)
|
clientConfig, err := kubeconfigClientConfig(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Could not load kubeconfig file %s: %v. Trying auth path instead.", s.KubeConfig, err)
|
glog.Warningf("Could not load kubeconfig file %s: %v. Using default client config instead.", s.KubeConfig, err)
|
||||||
return authPathClientConfig(s, true)
|
|
||||||
|
authInfo := &clientauth.Info{}
|
||||||
|
authConfig, err := authInfo.MergeWithConfig(restclient.Config{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
authConfig.Host = s.APIServerList[0]
|
||||||
|
clientConfig = &authConfig
|
||||||
}
|
}
|
||||||
return clientConfig, nil
|
return clientConfig, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user