postgres-operator
postgres-operator copied to clipboard
Manual switchover via operator
Please, answer some short questions which should help us to understand your problem / question better?
- Which image of the operator are you using? registry.opensource.zalan.do/acid/postgres-operator:v1.8.2
- Where do you run it - cloud or metal? Kubernetes or OpenShift? Bare Metal K8s
- Are you running Postgres Operator in production? no
- Type of issue? question
Does the operator support manual swithover? I know that I can enter in pod and run switchover via patronictl. But it may be convenient and useful to be able to do a switchover using an operator, for example, through an endpoint annotation.
You can indeed add the annotation zalando-postgres-operator-rolling-update-required: true
to the pods and the operator will discover it on next sync and think it has to do a rolling update.
Thank you very much @FxKu! This workaround sounds good. But is there a way to force operator run sync operation early? For example via send a request to service postgres-operator.
Only by deleting the operator pod you can force a sync of all clusters.
Thank you very much @FxKu for your answers! Could you give me advise please.
I want to try make a PR with switchover functionality via operator. How do you think is it possible to realise it with the next approach?
- Add optional section in spec section of kind: postgresql manifest spec: patroni: switchover: enabled: true targetInstance: acid-test-cluster-1 This enable swithcover functionality via operator for our postgresql cluster and set target instance for promoting. Operator will be looking for the trigger in cluster's annotation to perform a switchover.
- When we need make swithover we need to add annotation for our postgresql cluster: kubectl annotate postgresql acid-test-cluster acid.zalan.do/swithcover="$(date)"
- After that we need to delete operator's pod for trigger sync operation.
- Pod make sync. Detect switchover annotation and make switchover via patroni api.
- After that we disable switchover section in cluster's spec.
You can indeed add the annotation
zalando-postgres-operator-rolling-update-required: true
to the pods and the operator will discover it on next sync and think it has to do a rolling update.
Is it recommended to remove annotation after rollout?
I noticed that when the annotation is removed, another rollout happens. I also saw that regardless of the true
or false
value, the rollout happens, is this expected?