Improve ResourceLocation API, allow proxy to use authenticated transport

This commit is contained in:
Jordan Liggitt
2015-03-23 14:42:39 -04:00
parent 1dc7bcf53b
commit a75b501821
18 changed files with 247 additions and 72 deletions

View File

@@ -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")
}