forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Origin-commit: 14ba1f8ece9a7bb00ececb2a35b5f8f5fbeacc83 UPSTREAM: <carry>: prevent apiservice registration by CRD controller when delegating Origin-commit: 3d216eab7adcbd8596606d72d31b6af621bfd350 UPSTREAM: <carry>: prevent CRD registration from fighting with APIServices Origin-commit: c1c87eeade4730a2271cb98b4c6ea16af07e3e68 UPSTREAM: <carry>: always delegate namespaced resources Origin-commit: 7f0815b5a88d57046a92fbdbc493bab2ad28a79c
- Loading branch information
Showing
4 changed files
with
91 additions
and
12 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 | ||
} |