mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 04:03:20 +00:00
Improve ResourceLocation API, allow proxy to use authenticated transport
This commit is contained in:
@@ -40,6 +40,7 @@ type KubeletClient interface {
|
||||
KubeletHealthChecker
|
||||
PodInfoGetter
|
||||
NodeInfoGetter
|
||||
ConnectionInfoGetter
|
||||
}
|
||||
|
||||
// KubeletHealthchecker is an interface for healthchecking kubelets
|
||||
@@ -59,6 +60,10 @@ type NodeInfoGetter interface {
|
||||
GetNodeInfo(host string) (api.NodeInfo, error)
|
||||
}
|
||||
|
||||
type ConnectionInfoGetter interface {
|
||||
GetConnectionInfo(host string) (scheme string, port uint, transport http.RoundTripper, error error)
|
||||
}
|
||||
|
||||
// HTTPKubeletClient is the default implementation of PodInfoGetter and KubeletHealthchecker, accesses the kubelet over HTTP.
|
||||
type HTTPKubeletClient struct {
|
||||
Client *http.Client
|
||||
@@ -92,6 +97,14 @@ func NewKubeletClient(config *KubeletConfig) (KubeletClient, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *HTTPKubeletClient) GetConnectionInfo(host string) (string, uint, http.RoundTripper, error) {
|
||||
scheme := "http"
|
||||
if c.EnableHttps {
|
||||
scheme = "https"
|
||||
}
|
||||
return scheme, c.Port, c.Client.Transport, nil
|
||||
}
|
||||
|
||||
func (c *HTTPKubeletClient) url(host, path, query string) string {
|
||||
scheme := "http"
|
||||
if c.EnableHttps {
|
||||
@@ -168,3 +181,7 @@ func (c FakeKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error) {
|
||||
func (c FakeKubeletClient) HealthCheck(host string) (probe.Result, error) {
|
||||
return probe.Unknown, errors.New("Not Implemented")
|
||||
}
|
||||
|
||||
func (c FakeKubeletClient) GetConnectionInfo(host string) (string, uint, http.RoundTripper, error) {
|
||||
return "", 0, nil, errors.New("Not Implemented")
|
||||
}
|
||||
|
Reference in New Issue
Block a user