mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #9423 from mesosphere/create-api-server-client
refactor createAPIServerClient for easier integration with 3rd party …
This commit is contained in:
commit
0fbd4900d1
@ -254,7 +254,11 @@ func (s *KubeletServer) Run(_ []string) error {
|
|||||||
glog.Warning(err)
|
glog.Warning(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := s.createAPIServerClient()
|
var apiclient *client.Client
|
||||||
|
clientConfig, err := s.CreateAPIServerClientConfig()
|
||||||
|
if err == nil {
|
||||||
|
apiclient, err = client.New(clientConfig)
|
||||||
|
}
|
||||||
if err != nil && len(s.APIServerList) > 0 {
|
if err != nil && len(s.APIServerList) > 0 {
|
||||||
glog.Warningf("No API client: %v", err)
|
glog.Warningf("No API client: %v", err)
|
||||||
}
|
}
|
||||||
@ -334,7 +338,7 @@ func (s *KubeletServer) Run(_ []string) error {
|
|||||||
EnableServer: s.EnableServer,
|
EnableServer: s.EnableServer,
|
||||||
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
|
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
|
||||||
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
|
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
|
||||||
KubeClient: client,
|
KubeClient: apiclient,
|
||||||
MasterServiceNamespace: s.MasterServiceNamespace,
|
MasterServiceNamespace: s.MasterServiceNamespace,
|
||||||
VolumePlugins: ProbeVolumePlugins(),
|
VolumePlugins: ProbeVolumePlugins(),
|
||||||
NetworkPlugins: ProbeNetworkPlugins(),
|
NetworkPlugins: ProbeNetworkPlugins(),
|
||||||
@ -454,7 +458,11 @@ func (s *KubeletServer) createClientConfig() (*client.Config, error) {
|
|||||||
return clientConfig, nil
|
return clientConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KubeletServer) createAPIServerClient() (*client.Client, error) {
|
// CreateAPIServerClientConfig generates a client.Config from command line flags,
|
||||||
|
// including api-server-list, via createClientConfig and then injects chaos into
|
||||||
|
// the configuration via addChaosToClientConfig. This func is exported to support
|
||||||
|
// integration with third party kubelet extensions (e.g. kubernetes-mesos).
|
||||||
|
func (s *KubeletServer) CreateAPIServerClientConfig() (*client.Config, error) {
|
||||||
if len(s.APIServerList) < 1 {
|
if len(s.APIServerList) < 1 {
|
||||||
return nil, fmt.Errorf("no api servers specified")
|
return nil, fmt.Errorf("no api servers specified")
|
||||||
}
|
}
|
||||||
@ -468,11 +476,7 @@ func (s *KubeletServer) createAPIServerClient() (*client.Client, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.addChaosToClientConfig(clientConfig)
|
s.addChaosToClientConfig(clientConfig)
|
||||||
client, err := client.New(clientConfig)
|
return clientConfig, nil
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return client, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// addChaosToClientConfig injects random errors into client connections if configured.
|
// addChaosToClientConfig injects random errors into client connections if configured.
|
||||||
|
Loading…
Reference in New Issue
Block a user