Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lazy rest mapper for performance and less audit #116

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
)

// NewRESTConfig returns a rest config given a secret with connection information.
Expand All @@ -33,7 +34,14 @@ func NewRESTConfig(kubeconfig []byte) (*rest.Config, error) {
// NewKubeClient returns a kubernetes client given a secret with connection
// information.
func NewKubeClient(config *rest.Config) (client.Client, error) {
kc, err := client.New(config, client.Options{})
// in 0.15 this will be default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merged a bump PR which updates controller runtime to v0.15.1, does this mean we no longer need the changes here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapper, err := apiutil.NewDynamicRESTMapper(config, apiutil.WithExperimentalLazyMapper)
if err != nil {
return nil, errors.Wrap(err, "cannot create dynamic REST mapper for Kubernetes client")
}
kc, err := client.New(config, client.Options{
Mapper: mapper,
})
if err != nil {
return nil, errors.Wrap(err, "cannot create Kubernetes client")
}
Expand Down