---
title: PushSecret Update Policy
version: v1alpha1
authors: Moritz Johner
creation-date: 2023-08-25
status: partially implemented
---
// autogen please
The PushSecret update procedure needs to be configurable so users can control its behaviour.
The motivation is to enhance the configurability of the PushSecret lifecycle within the External Secrets Operator (ESO). Currently, there is a need for users to have more control over the behavior of PushSecret when updating values at the secret provider.
The use-case for updatePolicy is the following: Users would like to use ESO generate a password and store it in an external store. Once the password is generated and pushed, they want the secret store to become the source of truth, so that the password won't be overridden when ExternalSecret or Secret Resources are deleted and/or regenerated.
More context in #2643.
When ESO intends to push a secret to the provider, several cases need to be considered for managing the lifecycle:
This design document concerns the second point.
The PushSecret lifecycle consists of these 3 parts:
spec.refreshIntervalFor each part we can apply a policy. For this design document the update part is relevant. The following flowchart illustrates the decision-making process:
flowchart TD
C{Create} --> |no policy here| F{Update}
F -->|updatePolicy=Replace| G[Always overrides the existing value]
F -->|updatePolicy=IfNotExists| H[Writes the value only\n if no value exists]
G --> F
H --> F
G --> I{Delete}
H --> I{Delete}
I --> |deletionPolicy=Delete| J[Deletes the secret]
I --> |deletionPolicy=None| K[Retains the existing secret]
The proposed solution is to introduce an updatePolicy field within the PushSecret specification. This field allows users to configure the behavior of updates during the PushSecret lifecycle.
By default, the value of updatePolicy is set to Replace, meaning that the existing value will always be overridden. Alternatively, users can set the value to IfNotExists, which prevents a write operation if a value already exists.
apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
name: pushsecret-example
namespace: default
spec:
updatePolicy: Replace # Replace (default) or IfNotExists
# ...
For the future we can consider adding more policies like Merge of needed.
not implemented error if specified but not implementedSecretAlreadyExists (as a pair of SecretSynced, SecretDeleted ) to indicate it.updatePolicy
updatePolicy breaks idempotency contracts, and that it should be used with care by the user.