mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #72898 from davidz627/fix/removeImpersonation
Remove client impersonantion from ClusterRole creation
This commit is contained in:
commit
06e1af74ef
@ -31,8 +31,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
|
||||||
restclient "k8s.io/client-go/rest"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/test/e2e/framework/testfiles"
|
"k8s.io/kubernetes/test/e2e/framework/testfiles"
|
||||||
@ -397,27 +395,9 @@ func (*clusterRoleFactory) Create(f *Framework, i interface{}) (func() error, er
|
|||||||
return nil, ItemNotSupported
|
return nil, ItemNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// Impersonation is required for Kubernetes < 1.12, see
|
Logf("Define cluster role %v", item.GetName())
|
||||||
// https://github.com/kubernetes/kubernetes/issues/62237#issuecomment-429315111
|
client := f.ClientSet.RbacV1().ClusterRoles()
|
||||||
//
|
if _, err := client.Create(item); err != nil {
|
||||||
// This code is kept even for more recent Kubernetes, because users of
|
|
||||||
// the framework outside of Kubernetes might run against an older version
|
|
||||||
// of Kubernetes. It will be deprecated eventually.
|
|
||||||
//
|
|
||||||
// TODO: is this only needed for a ClusterRole or also for other non-namespaced
|
|
||||||
// items?
|
|
||||||
Logf("Creating an impersonating superuser kubernetes clientset to define cluster role")
|
|
||||||
rc, err := LoadConfig()
|
|
||||||
ExpectNoError(err)
|
|
||||||
rc.Impersonate = restclient.ImpersonationConfig{
|
|
||||||
UserName: "superuser",
|
|
||||||
Groups: []string{"system:masters"},
|
|
||||||
}
|
|
||||||
superuserClientset, err := clientset.NewForConfig(rc)
|
|
||||||
ExpectNoError(err, "create superuser clientset")
|
|
||||||
|
|
||||||
client := superuserClientset.RbacV1().ClusterRoles()
|
|
||||||
if _, err = client.Create(item); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "create ClusterRole")
|
return nil, errors.Wrap(err, "create ClusterRole")
|
||||||
}
|
}
|
||||||
return func() error {
|
return func() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user