Skip to content

Commit

Permalink
Merge pull request kubernetes#22765 from deads2k/sally-rbr
Browse files Browse the repository at this point in the history
add RBR from CRDs

Origin-commit: a0a3b1f6f90faae6f960030136b54aa5800369cf
  • Loading branch information
k8s-publishing-bot committed May 4, 2019
2 parents 396fcfe + b3a0899 commit a9532d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"net/url"
"sync/atomic"

"k8s.io/klog"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/httpstream"
"k8s.io/apimachinery/pkg/util/httpstream/spdy"
utilnet "k8s.io/apimachinery/pkg/util/net"
Expand All @@ -36,6 +35,7 @@ import (
utilfeature "k8s.io/apiserver/pkg/util/feature"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/transport"
"k8s.io/klog"
apiregistrationapi "k8s.io/kube-aggregator/pkg/apis/apiregistration"
)

Expand Down Expand Up @@ -109,6 +109,14 @@ func (r *proxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}

// some groupResources should always be delegated
if requestInfo, ok := genericapirequest.RequestInfoFrom(req.Context()); ok {
if alwaysLocalDelegateGroupResource[schema.GroupResource{Group: requestInfo.APIGroup, Resource: requestInfo.Resource}] {
r.localDelegate.ServeHTTP(w, req)
return
}
}

if !handlingInfo.serviceAvailable {
proxyError(w, req, "service unavailable", http.StatusServiceUnavailable)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func AddOverlappingGroupVersion(groupVersion schema.GroupVersion) {
overlappingGroupVersion[groupVersion] = true
}

var alwaysLocalDelegateGroupResource = map[schema.GroupResource]bool{}

func AddAlwaysLocalDelegateGroupResource(groupResource schema.GroupResource) {
alwaysLocalDelegateGroupResource[groupResource] = true
}

func APIServiceAlreadyExists(groupVersion schema.GroupVersion) bool {
if overlappingGroupVersion[groupVersion] {
return true
Expand Down

0 comments on commit a9532d9

Please sign in to comment.