Skip to content

Commit 435359b

Browse files
committed
Update the docs with a section regarding the cache usage
Signed-off-by: Soule BA <soule@weave.works>
1 parent 15ab075 commit 435359b

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

docs/spec/v1beta2/helmcharts.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,54 @@ Besides being reported in Events, the reconciliation errors are also logged by
390390
the controller. The Flux CLI offer commands for filtering the logs for a
391391
specific HelmChart, e.g. `flux logs --level=error --kind=HelmChart --name=<chart-name>`.
392392

393+
### Improving Resource Consumption Using The Cache
394+
395+
When using a Helm Repository as source for a Helm chart and dependencies, the
396+
controller loads the Helm Repository index in-memory to find the latest version
397+
of the chart.
398+
399+
The controller can be configured to cache a Helm Repository indexes in-memory.
400+
The cache is used to avoid loading Helm Repository indexes for every Helm chart
401+
reconciliation.
402+
403+
Three fields are provided to enable and configure the cache:
404+
- `helm-cache-max-size`: The maximum size of the cache in number of indexes.
405+
If `0`, then the cache is disabled.
406+
- `helm-cache-ttl`: The TTL of an index in the cache.
407+
- `helm-cache-purge-interval`: The interval at which the cache is purged of
408+
expired items.
409+
410+
The caching strategy is to pull a Helm Repository index from the cache if it is
411+
available, otherwise to load the index, to retrieve and build the chart,
412+
then cache the index. The cached index ttl is refreshed every time the
413+
Helm Repository index is loaded with the `helm-cache-ttl` value.
414+
415+
The cache is purged of expired items every `helm-cache-purge-interval`.
416+
417+
When the cache is full, no more items can be added to the cache, the
418+
source-controller will report a warning event instead.
419+
420+
In order to use the cache, set the related flags in the source-controller
421+
deployment config:
422+
423+
```yaml
424+
spec:
425+
containers:
426+
- args:
427+
- --watch-all-namespaces
428+
- --log-level=info
429+
- --log-encoding=json
430+
- --enable-leader-election
431+
- --storage-path=/data
432+
- --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.cluster.local.
433+
## Helm Cache with up to 10 items, i.e. 10 indexes.
434+
- --helm-cache-max-size=10
435+
## TTL of an index is 1 hour.
436+
- --helm-cache-ttl=1h
437+
## Purge expired index every 10 minutes.
438+
- --helm-cache-purge-interval=10m
439+
```
440+
393441
## HelmChart Status
394442

395443
### Artifact

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ func main() {
115115
flag.DurationVar(&requeueDependency, "requeue-dependency", 30*time.Second,
116116
"The interval at which failing dependencies are reevaluated.")
117117
flag.IntVar(&helmCacheMaxSize, "helm-cache-max-size", 0,
118-
"The maximum size of the cache in number of items.")
118+
"The maximum size of the cache in number of indexes.")
119119
flag.StringVar(&helmCacheTTL, "helm-cache-ttl", "15m",
120-
"The TTL of an item in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
120+
"The TTL of an index in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
121121
flag.StringVar(&helmCachePurgeInterval, "helm-cache-purge-interval", "1m",
122122
"The interval at which the cache is purged. Valid time units are ns, us (or µs), ms, s, m, h.")
123123

0 commit comments

Comments
 (0)