-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathproxy.go
More file actions
33 lines (25 loc) · 725 Bytes
/
proxy.go
File metadata and controls
33 lines (25 loc) · 725 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
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/",
}
}