|
| 1 | +# Strategies |
| 2 | + |
| 3 | +Each destination in the Reloader configuration supports three optional strategies that control how updates are applied, how secrets are matched, and how the Reloader waits between reconciliations. |
| 4 | + |
| 5 | +When not specified, sensible defaults are used per destination type. See [Deployments](../destinations/deployments.md), [ExternalSecrets](../destinations/external-secrets.md), [PushSecrets](../destinations/push-secrets.md), and [WorkflowRunTemplate](../destinations/workflows.md) for their respective defaults. |
| 6 | + |
| 7 | +## Update Strategy |
| 8 | + |
| 9 | +The Update Strategy controls what action the Reloader takes when a matching event arrives. |
| 10 | + |
| 11 | +### Operations |
| 12 | + |
| 13 | +| Operation | Description | |
| 14 | +|---------------|-----------------------------------------------------------------------------| |
| 15 | +| `PatchStatus` | Patches the status subresource of the destination object. | |
| 16 | +| `Patch` | Patches the destination object at a custom path with a given template. | |
| 17 | +| `Delete` | Deletes the destination object entirely. | |
| 18 | + |
| 19 | +### Example: Custom Patch |
| 20 | + |
| 21 | +```yaml |
| 22 | +destinationsToWatch: |
| 23 | + - type: Deployment |
| 24 | + deployment: |
| 25 | + labelSelectors: |
| 26 | + matchLabels: |
| 27 | + app: my-app |
| 28 | + updateStrategy: |
| 29 | + operation: Patch |
| 30 | + patchOperationConfig: |
| 31 | + path: "/spec/template/metadata/annotations" |
| 32 | + template: '{"reloader.external-secrets.io/rotated-at": "{{ .Timestamp }}"}' |
| 33 | +``` |
| 34 | +
|
| 35 | +### Example: Delete on Event |
| 36 | +
|
| 37 | +```yaml |
| 38 | +destinationsToWatch: |
| 39 | + - type: ExternalSecret |
| 40 | + externalSecret: |
| 41 | + names: |
| 42 | + - my-external-secret |
| 43 | + updateStrategy: |
| 44 | + operation: Delete |
| 45 | +``` |
| 46 | +
|
| 47 | +## Match Strategy |
| 48 | +
|
| 49 | +The Match Strategy controls how the Reloader determines whether a destination is affected by a given secret event. It evaluates a JSON path on the destination object against one or more conditions. |
| 50 | +
|
| 51 | +### Condition Operations |
| 52 | +
|
| 53 | +| Operation | Description | |
| 54 | +|---------------------|------------------------------------------------| |
| 55 | +| `Equal` | Exact value match. | |
| 56 | +| `NotEqual` | Value does not match. | |
| 57 | +| `Contains` | Value contains the given substring. | |
| 58 | +| `NotContains` | Value does not contain the given substring. | |
| 59 | +| `RegularExpression` | Value matches the given regular expression. | |
| 60 | + |
| 61 | +### Example: Custom Match Path |
| 62 | + |
| 63 | +```yaml |
| 64 | +destinationsToWatch: |
| 65 | + - type: Deployment |
| 66 | + deployment: |
| 67 | + labelSelectors: |
| 68 | + matchLabels: {} |
| 69 | + matchStrategy: |
| 70 | + path: "spec.template.spec.containers[*].env[*].valueFrom.secretKeyRef.name" |
| 71 | + conditions: |
| 72 | + - value: "my-secret" |
| 73 | + operation: Equal |
| 74 | +``` |
| 75 | + |
| 76 | +### Example: Regex Match |
| 77 | + |
| 78 | +```yaml |
| 79 | +destinationsToWatch: |
| 80 | + - type: ExternalSecret |
| 81 | + externalSecret: |
| 82 | + labelSelectors: |
| 83 | + matchLabels: {} |
| 84 | + matchStrategy: |
| 85 | + path: "spec.dataFrom.find.name.regexp" |
| 86 | + conditions: |
| 87 | + - value: "prod/.*" |
| 88 | + operation: RegularExpression |
| 89 | +``` |
| 90 | + |
| 91 | +## Wait Strategy |
| 92 | + |
| 93 | +The Wait Strategy controls how the Reloader waits between reconciling multiple destination objects. This is useful to avoid overwhelming the cluster with simultaneous rollouts. |
| 94 | + |
| 95 | +Two modes are available: time-based and condition-based. They can be used independently or together. |
| 96 | + |
| 97 | +### Time-Based Wait |
| 98 | + |
| 99 | +Waits for a fixed duration before reconciling the next object. |
| 100 | + |
| 101 | +```yaml |
| 102 | +destinationsToWatch: |
| 103 | + - type: Deployment |
| 104 | + deployment: |
| 105 | + labelSelectors: |
| 106 | + matchLabels: {} |
| 107 | + waitStrategy: |
| 108 | + time: 30s |
| 109 | +``` |
| 110 | + |
| 111 | +### Condition-Based Wait |
| 112 | + |
| 113 | +Waits until a specific condition is met on the destination object before moving to the next one. Supports retry logic with configurable timeout and maximum retries. |
| 114 | + |
| 115 | +```yaml |
| 116 | +destinationsToWatch: |
| 117 | + - type: Deployment |
| 118 | + deployment: |
| 119 | + labelSelectors: |
| 120 | + matchLabels: {} |
| 121 | + waitStrategy: |
| 122 | + condition: |
| 123 | + type: Available |
| 124 | + status: "True" |
| 125 | + retryTimeout: 10s |
| 126 | + maxRetries: 18 |
| 127 | +``` |
| 128 | + |
| 129 | +In this example, the Reloader waits for the `Available` condition to be `True` before proceeding, checking every 10 seconds up to 18 times (3 minutes total). |
| 130 | + |
| 131 | +### Condition Fields |
| 132 | + |
| 133 | +| Field | Description | Required | |
| 134 | +|--------------------|--------------------------------------------------------------------------|----------| |
| 135 | +| `type` | The name of the condition to wait for. | Yes | |
| 136 | +| `status` | The expected status of the condition. | No | |
| 137 | +| `message` | Optional message to match. | No | |
| 138 | +| `reason` | Optional reason to match. | No | |
| 139 | +| `retryTimeout` | Period to wait before each retry. | No | |
| 140 | +| `maxRetries` | Maximum number of retries for the condition. | No | |
| 141 | +| `transitionedAfter`| Only accept this condition after a given period from the transition time. | No | |
| 142 | +| `updatedAfter` | Only accept this condition after a given period from the update time. | No | |
| 143 | + |
| 144 | +### Example: Wait for Fresh Condition |
| 145 | + |
| 146 | +```yaml |
| 147 | +waitStrategy: |
| 148 | + condition: |
| 149 | + type: Available |
| 150 | + status: "True" |
| 151 | + transitionedAfter: 5s |
| 152 | + retryTimeout: 10s |
| 153 | + maxRetries: 30 |
| 154 | +``` |
| 155 | + |
| 156 | +This ensures the `Available` condition was set at least 5 seconds ago, avoiding stale conditions from a previous rollout. |
0 commit comments