Skip to content

Commit ceefb36

Browse files
authored
Merge pull request #1324 from fluxcd/backport-1323-to-release/v1.4.x
[release/v1.4.x] Add recommended settings for production environments
2 parents 1ba110d + db72db6 commit ceefb36

File tree

2 files changed

+73
-10
lines changed

2 files changed

+73
-10
lines changed

docs/spec/v2/helmreleases.md

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ metadata:
2020
name: podinfo
2121
namespace: default
2222
spec:
23-
interval: 5m
23+
interval: 15m
2424
url: https://stefanprodan.github.io/podinfo
2525
---
2626
apiVersion: helm.toolkit.fluxcd.io/v2
@@ -29,7 +29,7 @@ metadata:
2929
name: podinfo
3030
namespace: default
3131
spec:
32-
interval: 10m
32+
interval: 15m
3333
timeout: 5m
3434
chart:
3535
spec:
@@ -1090,12 +1090,13 @@ matches the desired state.
10901090

10911091
After successfully reconciling the object, the controller requeues it for
10921092
inspection at the specified interval. The value must be in a [Go recognized
1093-
duration string format](https://pkg.go.dev/time#ParseDuration), e.g. `10m0s`
1094-
to reconcile the object every ten minutes.
1093+
duration string format](https://pkg.go.dev/time#ParseDuration), e.g. `15m0s`
1094+
to reconcile the object every fifteen minutes.
10951095

10961096
If the `.metadata.generation` of a resource changes (due to e.g. a change to
10971097
the spec) or the HelmChart revision changes (which generates a Kubernetes
1098-
Event), this is handled instantly outside the interval window.
1098+
Event), or a ConfigMap/Secret referenced in `valuesFrom` changes,
1099+
this is handled instantly outside the interval window.
10991100

11001101
**Note:** The controller can be configured to apply a jitter to the interval in
11011102
order to distribute the load more evenly when multiple HelmRelease objects are
@@ -1120,6 +1121,69 @@ resume.
11201121

11211122
## Working with HelmReleases
11221123

1124+
### Recommended settings
1125+
1126+
When deploying applications to production environments, it is recommended
1127+
to use OCI-based Helm charts with OCIRepository as `chartRef`, and
1128+
to configure the following fields, while adjusting them to your desires for
1129+
responsiveness:
1130+
1131+
```yaml
1132+
apiVersion: source.toolkit.fluxcd.io/v1
1133+
kind: OCIRepository
1134+
metadata:
1135+
name: webapp-chart
1136+
namespace: apps
1137+
spec:
1138+
interval: 5m # check for new versions every 5 minutes and trigger an upgrade
1139+
url: oci://ghcr.io/org/charts/webapp
1140+
secretRef:
1141+
name: registry-auth # Image pull secret with read-only access
1142+
layerSelector: # select the Helm chart layer
1143+
mediaType: "application/vnd.cncf.helm.chart.content.v1.tar+gzip"
1144+
operation: copy
1145+
ref:
1146+
semver: "*" # track the latest stable version
1147+
---
1148+
apiVersion: helm.toolkit.fluxcd.io/v2
1149+
kind: HelmRelease
1150+
metadata:
1151+
name: webapp
1152+
namespace: apps
1153+
spec:
1154+
releaseName: webapp
1155+
chartRef:
1156+
kind: OCIRepository
1157+
name: webapp-chart
1158+
interval: 30m # run drift detection every 30 minutes
1159+
driftDetection:
1160+
mode: enabled # undo kubectl edits and other unintended changes
1161+
install:
1162+
strategy:
1163+
name: RetryOnFailure # retry failed installations instead of uninstalling
1164+
retryInterval: 5m # retry failed installations every five minutes
1165+
upgrade:
1166+
crds: CreateReplace # update CRDs when upgrading
1167+
strategy:
1168+
name: RetryOnFailure # retry failed upgrades instead of rollback
1169+
retryInterval: 5m # retry failed upgrades every five minutes
1170+
# All ConfigMaps and Secrets referenced in valuesFrom should
1171+
# be labelled with `reconcile.fluxcd.io/watch: Enabled`
1172+
valuesFrom:
1173+
- kind: ConfigMap
1174+
name: webapp-values
1175+
- kind: Secret
1176+
name: webapp-secret-values
1177+
```
1178+
1179+
Note that the `RetryOnFailure` strategy is suitable for statefulsets
1180+
and other workloads that cannot tolerate rollbacks and have a high rollout duration
1181+
susceptible to health check timeouts and transient capacity errors.
1182+
1183+
For stateless workloads and applications that can tolerate rollbacks, the
1184+
`RemediateOnFailure` strategy may be more suitable, as it will ensure that
1185+
the last known good state is restored in case of a failure.
1186+
11231187
### Configuring failure handling
11241188

11251189
From time to time, a Helm installation, upgrade, or accompanying [Helm test](#test-configuration)
@@ -1190,7 +1254,7 @@ metadata:
11901254
name: my-operator
11911255
namespace: default
11921256
spec:
1193-
interval: 10m
1257+
interval: 15m
11941258
chart:
11951259
spec:
11961260
chart: my-operator
@@ -1278,7 +1342,7 @@ metadata:
12781342
namespace: webapp
12791343
spec:
12801344
serviceAccountName: webapp-reconciler
1281-
interval: 5m
1345+
interval: 15m
12821346
chart:
12831347
spec:
12841348
chart: podinfo

internal/controller/helmrelease_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
204204
log := ctrl.LoggerFrom(ctx)
205205

206206
// Mark the resource as under reconciliation.
207-
const progressingMsg = "Fulfilling prerequisites"
208-
conditions.MarkReconciling(obj, meta.ProgressingReason, progressingMsg)
209-
conditions.MarkUnknown(obj, meta.ReadyCondition, meta.ProgressingReason, progressingMsg)
207+
// We set Ready=Unknown down below after we assess the readiness of dependencies and the source.
208+
conditions.MarkReconciling(obj, meta.ProgressingReason, "Fulfilling prerequisites")
210209
if err := patchHelper.Patch(ctx, obj, patch.WithOwnedConditions{Conditions: intreconcile.OwnedConditions}, patch.WithFieldOwner(r.FieldManager)); err != nil {
211210
return ctrl.Result{}, err
212211
}

0 commit comments

Comments
 (0)