Skip to content

Commit

Permalink
Update the docs with a section regarding the cache usage
Browse files Browse the repository at this point in the history
Signed-off-by: Soule BA <soule@weave.works>
  • Loading branch information
souleb committed Mar 31, 2022
1 parent 15ab075 commit e561349
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions docs/spec/v1beta2/helmcharts.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,53 @@ Besides being reported in Events, the reconciliation errors are also logged by
the controller. The Flux CLI offer commands for filtering the logs for a
specific HelmChart, e.g. `flux logs --level=error --kind=HelmChart --name=<chart-name>`.

### Improving resource consumption by enabling the cache

When using a `HelmRepository` as Source for a `HelmChart`, the controller loads
the repository index in-memory to find the latest version chart.

The controller can be configured to cache a Helm repository indexes in-memory.
The cache is used to avoid loading repository indexes for every Helm chart
reconciliation.

Three fields are provided to enable and configure the cache:
- `helm-cache-max-size`: The maximum size of the cache in number of indexes.
If `0`, then the cache is disabled.
- `helm-cache-ttl`: The TTL of an index in the cache.
- `helm-cache-purge-interval`: The interval at which the cache is purged of
expired items.

The caching strategy is to pull a repository index from the cache if it is
available, otherwise to load the index, retrieve and build the chart,
then cache the index. The cached index TTL is refreshed every time the
Helm repository index is loaded with the `helm-cache-ttl` value.

The cache is purged of expired items every `helm-cache-purge-interval`.

When the cache is full, no more items can be added to the cache, and the
source-controller will report a warning event instead.

In order to use the cache, set the related flags in the source-controller
Deployment config:

```yaml
spec:
containers:
- args:
- --watch-all-namespaces
- --log-level=info
- --log-encoding=json
- --enable-leader-election
- --storage-path=/data
- --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.cluster.local.
## Helm cache with up to 10 items, i.e. 10 indexes.
- --helm-cache-max-size=10
## TTL of an index is 1 hour.
- --helm-cache-ttl=1h
## Purge expired index every 10 minutes.
- --helm-cache-purge-interval=10m
```

## HelmChart Status

### Artifact
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func main() {
flag.DurationVar(&requeueDependency, "requeue-dependency", 30*time.Second,
"The interval at which failing dependencies are reevaluated.")
flag.IntVar(&helmCacheMaxSize, "helm-cache-max-size", 0,
"The maximum size of the cache in number of items.")
"The maximum size of the cache in number of indexes.")
flag.StringVar(&helmCacheTTL, "helm-cache-ttl", "15m",
"The TTL of an item in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
"The TTL of an index in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
flag.StringVar(&helmCachePurgeInterval, "helm-cache-purge-interval", "1m",
"The interval at which the cache is purged. Valid time units are ns, us (or µs), ms, s, m, h.")

Expand Down

0 comments on commit e561349

Please sign in to comment.