-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathproxy.go
More file actions
34 lines (25 loc) · 701 Bytes
/
proxy.go
File metadata and controls
34 lines (25 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package node
import (
"fmt"
"net/url"
restclient "k8s.io/client-go/rest"
restful "github.com/emicklei/go-restful"
"github.com/openshift/origin/pkg/util/httpproxy"
)
type ProxyConfig struct {
ClientConfig *restclient.Config
}
func (c *ProxyConfig) InstallAPI(container *restful.Container) ([]string, error) {
kubeAddr, err := url.Parse(c.ClientConfig.Host)
if err != nil {
return nil, err
}
proxy, err := httpproxy.NewUpgradeAwareSingleHostReverseProxy(c.ClientConfig, kubeAddr)
if err != nil {
return nil, fmt.Errorf("Unable to initialize the Kubernetes proxy: %v", err)
}
container.Handle("/api/", proxy)
return []string{
"Started Kubernetes proxy at %s/api/",
}, nil
}