Skip to content

Commit

Permalink
Extract RESTHandler and allow API groupings
Browse files Browse the repository at this point in the history
Prepare for running multiple API versions on the same HTTP server
by decoupling some of the mechanics of apiserver.  Define a new
APIGroup object which represents a version of the API.
  • Loading branch information
smarterclayton committed Aug 13, 2014
1 parent aeea1b1 commit bbf3b55
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 289 deletions.
11 changes: 10 additions & 1 deletion cmd/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strconv"
"time"

"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
Expand Down Expand Up @@ -114,5 +115,13 @@ func main() {
})
}

glog.Fatal(m.Run(net.JoinHostPort(*address, strconv.Itoa(int(*port))), *apiPrefix))
storage, codec := m.API_v1beta1()
s := &http.Server{
Addr: net.JoinHostPort(*address, strconv.Itoa(int(*port))),
Handler: apiserver.Handle(storage, codec, *apiPrefix),
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
glog.Fatal(s.ListenAndServe())
}
10 changes: 6 additions & 4 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"time"

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
Expand Down Expand Up @@ -86,11 +87,11 @@ func startComponents(manifestURL string) (apiServerURL string) {
machineList := []string{"localhost", "machine"}

handler := delegateHandler{}
apiserver := httptest.NewServer(&handler)
apiServer := httptest.NewServer(&handler)

etcdClient := etcd.NewClient(servers)

cl := client.New(apiserver.URL, nil)
cl := client.New(apiServer.URL, nil)
cl.PollPeriod = time.Second * 1
cl.Sync = true

Expand All @@ -101,7 +102,8 @@ func startComponents(manifestURL string) (apiServerURL string) {
Minions: machineList,
PodInfoGetter: fakePodInfoGetter{},
})
handler.delegate = m.ConstructHandler("/api/v1beta1")
storage, codec := m.API_v1beta1()
handler.delegate = apiserver.Handle(storage, codec, "/api/v1beta1")

controllerManager := controller.MakeReplicationManager(cl)

Expand Down Expand Up @@ -130,7 +132,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), http.DefaultServeMux, "localhost", 10251)
}, 0)

return apiserver.URL
return apiServer.URL
}

func runReplicationControllerTest(kubeClient *client.Client) {
Expand Down
Loading

0 comments on commit bbf3b55

Please sign in to comment.