Skip to content

Commit

Permalink
feat(rdb): add support for read-replicas (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Aug 5, 2022
1 parent c49c798 commit 48fa817
Show file tree
Hide file tree
Showing 23 changed files with 468 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ARGS:
[project-id] Project ID to use. If none is passed the default project ID will be used
[tags.{index}] The volume tags
[volume-type] The volume type (l_ssd | b_ssd | unified)
[size] The volume disk size
[size] The volume disk size, must be a multiple of 512
[base-volume] The ID of the volume on which this volume will be based
[base-snapshot] The ID of the snapshot on which this volume will be based
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ARGS:
volume-id UUID of the volume
[name] The volume name
[tags.{index}] The tags of the volume
[size] The volume disk size
[size] The volume disk size, must be a multiple of 512
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1)

FLAGS:
Expand Down
12 changes: 10 additions & 2 deletions cmd/scw/testdata/test-all-usage-k8s-node-delete-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
This method allows to delete a specific node. Note that when there is not enough space to reschedule all the pods (in a one node cluster for instance), you may experience some disruption of your applications.

USAGE:
scw k8s node delete [arg=value ...]
scw k8s node delete <node-id ...> [arg=value ...]

EXAMPLES:
Delete a given node
scw k8s node delete 11111111-1111-1111-111111111111

Delete a given node without evicting workloads
scw k8s node delete 11111111-1111-1111-111111111111 skip-drain=true

Replace a given node by a new one
scw k8s node delete 11111111-1111-1111-111111111111 replace=true

ARGS:
node-id
node-id The ID of the node to replace
[skip-drain] Skip draining node from its workload
[replace] Add a new node after the deletion of this node
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
Expand Down
2 changes: 1 addition & 1 deletion cmd/scw/testdata/test-all-usage-k8s-node-list-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ARGS:
[pool-id] The pool ID on which to filter the returned nodes
[order-by] The sort order of the returned nodes (created_at_asc | created_at_desc)
[name] The name on which to filter the returned nodes
[status] The status on which to filter the returned nodes (unknown | creating | not_ready | ready | deleting | deleted | locked | rebooting | creation_error | upgrading | starting)
[status] The status on which to filter the returned nodes (unknown | creating | not_ready | ready | deleting | deleted | locked | rebooting | creation_error | upgrading | starting | registering)
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Create a new endpoint for a given read replica.

USAGE:
scw rdb read-replica create-endpoint <read-replica-id ...> [arg=value ...]

ARGS:
read-replica-id UUID of the read replica
[endpoint-spec.{index}.private-network.private-network-id] UUID of the private network to be connected to the read replica
[endpoint-spec.{index}.private-network.service-ip] Endpoint IPv4 adress with a CIDR notation. Check documentation about IP and subnet limitations.
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for create-endpoint

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Create a read replica.

USAGE:
scw rdb read-replica create <instance-id ...> [arg=value ...]

ARGS:
instance-id UUID of the instance you want a read replica of
[endpoint-spec.{index}.private-network.private-network-id] UUID of the private network to be connected to the read replica
[endpoint-spec.{index}.private-network.service-ip] Endpoint IPv4 adress with a CIDR notation. Check documentation about IP and subnet limitations.
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for create

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Delete a read replica.

USAGE:
scw rdb read-replica delete <read-replica-id ...> [arg=value ...]

ARGS:
read-replica-id UUID of the read replica
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for delete

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-rdb-read-replica-get-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get a read replica.

USAGE:
scw rdb read-replica get <read-replica-id ...> [arg=value ...]

ARGS:
read-replica-id UUID of the read replica
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for get

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Reset a read replica.

USAGE:
scw rdb read-replica reset <read-replica-id ...> [arg=value ...]

ARGS:
read-replica-id UUID of the read replica
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for reset

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
11 changes: 10 additions & 1 deletion cmd/scw/testdata/test-all-usage-rdb-read-replica-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
A read replica is a live copy of the main database instance only available for reading. Read replica allows you to scale your database instance for read-heavy database workloads. Read replicas can also be used for Business Intelligence workloads.

USAGE:
scw rdb read-replica
scw rdb read-replica <command>

AVAILABLE COMMANDS:
create Create a read replica
create-endpoint Create a new endpoint for a given read replica
delete Delete a read replica
get Get a read replica
reset Reset a read replica

FLAGS:
-h, --help help for read-replica
Expand All @@ -13,3 +20,5 @@ GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use

Use "scw rdb read-replica [command] --help" for more information about a command.
4 changes: 2 additions & 2 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,7 @@ scw instance volume create [arg=value ...]
| project-id | | Project ID to use. If none is passed the default project ID will be used |
| tags.{index} | | The volume tags |
| volume-type | One of: `l_ssd`, `b_ssd`, `unified` | The volume type |
| size | | The volume disk size |
| size | | The volume disk size, must be a multiple of 512 |
| base-volume | | The ID of the volume on which this volume will be based |
| base-snapshot | | The ID of the snapshot on which this volume will be based |
| organization-id | | Organization ID to use. If none is passed the default organization ID will be used |
Expand Down Expand Up @@ -2411,7 +2411,7 @@ scw instance volume update <volume-id ...> [arg=value ...]
| volume-id | Required | UUID of the volume |
| name | | The volume name |
| tags.{index} | | The tags of the volume |
| size | | The volume disk size |
| size | | The volume disk size, must be a multiple of 512 |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1` | Zone to target. If none is passed will use default zone from the config |


Expand Down
18 changes: 15 additions & 3 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,17 @@ This method allows to delete a specific node. Note that when there is not enough
**Usage:**

```
scw k8s node delete [arg=value ...]
scw k8s node delete <node-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| node-id | Required | |
| node-id | Required | The ID of the node to replace |
| skip-drain | | Skip draining node from its workload |
| replace | | Add a new node after the deletion of this node |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |


Expand All @@ -556,6 +558,16 @@ Delete a given node
scw k8s node delete 11111111-1111-1111-111111111111
```

Delete a given node without evicting workloads
```
scw k8s node delete 11111111-1111-1111-111111111111 skip-drain=true
```

Replace a given node by a new one
```
scw k8s node delete 11111111-1111-1111-111111111111 replace=true
```




Expand Down Expand Up @@ -608,7 +620,7 @@ scw k8s node list [arg=value ...]
| pool-id | | The pool ID on which to filter the returned nodes |
| order-by | One of: `created_at_asc`, `created_at_desc` | The sort order of the returned nodes |
| name | | The name on which to filter the returned nodes |
| status | One of: `unknown`, `creating`, `not_ready`, `ready`, `deleting`, `deleted`, `locked`, `rebooting`, `creation_error`, `upgrading`, `starting` | The status on which to filter the returned nodes |
| status | One of: `unknown`, `creating`, `not_ready`, `ready`, `deleting`, `deleted`, `locked`, `rebooting`, `creation_error`, `upgrading`, `starting`, `registering` | The status on which to filter the returned nodes |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |


Expand Down
103 changes: 101 additions & 2 deletions docs/commands/rdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Database RDB API
- [List privileges of a given user for a given database on a given instance](#list-privileges-of-a-given-user-for-a-given-database-on-a-given-instance)
- [Set privileges of a given user for a given database on a given instance](#set-privileges-of-a-given-user-for-a-given-database-on-a-given-instance)
- [Read replica management](#read-replica-management)
- [Create a read replica](#create-a-read-replica)
- [Create a new endpoint for a given read replica](#create-a-new-endpoint-for-a-given-read-replica)
- [Delete a read replica](#delete-a-read-replica)
- [Get a read replica](#get-a-read-replica)
- [Reset a read replica](#reset-a-read-replica)
- [Block snapshot management](#block-snapshot-management)
- [Create an instance snapshot](#create-an-instance-snapshot)
- [Delete an instance snapshot](#delete-an-instance-snapshot)
Expand Down Expand Up @@ -930,16 +935,110 @@ scw rdb privilege set [arg=value ...]
A read replica is a live copy of the main database instance only available for reading. Read replica allows you to scale your database instance for read-heavy database workloads. Read replicas can also be used for Business Intelligence workloads.


A read replica is a live copy of the main database instance only available for reading. Read replica allows you to scale your database instance for read-heavy database workloads. Read replicas can also be used for Business Intelligence workloads.

### Create a read replica

Create a read replica.

**Usage:**

```
scw rdb read-replica
scw rdb read-replica create <instance-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| instance-id | Required | UUID of the instance you want a read replica of |
| endpoint-spec.{index}.private-network.private-network-id | | UUID of the private network to be connected to the read replica |
| endpoint-spec.{index}.private-network.service-ip | | Endpoint IPv4 adress with a CIDR notation. Check documentation about IP and subnet limitations. |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |



### Create a new endpoint for a given read replica

Create a new endpoint for a given read replica.

**Usage:**

```
scw rdb read-replica create-endpoint <read-replica-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| read-replica-id | Required | UUID of the read replica |
| endpoint-spec.{index}.private-network.private-network-id | | UUID of the private network to be connected to the read replica |
| endpoint-spec.{index}.private-network.service-ip | | Endpoint IPv4 adress with a CIDR notation. Check documentation about IP and subnet limitations. |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |



### Delete a read replica

Delete a read replica.

**Usage:**

```
scw rdb read-replica delete <read-replica-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| read-replica-id | Required | UUID of the read replica |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |



### Get a read replica

Get a read replica.

**Usage:**

```
scw rdb read-replica get <read-replica-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| read-replica-id | Required | UUID of the read replica |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |



### Reset a read replica

Reset a read replica.

**Usage:**

```
scw rdb read-replica reset <read-replica-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| read-replica-id | Required | UUID of the read replica |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |



## Block snapshot management

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
github.com/mattn/go-colorable v0.1.12
github.com/mattn/go-isatty v0.0.14
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220713095144-987a16e8bbc0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220804074940-36f0995dd5b3
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220713095144-987a16e8bbc0 h1:Wk46C3vB2veB2dyguZZZ/MDWlrBuUwu3KAVI7OlTTX0=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220713095144-987a16e8bbc0/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220804074940-36f0995dd5b3 h1:QhrBPIfq67DwrIcs180KXzqe8xc3fx1ivR2BYlj1M3Y=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220804074940-36f0995dd5b3/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
Expand Down
Loading

0 comments on commit 48fa817

Please sign in to comment.