Skip to content

Commit

Permalink
add storage_resize_mode mixed to opConfig CRD (zalando#1947)
Browse files Browse the repository at this point in the history
  • Loading branch information
FxKu authored Jul 8, 2022
1 parent 5e4badd commit 1c80ac0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions charts/postgres-operator/crds/operatorconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ spec:
type: string
enum:
- "ebs"
- "mixed"
- "pvc"
- "off"
default: "pvc"
Expand Down
2 changes: 1 addition & 1 deletion charts/postgres-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ configKubernetes:
# whether the Spilo container should run with additional permissions other than parent.
# required by cron which needs setuid
spilo_allow_privilege_escalation: true
# storage resize strategy, available options are: ebs, pvc, off
# storage resize strategy, available options are: ebs, pvc, off or mixed
storage_resize_mode: pvc
# pod toleration assigned to instances of every Postgres cluster
# toleration:
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/operator_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ configuration they are grouped under the `kubernetes` key.
* **storage_resize_mode**
defines how operator handles the difference between the requested volume size and
the actual size. Available options are:
1. `ebs` : operator resizes EBS volumes directly and executes `resizefs` within a pod
2. `pvc` : operator only changes PVC definition
3. `off` : disables resize of the volumes.
4. `mixed` :operator uses AWS API to adjust size, throughput, and IOPS, and calls pvc change for file system resize
1. `ebs` : operator resizes EBS volumes directly and executes `resizefs` within a pod
2. `pvc` : operator only changes PVC definition
3. `off` : disables resize of the volumes.
4. `mixed` : operator uses AWS API to adjust size, throughput, and IOPS, and calls pvc change for file system resize
Default is "pvc".

## Kubernetes resource requests
Expand Down
39 changes: 23 additions & 16 deletions docs/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,9 @@ specified but globally disabled in the configuration. The

## Increase volume size

Postgres operator supports statefulset volume resize if you're using the
operator on top of AWS. For that you need to change the size field of the
volume description in the cluster manifest and apply the change:
Postgres operator supports statefulset volume resize without doing a rolling
update. For that you need to change the size field of the volume description
in the cluster manifest and apply the change:

```yaml
spec:
Expand All @@ -1040,22 +1040,29 @@ spec:
```

The operator compares the new value of the size field with the previous one and
acts on differences.
acts on differences. The `storage_resize_mode` can be configured. By default,
the operator will adjust the PVCs and leave it to K8s and the infrastructure to
apply the change.

You can only enlarge the volume with the process described above, shrinking is
not supported and will emit a warning. After this update all the new volumes in
the statefulset are allocated according to the new size. To enlarge persistent
volumes attached to the running pods, the operator performs the following
actions:
When using AWS with gp3 volumes you should set the mode to `mixed` because it
will also adjust the IOPS and throughput that can be defined in the manifest.
Check the [AWS docs](https://aws.amazon.com/ebs/general-purpose/) to learn
about default and maximum values. Keep in mind that AWS rate-limits updating
volume specs to no more than once every 6 hours.

* call AWS API to change the volume size

* connect to pod using `kubectl exec` and resize filesystem with `resize2fs`.
```yaml
spec:
volume:
size: 5Gi # new volume size
iops: 4000
throughput: 500
```

Fist step has a limitation, AWS rate-limits this operation to no more than once
every 6 hours. Note, that if the statefulset is scaled down before resizing the
new size is only applied to the volumes attached to the running pods. The
size of volumes that correspond to the previously running pods is not changed.
The operator can only enlarge volumes. Shrinking is not supported and will emit
a warning. However, it can be done manually after updating the manifest. You
have to delete the PVC, which will hang until you also delete the corresponding
pod. Proceed with the next pod when the cluster is healthy again and replicas
are streaming.

## Logical backups

Expand Down
1 change: 1 addition & 0 deletions manifests/operatorconfiguration.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ spec:
type: string
enum:
- "ebs"
- "mixed"
- "pvc"
- "off"
default: "pvc"
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/acid.zalan.do/v1/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
{
Raw: []byte(`"ebs"`),
},
{
Raw: []byte(`"mixed"`),
},
{
Raw: []byte(`"pvc"`),
},
Expand Down

0 comments on commit 1c80ac0

Please sign in to comment.