nginxinc / nginx-gateway-fabric

NGINX Gateway Fabric provides an implementation for the Gateway API using NGINX as the data plane.
Apache License 2.0
472 stars 91 forks source link

Refactor ConfigMap and Secret resolvers and use `controller.WithOnlyMetadata` predicate #1545

Open ciarams87 opened 7 months ago

ciarams87 commented 7 months ago

Currently, we cache all the Secrets in the cluster., and ConfigMaps when the experimental Gateway API features are enabled, in NGF. This can lead to unnecessary memory consumption, as we only need to store any referenced resources. A better approach would be to use the controller.WithOnlyMetadata() predicate and then fetch the required resources when they are referenced.

Additionally, the secret and configmap resolvers are in the graph package, but we have a resolver package which would be more logical for them to reside. There's also an opportunity for the resolvers to be refactored to deduplicate functionality. Moving the resolvers to the resolver package also simplifies passing the k8s client to the resolvers, which is required when using the controller.WithOnlyMetadata predicate as the referenced resources need to be fetched from the API by the resolver.

AC:

pleshakov commented 6 months ago

Related to https://github.com/nginxinc/nginx-gateway-fabric/pull/1487 Related to https://github.com/nginxinc/nginx-gateway-fabric/issues/1425

mpstefan commented 3 months ago

Placing this into the backlog unless there's a strong reason to include it within a near-future release.