Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85099 from liggitt/quota-config-v1
Promote apiserver.config.k8s.io/v1, kind=ResourceQuotaConfiguration
- Loading branch information
Showing
16 changed files
with
616 additions
and
17 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
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
41 changes: 41 additions & 0 deletions
41
plugin/pkg/admission/resourcequota/apis/resourcequota/v1/BUILD
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,41 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"@io_bazel_rules_go//go:def.bzl", | ||
"go_library", | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"defaults.go", | ||
"doc.go", | ||
"register.go", | ||
"types.go", | ||
"zz_generated.conversion.go", | ||
"zz_generated.deepcopy.go", | ||
"zz_generated.defaults.go", | ||
], | ||
importpath = "k8s.io/kubernetes/plugin/pkg/admission/resourcequota/apis/resourcequota/v1", | ||
deps = [ | ||
"//plugin/pkg/admission/resourcequota/apis/resourcequota:go_default_library", | ||
"//staging/src/k8s.io/api/core/v1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", | ||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
) |
25 changes: 25 additions & 0 deletions
25
plugin/pkg/admission/resourcequota/apis/resourcequota/v1/defaults.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,25 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import kruntime "k8s.io/apimachinery/pkg/runtime" | ||
|
||
func addDefaultingFuncs(scheme *kruntime.Scheme) error { | ||
return RegisterDefaults(scheme) | ||
} | ||
|
||
func SetDefaults_Configuration(obj *Configuration) {} |
23 changes: 23 additions & 0 deletions
23
plugin/pkg/admission/resourcequota/apis/resourcequota/v1/doc.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,23 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// +k8s:deepcopy-gen=package | ||
// +k8s:conversion-gen=k8s.io/kubernetes/plugin/pkg/admission/resourcequota/apis/resourcequota | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=resourcequota.admission.k8s.io | ||
|
||
// Package v1 is the v1 version of the API. | ||
package v1 // import "k8s.io/kubernetes/plugin/pkg/admission/resourcequota/apis/resourcequota/v1" |
51 changes: 51 additions & 0 deletions
51
plugin/pkg/admission/resourcequota/apis/resourcequota/v1/register.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,51 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GroupName is the group name use in this package | ||
const GroupName = "apiserver.config.k8s.io" | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} | ||
|
||
var ( | ||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. | ||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. | ||
|
||
// SchemeBuilder is a pointer used to call AddToScheme | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
// AddToScheme is used to register the types to API encoding/decoding machinery | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
// We only register manually written functions here. The registration of the | ||
// generated functions takes place in the generated files. The separation | ||
// makes the code compile even when the generated files are missing. | ||
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) | ||
} | ||
|
||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("ResourceQuotaConfiguration"), &Configuration{}) | ||
return nil | ||
} |
69 changes: 69 additions & 0 deletions
69
plugin/pkg/admission/resourcequota/apis/resourcequota/v1/types.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,69 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
"k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Configuration provides configuration for the ResourceQuota admission controller. | ||
type Configuration struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// LimitedResources whose consumption is limited by default. | ||
// +optional | ||
LimitedResources []LimitedResource `json:"limitedResources"` | ||
} | ||
|
||
// LimitedResource matches a resource whose consumption is limited by default. | ||
// To consume the resource, there must exist an associated quota that limits | ||
// its consumption. | ||
type LimitedResource struct { | ||
|
||
// APIGroup is the name of the APIGroup that contains the limited resource. | ||
// +optional | ||
APIGroup string `json:"apiGroup,omitempty"` | ||
|
||
// Resource is the name of the resource this rule applies to. | ||
// For example, if the administrator wants to limit consumption | ||
// of a storage resource associated with persistent volume claims, | ||
// the value would be "persistentvolumeclaims". | ||
Resource string `json:"resource"` | ||
|
||
// For each intercepted request, the quota system will evaluate | ||
// its resource usage. It will iterate through each resource consumed | ||
// and if the resource contains any substring in this listing, the | ||
// quota system will ensure that there is a covering quota. In the | ||
// absence of a covering quota, the quota system will deny the request. | ||
// For example, if an administrator wants to globally enforce that | ||
// that a quota must exist to consume persistent volume claims associated | ||
// with any storage class, the list would include | ||
// ".storageclass.storage.k8s.io/requests.storage" | ||
MatchContains []string `json:"matchContains,omitempty"` | ||
// For each intercepted request, the quota system will figure out if the input object | ||
// satisfies a scope which is present in this listing, then | ||
// quota system will ensure that there is a covering quota. In the | ||
// absence of a covering quota, the quota system will deny the request. | ||
// For example, if an administrator wants to globally enforce that | ||
// a quota must exist to create a pod with "cluster-services" priorityclass | ||
// the list would include "scopeName=PriorityClass, Operator=In, Value=cluster-services" | ||
// +optional | ||
MatchScopes []v1.ScopedResourceSelectorRequirement `json:"matchScopes,omitempty"` | ||
} |
Oops, something went wrong.