forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPSTREAM: <carry>: patch aggregator to allow delegating resources
UPSTREAM: <carry>: prevent apiservice registration by CRD controller when delegating UPSTREAM: <carry>: prevent CRD registration from fighting with APIServices UPSTREAM: <carry>: always delegate namespaced resources OpenShift-Rebase-Source: d4cd0ba
- Loading branch information
1 parent
58c4cee
commit df77b1f
Showing
4 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
staging/src/k8s.io/kube-aggregator/pkg/apiserver/patch_always_local_delegate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package apiserver | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
) | ||
|
||
// alwaysLocalDelegatePrefixes specify a list of API paths that we want to delegate to Kubernetes API server | ||
// instead of handling with OpenShift API server. | ||
var alwaysLocalDelegatePathPrefixes = sets.NewString() | ||
|
||
// AddAlwaysLocalDelegateForPrefix will cause the given URL prefix always be served by local API server (kube apiserver). | ||
// This allows to move some resources from aggregated API server into CRD. | ||
func AddAlwaysLocalDelegateForPrefix(prefix string) { | ||
if alwaysLocalDelegatePathPrefixes.Has(prefix) { | ||
return | ||
} | ||
alwaysLocalDelegatePathPrefixes.Insert(prefix) | ||
} | ||
|
||
var overlappingGroupVersion = map[schema.GroupVersion]bool{} | ||
|
||
// AddOverlappingGroupVersion will stop the CRD registration controller from trying to manage an APIService. | ||
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 | ||
} | ||
|
||
testPrefix := fmt.Sprintf("/apis/%s/%s/", groupVersion.Group, groupVersion.Version) | ||
for _, prefix := range alwaysLocalDelegatePathPrefixes.List() { | ||
if strings.HasPrefix(prefix, testPrefix) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |