Slide 43
Slide 43 text
Unstructured Objectのキャッシュを有効化するには
CacheUnstructuredオプションを有効化する必要がある
func NewCustomDelegatingClient(
cache cache.Cache,
config *rest.Config,
options client.Options,
uncachedObjects ...client.Object
) (client.Client, error) {
c, err := client.New(config, options)
if err != nil {
return nil, err
}
return client.NewDelegatingClient(client.NewDelegatingClientInput{
CacheReader: cache,
Client: c,
UncachedObjects: uncachedObjects,
CacheUnstructured: true // enable caching for unstructured objects
})
}
func main() {
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
NewClient: NewCustomDelegatingClient,
…
})
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}
}