forked from projectatomic/atomic-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
33 lines (25 loc) · 725 Bytes
/
proxy.go
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
package kubernetes
import (
"net/url"
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
restful "github.com/emicklei/go-restful"
"github.com/golang/glog"
"github.com/openshift/origin/pkg/util/httpproxy"
)
type ProxyConfig struct {
ClientConfig *kclient.Config
}
func (c *ProxyConfig) InstallAPI(container *restful.Container) []string {
kubeAddr, err := url.Parse(c.ClientConfig.Host)
if err != nil {
glog.Fatal(err)
}
proxy, err := httpproxy.NewUpgradeAwareSingleHostReverseProxy(c.ClientConfig, kubeAddr)
if err != nil {
glog.Fatalf("Unable to initialize the Kubernetes proxy: %v", err)
}
container.Handle("/api/", proxy)
return []string{
"Started Kubernetes proxy at %s/api/",
}
}