Skip to content

Commit 24bdd54

Browse files
committed
api calls for CRDR management
1 parent cde02cd commit 24bdd54

File tree

3 files changed

+248
-2
lines changed

3 files changed

+248
-2
lines changed

docs/products/postgresql/crdr/crdr-failover-to-recovery.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,62 @@ avn service update PRIMARY_SERVICE_NAME \
5656

5757
Replace `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`.
5858

59+
</TabItem>
60+
<TabItem value="api" label="Aiven API">
61+
62+
Call the [ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
63+
to change `disaster_recovery_role` of the primary service to `failed`:
64+
65+
```bash {5}
66+
curl --request PUT \
67+
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
68+
-H 'Authorization: Bearer BEARER_TOKEN' \
69+
-H 'content-type: application/json' \
70+
--data '{"disaster_recovery_role": "failed"}'
71+
```
72+
73+
Replace the following placeholders with meaningful data:
74+
75+
- `PROJECT_NAME`, for example `crdr-test`
76+
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
77+
- `BEARER_TOKEN`
78+
79+
After sending the request, you can check the CRDR status on each of the CRDR peer services:
80+
81+
- Primary service status
82+
83+
```bash
84+
avn service get pg-primary
85+
--project $PROJECT_NAME
86+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
87+
```
88+
89+
Expect the following output:
90+
91+
```json
92+
{
93+
"state": "POWEROFF",
94+
"disaster_recovery_role": "failed"
95+
}
96+
```
97+
98+
- Recovery service status
99+
100+
```bash
101+
avn service get pg-primary-dr
102+
--project $PROJECT_NAME
103+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
104+
```
105+
106+
Expect the following output:
107+
108+
```json
109+
{
110+
"state": "RUNNING",
111+
"disaster_recovery_role": "active"
112+
}
113+
```
114+
59115
</TabItem>
60116
</Tabs>
61117

docs/products/postgresql/crdr/crdr-revert-to-primary.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,117 @@ using a tool of your choice:
7070

7171
Replace `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`.
7272

73+
</TabItem>
74+
<TabItem value="api" label="Aiven API">
75+
76+
1. Trigger the recreation of the primary service by calling the
77+
[ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
78+
to change `disaster_recovery_role` of the primary service to `passive`:
79+
80+
```bash {5}
81+
curl --request PUT \
82+
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
83+
-H 'Authorization: Bearer BEARER_TOKEN' \
84+
-H 'content-type: application/json' \
85+
--data '{"disaster_recovery_role": "passive"}'
86+
```
87+
88+
Replace the following placeholders with meaningful data:
89+
90+
- `PROJECT_NAME`, for example `crdr-test`
91+
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
92+
- `BEARER_TOKEN`
93+
94+
After sending the request, you can check the CRDR status on each of the CRDR peer services:
95+
96+
- Primary service status
97+
98+
```bash
99+
avn service get pg-primary
100+
--project $PROJECT_NAME
101+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
102+
```
103+
104+
Expect the following output:
105+
106+
```json
107+
{
108+
"state": "REBUILDING",
109+
"disaster_recovery_role": "passive"
110+
}
111+
```
112+
113+
- Recovery service status
114+
115+
```bash
116+
avn service get pg-primary-dr
117+
--project $PROJECT_NAME
118+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
119+
```
120+
121+
Expect the following output:
122+
123+
```json
124+
{
125+
"state": "RUNNING",
126+
"disaster_recovery_role": "active"
127+
}
128+
```
129+
130+
1. Promote the primary service as active by calling the
131+
[ServiceUpdte endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate)
132+
to change `disaster_recovery_role` of the primary service to `active`:
133+
134+
```bash {5}
135+
curl --request PUT \
136+
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/PRIMARY_SERVICE_NAME \
137+
-H 'Authorization: Bearer BEARER_TOKEN' \
138+
-H 'content-type: application/json' \
139+
--data '{"disaster_recovery_role": "active"}'
140+
```
141+
142+
Replace the following placeholders with meaningful data:
143+
144+
- `PROJECT_NAME`, for example `crdr-test`
145+
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
146+
- `BEARER_TOKEN`
147+
148+
After sending the request, you can check the CRDR status on each of the CRDR peer services:
149+
150+
- Primary service status
151+
152+
```bash
153+
avn service get pg-primary
154+
--project $PROJECT_NAME
155+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
156+
```
157+
158+
Expect the following output:
159+
160+
```json
161+
{
162+
"state": "RUNNING",
163+
"disaster_recovery_role": "active"
164+
}
165+
```
166+
167+
- Recovery service status
168+
169+
```bash
170+
avn service get pg-primary-dr
171+
--project $PROJECT_NAME
172+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
173+
```
174+
175+
Expect the following output:
176+
177+
```json
178+
{
179+
"state": "RUNNING",
180+
"disaster_recovery_role": "passive"
181+
}
182+
```
183+
73184
</TabItem>
74185
</Tabs>
75186

docs/products/postgresql/crdr/enable-crdr.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ Enable the [cross-region disaster recovery (CRDR)](/docs/products/postgresql/crd
2222
plan.
2323
:::
2424

25-
- Access to the [Aiven Console](https://console.aiven.io/) or
26-
the [Aiven CLI client installed](/docs/tools/cli)
25+
- One of the following tool for operating CRDR:
26+
- [Aiven Console](https://console.aiven.io/)
27+
- [Aiven CLI](/docs/tools/cli)
28+
- [Aiven API](/docs/tools/api)
2729

2830
## Set up a recovery service
2931

@@ -66,6 +68,83 @@ Replace the following:
6668
`google-europe-west-4`
6769
- `PRIMARY_SERVICE_NAME` with the name of the primary service, for example, `pg-demo`
6870

71+
</TabItem>
72+
<TabItem value="api" label="Aiven API">
73+
74+
Call the
75+
[ServiceCreate endpoint](https://api.aiven.io/doc/#tag/Service/operation/ServiceCreate) to
76+
create a recovery service and enable the `disaster_recovery` service integration between
77+
the recovery service and the primary service, for example:
78+
79+
```bash {14}
80+
curl --request POST \
81+
--url https://api.aiven.io/v1/project/PROJECT_NAME/service \
82+
-H 'accept: application/json, text/plain, */*' \
83+
-H 'Authorization: Bearer BEARER_TOKEN' \
84+
-H 'content-type: application/json' \
85+
--data-raw '{
86+
"service_name": "RECOVERY_SERCICE_NAME",
87+
"cloud": "CLOUD_PROVIDER_REGION",
88+
"plan": "SERVICE_PLAN",
89+
"service_type": "SERVICE_TYPE",
90+
"disk_space_mb": DISK_SIZE,
91+
"service_integrations": [
92+
{
93+
"integration_type": "disaster_recovery",
94+
"source_service": "PRIMARY_SERVICE_NAME",
95+
"user_config": {}
96+
}
97+
]
98+
}'
99+
```
100+
101+
Replace the following placeholders with meaningful data:
102+
103+
- `PROJECT_NAME`, for example `crdr-test`
104+
- `BEARER_TOKEN`
105+
- `RECOVERY_SERCICE_NAME`, for example `pg-dr-test`
106+
- `CLOUD_PROVIDER_REGION`, for example `google-europe-west10`
107+
- `SERVICE_PLAN`, for example `startup-4`
108+
- `SERVICE_TYPE`, for example `pg`
109+
- `DISK_SIZE` in MiB, for example `81920`
110+
- `PRIMARY_SERVICE_NAME`, for example `pg-primary-test`
111+
112+
After sending the request, you can check the CRDR status on each of the CRDR peer services:
113+
114+
- Primary service status
115+
116+
```bash
117+
avn service get PRIMARY_SERVICE_NAME
118+
--project PROJECT_NAME
119+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
120+
```
121+
122+
Expect the following output:
123+
124+
```json
125+
{
126+
"state": "RUNNING",
127+
"disaster_recovery_role": "active"
128+
}
129+
```
130+
131+
- Recovery service status
132+
133+
```bash
134+
avn service get RECOVERY_SERVICE_NAME
135+
--project PROJECT_NAME
136+
--json | jq '{state: .state, disaster_recovery_role: .disaster_recovery_role}'
137+
```
138+
139+
Expect the following output:
140+
141+
```json
142+
{
143+
"state": "REBUILDING",
144+
"disaster_recovery_role": "passive"
145+
}
146+
```
147+
69148
</TabItem>
70149
</Tabs>
71150

0 commit comments

Comments
 (0)