mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Drop using cloud provider to set host address feature
As part of the larger plan to drop --cloud-provider and --cloud-config from kube-apiserver, we need to stop calling Cloud Provider API to find the external ip address when one is not specified on the command line. When ExternalHost is not specified, we check if AdvertiseAddress is specified and use that, if that is missing then we use os.Hostname(). When testing this feature, found a problem that when ExternalHost is specified, the port was not added in the generated URL. So fixed that as well.
This commit is contained in:
@@ -630,8 +630,18 @@ func defaultOptions(s *options.ServerRunOptions) error {
|
||||
if err := s.SecureServing.MaybeDefaultWithSelfSignedCerts(s.GenericServerRunOptions.AdvertiseAddress.String(), []string{"kubernetes.default.svc", "kubernetes.default", "kubernetes"}, []net.IP{apiServerServiceIP}); err != nil {
|
||||
return fmt.Errorf("error creating self-signed certificates: %v", err)
|
||||
}
|
||||
if err := s.CloudProvider.DefaultExternalHost(s.GenericServerRunOptions); err != nil {
|
||||
return fmt.Errorf("error setting the external host value: %v", err)
|
||||
|
||||
if len(s.GenericServerRunOptions.ExternalHost) == 0 {
|
||||
if len(s.GenericServerRunOptions.AdvertiseAddress) > 0 {
|
||||
s.GenericServerRunOptions.ExternalHost = s.GenericServerRunOptions.AdvertiseAddress.String()
|
||||
} else {
|
||||
if hostname, err := os.Hostname(); err == nil {
|
||||
s.GenericServerRunOptions.ExternalHost = hostname
|
||||
} else {
|
||||
return fmt.Errorf("error finding host name: %v", err)
|
||||
}
|
||||
}
|
||||
glog.Infof("external host was not specified, using %v", s.GenericServerRunOptions.ExternalHost)
|
||||
}
|
||||
|
||||
s.Authentication.ApplyAuthorization(s.Authorization)
|
||||
|
||||
Reference in New Issue
Block a user