A controlled restart of a StackGres cluster can be performed declaratively through SGDbOps. This is useful when configuration changes require a Pod restart to take effect, or when you need to perform a rolling restart of the cluster for maintenance purposes.
Since the SGCluster version is now updated on any restart, the
restartandsecurityUpgradeSGDbOps operations are logically equivalent. You can also perform this operation without creating an SGDbOps by using the rollout functionality, which allows the operator to automatically roll out Pod updates based on the cluster’s update strategy.
The restart operation supports two methods:
| Method | Description |
|---|---|
InPlace |
Restarts each Pod in the existing cluster one at a time. Does not require additional resources but causes longer service disruption when only a single instance is present. |
ReducedImpact |
Creates a new updated replica before restarting existing Pods. Requires additional resources to spawn the temporary replica but minimizes downtime. Recommended for production environments. |
Perform a rolling restart using the reduced impact method:
apiVersion: stackgres.io/v1
kind: SGDbOps
metadata:
name: restart-cluster
spec:
sgCluster: my-cluster
op: restart
restart:
method: ReducedImpact
To restart only the Pods that have pending configuration changes:
apiVersion: stackgres.io/v1
kind: SGDbOps
metadata:
name: restart-pending
spec:
sgCluster: my-cluster
op: restart
restart:
method: ReducedImpact
onlyPendingRestart: true
When onlyPendingRestart is set to true, only Pods detected as needing a restart will be restarted. By default (false), all Pods in the cluster are restarted.
| Option | Type | Default | Description |
|---|---|---|---|
method |
string | - | The restart method: InPlace or ReducedImpact. |
onlyPendingRestart |
boolean | false |
If true, restarts only Pods that are in pending restart state. |
After creating the SGDbOps resource, you can monitor the progress:
kubectl get sgdbops restart-cluster -w
The operation status is tracked in SGDbOps.status.conditions. When the operation completes successfully, the status will show Completed.