enhancement: Use Recreate deployment strategy - #225
Conversation
ValkeyNode is a 1:1 mapping of node to pod. By default the Deployment's updateStrategy is set to RollingUpdate which will add a new pod first before removing the old one. This can create 2 pods for a ValkeyNode at once. Recreate will remove the old pod first before creating the new one. Signed-off-by: Joseph Heyburn <jdheyburn@gmail.com>
|
| Filename | Overview |
|---|---|
| internal/controller/valkeynode_resources.go | Adds Recreate deployment strategy to buildValkeyNodeDeployment to prevent two pods from coexisting for the same ValkeyNode during updates. |
Sequence Diagram
sequenceDiagram
participant Op as Operator
participant K8s as Kubernetes API
participant OldPod as Old Pod
participant NewPod as New Pod
Note over Op,NewPod: Before this PR (RollingUpdate)
Op->>K8s: Update Deployment
K8s->>NewPod: Create new pod
NewPod-->>K8s: Running
K8s->>OldPod: Terminate old pod
Note over OldPod,NewPod: ⚠️ Both pods exist simultaneously
Note over Op,NewPod: After this PR (Recreate)
Op->>K8s: Update Deployment
K8s->>OldPod: Terminate old pod
OldPod-->>K8s: Terminated
K8s->>NewPod: Create new pod
NewPod-->>K8s: Running
Note over NewPod: ✅ Only one pod at a time
Reviews (2): Last reviewed commit: "enhancement: Use Recreate deployment str..." | Re-trigger Greptile
Ah, yes, this is probably better! Will just testrun this and then close PR #215. |
Summary
ValkeyNode is a 1:1 mapping of node to pod. By default the Deployment's updateStrategy is set to RollingUpdate which will add a new pod first before removing the old one. This can create 2 pods for a ValkeyNode at once. Recreate will remove the old pod first before creating the new one.
Checklist
Before submitting the PR make sure the following are checked:
pre-commit run --all-filesor hooks on commit)