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

Conversation

chlunde
Copy link
Contributor

@chlunde chlunde commented May 8, 2023

Description of your changes

provider-kubernetes initialized a new kubernetes client for each
reconcile. The REST mapper in controller-runtime used to fetch
information about every CRD in the cluster.

controller-runtime introduced a lazy restmapper which means we don't
have to introduce any complex caching to get a significant performance
boost in provider-kubernetes:

kubernetes-sigs/controller-runtime#2116

This seems to become the default in the next release:

kubernetes-sigs/controller-runtime#2296

But this is so significant that we want to update now:

  • CPU reduced from constant throttling at 0.4 cores to 0.04 cores

  • CloudWatch / EKS audit log costs reduced significantly (55% for our
    cluster, with a lot of provider-kubernetes resources)

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Run in cluster

provider-kubernetes initialized a new kubernetes client for each
reconcile. The REST mapper in controller-runtime used to fetch
information about every CRD in the cluster.

controller-runtime introduced a lazy restmapper which means we don't
have to introduce any complex caching to get a significant performance
boost in provider-kubernetes:

kubernetes-sigs/controller-runtime#2116

This seems to become the default in the next release:

kubernetes-sigs/controller-runtime#2296

But this is so significant that we want to update now:

* CPU reduced from constant throttling at 0.4 cores to 0.04 cores

* CloudWatch / EKS audit log costs reduced significantly (55% for our
  cluster, with a lot of provider-kubernetes resources)

Signed-off-by: Carl Henrik Lunde <[email protected]>
@chlunde
Copy link
Contributor Author

chlunde commented Jun 26, 2023

@morningspace could you take a look at this? Thanks!

@@ -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.

@chlunde chlunde closed this Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants