|
|
|
@@ -37,13 +37,11 @@ import (
|
|
|
|
|
restclient "k8s.io/client-go/rest"
|
|
|
|
|
"k8s.io/client-go/tools/record"
|
|
|
|
|
watchtools "k8s.io/client-go/tools/watch"
|
|
|
|
|
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
|
|
|
|
internalinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
|
|
|
|
|
"k8s.io/kubernetes/pkg/controller"
|
|
|
|
|
replicationcontroller "k8s.io/kubernetes/pkg/controller/replication"
|
|
|
|
|
resourcequotacontroller "k8s.io/kubernetes/pkg/controller/resourcequota"
|
|
|
|
|
"k8s.io/kubernetes/pkg/quota/generic"
|
|
|
|
|
quotainstall "k8s.io/kubernetes/pkg/quota/install"
|
|
|
|
|
"k8s.io/kubernetes/pkg/quota/v1/generic"
|
|
|
|
|
quotainstall "k8s.io/kubernetes/pkg/quota/v1/install"
|
|
|
|
|
"k8s.io/kubernetes/plugin/pkg/admission/resourcequota"
|
|
|
|
|
resourcequotaapi "k8s.io/kubernetes/plugin/pkg/admission/resourcequota/apis/resourcequota"
|
|
|
|
|
"k8s.io/kubernetes/test/integration/framework"
|
|
|
|
@@ -65,15 +63,14 @@ func TestQuota(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
admissionCh := make(chan struct{})
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{QPS: -1, Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
internalClientset := internalclientset.NewForConfigOrDie(&restclient.Config{QPS: -1, Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
config := &resourcequotaapi.Configuration{}
|
|
|
|
|
admission, err := resourcequota.NewResourceQuota(config, 5, admissionCh)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
admission.SetInternalKubeClientSet(internalClientset)
|
|
|
|
|
internalInformers := internalinformers.NewSharedInformerFactory(internalClientset, controller.NoResyncPeriodFunc())
|
|
|
|
|
admission.SetInternalKubeInformerFactory(internalInformers)
|
|
|
|
|
admission.SetExternalKubeClientSet(clientset)
|
|
|
|
|
internalInformers := informers.NewSharedInformerFactory(clientset, controller.NoResyncPeriodFunc())
|
|
|
|
|
admission.SetExternalKubeInformerFactory(internalInformers)
|
|
|
|
|
qca := quotainstall.NewQuotaConfigurationForAdmission()
|
|
|
|
|
admission.SetQuotaConfiguration(qca)
|
|
|
|
|
defer close(admissionCh)
|
|
|
|
@@ -257,7 +254,6 @@ func TestQuotaLimitedResourceDenial(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
admissionCh := make(chan struct{})
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{QPS: -1, Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
internalClientset := internalclientset.NewForConfigOrDie(&restclient.Config{QPS: -1, Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
|
|
|
|
|
// stop creation of a pod resource unless there is a quota
|
|
|
|
|
config := &resourcequotaapi.Configuration{
|
|
|
|
@@ -273,9 +269,9 @@ func TestQuotaLimitedResourceDenial(t *testing.T) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
admission.SetInternalKubeClientSet(internalClientset)
|
|
|
|
|
internalInformers := internalinformers.NewSharedInformerFactory(internalClientset, controller.NoResyncPeriodFunc())
|
|
|
|
|
admission.SetInternalKubeInformerFactory(internalInformers)
|
|
|
|
|
admission.SetExternalKubeClientSet(clientset)
|
|
|
|
|
externalInformers := informers.NewSharedInformerFactory(clientset, controller.NoResyncPeriodFunc())
|
|
|
|
|
admission.SetExternalKubeInformerFactory(externalInformers)
|
|
|
|
|
admission.SetQuotaConfiguration(qca)
|
|
|
|
|
defer close(admissionCh)
|
|
|
|
|
|
|
|
|
@@ -324,7 +320,7 @@ func TestQuotaLimitedResourceDenial(t *testing.T) {
|
|
|
|
|
// Periodically the quota controller to detect new resource types
|
|
|
|
|
go resourceQuotaController.Sync(discoveryFunc, 30*time.Second, controllerCh)
|
|
|
|
|
|
|
|
|
|
internalInformers.Start(controllerCh)
|
|
|
|
|
externalInformers.Start(controllerCh)
|
|
|
|
|
informers.Start(controllerCh)
|
|
|
|
|
close(informersStarted)
|
|
|
|
|
|
|
|
|
|