mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
[Federation] Update the deprecated name for 1.5 and try with flags only when --kubeconfig
is non-empty.
This commit is contained in:
parent
dbfc110934
commit
efafff4078
@ -52,14 +52,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// "federation-apiserver-secret" was the old name we used to store
|
||||
// Federation API server kubeconfig secret. Unfortunately, this name
|
||||
// is very close to "federation-apiserver-secrets" and causes a lot
|
||||
// of confusion, particularly while debugging. So deprecating it in
|
||||
// favor of the new name but giving people time to migrate.
|
||||
// TODO(madhusudancs): this name is deprecated in 1.4 and should be
|
||||
// removed in 1.5. Remove it in 1.5.
|
||||
DeprecatedKubeconfigSecretName = "federation-apiserver-secret"
|
||||
// "federation-apiserver-kubeconfig" was the old name we used to
|
||||
// store Federation API server kubeconfig secret. We are
|
||||
// deprecating it in favor of `--kubeconfig` flag but giving people
|
||||
// time to migrate.
|
||||
// TODO(madhusudancs): this name is deprecated in 1.5 and should be
|
||||
// removed in 1.6. Remove it in 1.6.
|
||||
DeprecatedKubeconfigSecretName = "federation-apiserver-kubeconfig"
|
||||
)
|
||||
|
||||
// NewControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||
@ -91,8 +90,8 @@ func Run(s *options.CMServer) error {
|
||||
glog.Errorf("unable to register configz: %s", err)
|
||||
}
|
||||
|
||||
// If s.Kubeconfig flag is empty, try with the deprecated name in 1.4.
|
||||
// TODO(madhusudancs): Remove this in 1.5.
|
||||
// If s.Kubeconfig flag is empty, try with the deprecated name in 1.5.
|
||||
// TODO(madhusudancs): Remove this in 1.6.
|
||||
var restClientCfg *restclient.Config
|
||||
var err error
|
||||
if len(s.Kubeconfig) <= 0 {
|
||||
@ -100,18 +99,18 @@ func Run(s *options.CMServer) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Create the config to talk to federation-apiserver.
|
||||
restClientCfg, err = clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig)
|
||||
if err != nil || restClientCfg == nil {
|
||||
// Retry with the deprecated name in 1.4.
|
||||
// TODO(madhusudancs): Remove this in 1.5.
|
||||
glog.V(2).Infof("Couldn't build the rest client config from flags: %v", err)
|
||||
glog.V(2).Infof("Trying with deprecated secret: %s", DeprecatedKubeconfigSecretName)
|
||||
restClientCfg, err = restClientConfigFromSecret(s.Master)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
// Create the config to talk to federation-apiserver.
|
||||
restClientCfg, err = clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig)
|
||||
if err != nil || restClientCfg == nil {
|
||||
// Retry with the deprecated name in 1.5.
|
||||
// TODO(madhusudancs): Remove this in 1.6.
|
||||
glog.V(2).Infof("Couldn't build the rest client config from flags: %v", err)
|
||||
glog.V(2).Infof("Trying with deprecated secret: %s", DeprecatedKubeconfigSecretName)
|
||||
restClientCfg, err = restClientConfigFromSecret(s.Master)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,13 +194,13 @@ func StartControllers(s *options.CMServer, restClientCfg *restclient.Config) err
|
||||
select {}
|
||||
}
|
||||
|
||||
// TODO(madhusudancs): Remove this in 1.5. This is only temporary to give an
|
||||
// upgrade path in 1.4.
|
||||
// TODO(madhusudancs): Remove this in 1.6. This is only temporary to give an
|
||||
// upgrade path in 1.4/1.5.
|
||||
func restClientConfigFromSecret(master string) (*restclient.Config, error) {
|
||||
kubeconfigGetter := util.KubeconfigGetterForSecret(DeprecatedKubeconfigSecretName)
|
||||
restClientCfg, err := clientcmd.BuildConfigFromKubeconfigGetter(master, kubeconfigGetter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to find the Federation API server kubeconfig, tried the flags and the deprecated secret %s: %v", DeprecatedKubeconfigSecretName, err)
|
||||
return nil, fmt.Errorf("failed to find the Federation API server kubeconfig, tried the --kubeconfig flag and the deprecated secret %s: %v", DeprecatedKubeconfigSecretName, err)
|
||||
}
|
||||
return restClientCfg, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user