Merge pull request #1868 from derekwaynecarr/service_proxy_needs_namespace

Fixup apiserver proxy to be namespace aware
pull/6/head
Daniel Smith 2014-10-20 11:48:29 -07:00
commit 7c9ac6a484
2 changed files with 10 additions and 1 deletions

View File

@ -116,6 +116,8 @@ The k8s API server will associate a resource with a *Namespace* if not populated
of the incoming request. If the *Namespace* of the resource being created, or updated does not match the *Namespace* on the request, of the incoming request. If the *Namespace* of the resource being created, or updated does not match the *Namespace* on the request,
then the k8s API server will reject the request. then the k8s API server will reject the request.
TODO: Update to discuss k8s api server proxy patterns
## k8s storage ## k8s storage
A namespace provides a unique identifier space and therefore must be in the storage path of a resource. A namespace provides a unique identifier space and therefore must be in the storage path of a resource.

View File

@ -77,7 +77,14 @@ type ProxyHandler struct {
} }
func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ctx := api.NewContext() // use the default namespace to address the service
ctx := api.NewDefaultContext()
// if not in default namespace, provide the query parameter
// TODO this will need to go in the path in the future and not as a query parameter
namespace := req.URL.Query().Get("namespace")
if len(namespace) > 0 {
ctx = api.WithNamespace(ctx, namespace)
}
parts := strings.SplitN(req.URL.Path, "/", 3) parts := strings.SplitN(req.URL.Path, "/", 3)
if len(parts) < 2 { if len(parts) < 2 {
notFound(w, req) notFound(w, req)