Skip to content

Commit b9b2107

Browse files
committed
Allow creation of free tier clusters from JSON definition
1 parent c0de34b commit b9b2107

File tree

2 files changed

+68
-27
lines changed

2 files changed

+68
-27
lines changed

docs/commands/clusters.adoc

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ The full list of flags supported by `clusters create` is:
7777
--cidr <string>: cider block for the cluster
7878
```
7979
80-
The `--free-tier` flag can be used to create free tier clusters in the active Capella project.
81-
For example:
82-
83-
```
84-
👤 Charlie 🏠 remote in ☁️ default._default._default
85-
> clusters create --free-tier --provider aws --region eu-west-1 --cidr 10.0.0.0/24 --description "My first Couchbase cluster"
86-
```
87-
88-
Free clusters clusters are more limited in how they can be customised, and only the name, description, cloud provider and cidr can be configured using flags.
89-
Check the https://docs.couchbase.com/cloud/management-api-reference/index.html#tag/Free-Tier[Capella API docs] for more information.
90-
Currently free tier clusters do not support creation with a JSON cluster definition.
91-
9280
If you are using a paid cluster and want complete control over the structure of the cluster then you can pipe a JSON cluster definition into the command:
9381
9482
```
@@ -99,7 +87,8 @@ If you are using a paid cluster and want complete control over the structure of
9987
"description": "A gcp cluster created using cbshell",
10088
"cloudProvider": {
10189
"type": "gcp",
102-
"region": "us-east1"
90+
"region": "us-central1",
91+
"cidr": "10.0.23.0/24"
10392
},
10493
"serviceGroups": [
10594
{
@@ -139,14 +128,77 @@ If you are using a paid cluster and want complete control over the structure of
139128
├───┼─────────────┼──────────────────────────────────────┼───────────┼───────────────────────────┤
140129
│ 0 │ GCP-CBShell │ c60b070f-6656-4e25-9b22-0cee497bea6a │ deploying │ ╭────────┬──────────────╮ │
141130
│ │ │ │ │ │ type │ gcp │ │
142-
│ │ │ │ │ │ region │ us-east1 │ │
131+
│ │ │ │ │ │ region │ us-central1 │ │
143132
│ │ │ │ │ │ cidr │ 10.0.23.0/24 │ │
144133
│ │ │ │ │ ╰────────┴──────────────╯ │
145134
╰───┴─────────────┴──────────────────────────────────────┴───────────┴───────────────────────────╯
146135
```
147136
148137
See the https://docs.couchbase.com/cloud/management-api-reference/index.html#tag/Clusters/operation/postCluster[Capella API docs] for more examples of cluster definitions with different providers.
149138
139+
The `--free-tier` flag can be used to create free tier clusters in the active Capella project.
140+
For example:
141+
142+
```
143+
👤 Charlie 🏠 remote in ☁️ default._default._default
144+
> clusters create --free-tier --provider aws --region eu-west-1 --cidr 10.0.0.0/24 --description "My first Couchbase cluster"
145+
```
146+
147+
Free clusters clusters are more limited in how they can be customised, and only the name, description, cloud provider and cidr can be configured.
148+
Check the https://docs.couchbase.com/cloud/management-api-reference/index.html#tag/Free-Tier[Capella API docs] for more information.
149+
Free tier clusters can be created by piping a cluster definition into `clusters create` as follows:
150+
151+
```
152+
👤 Charlie 🏠 remote in ☁️ default._default._default
153+
> cat gcp-cluster-def.json | clusters create --free-tier
154+
```
155+
156+
However fields other than the name, description, cloud provider, and cidr will be ignored.
157+
158+
```
159+
👤 Charlie 🏠 remote in ☁️ default._default._default
160+
> clusters get GCP-CBShell
161+
╭────────────────────┬──────────────────────────────────────────────────────────────────────────╮
162+
│ name │ GCP-CBShell │
163+
│ id │ 9ec29286-ceeb-40f0-b226-324fe6716ab7 │
164+
│ description │ A gcp cluster created using cbshell │
165+
│ state │ deploying │
166+
│ connection string │ cb.zssny9sxlno3atpb.aws-guardians.nonprod-project-avengers.com │
167+
│ configuration type │ singleNode │
168+
│ │ ╭─────────┬───────╮ │
169+
│ server │ │ version │ 7.6.6 │ │
170+
│ │ ╰─────────┴───────╯ │
171+
│ │ ╭────────┬─────────────╮ │
172+
│ cloud provider │ │ type │ gcp │ │
173+
│ │ │ region │ us-central1 │ │
174+
│ │ │ cidr │ 10.0.23.0/24│ │
175+
│ │ ╰────────┴─────────────╯ │
176+
│ │ ╭───┬────────────────────────────────────┬────────────┬────────────────╮ │
177+
│ service groups │ │ # │ node │ numOfNodes │ services │ │
178+
│ │ ├───┼────────────────────────────────────┼────────────┼────────────────┤ │
179+
│ │ │ 0 │ ╭─────────┬──────────────────────╮ │ 1 │ ╭───┬────────╮ │ │
180+
│ │ │ │ │ │ ╭─────┬───╮ │ │ │ │ 0 │ search │ │ │
181+
│ │ │ │ │ compute │ │ cpu │ 2 │ │ │ │ │ 1 │ index │ │ │
182+
│ │ │ │ │ │ │ ram │ 8 │ │ │ │ │ 2 │ data │ │ │
183+
│ │ │ │ │ │ ╰─────┴───╯ │ │ │ │ 3 │ query │ │ │
184+
│ │ │ │ │ │ ╭─────────┬────────╮ │ │ │ ╰───┴────────╯ │ │
185+
│ │ │ │ │ disk │ │ type │ pd-ssd │ │ │ │ │ │
186+
│ │ │ │ │ │ │ storage │ 10 │ │ │ │ │ │
187+
│ │ │ │ │ │ ╰─────────┴────────╯ │ │ │ │ │
188+
│ │ │ │ ╰─────────┴──────────────────────╯ │ │ │ │
189+
│ │ ╰───┴────────────────────────────────────┴────────────┴────────────────╯ │
190+
│ │ ╭──────┬────────╮ │
191+
│ availability │ │ type │ single │ │
192+
│ │ ╰──────┴────────╯ │
193+
│ │ ╭──────────┬──────╮ │
194+
│ support │ │ plan │ free │ │
195+
│ │ │ timezone │ PT │ │
196+
│ │ ╰──────────┴──────╯ │
197+
╰────────────────────┴──────────────────────────────────────────────────────────────────────────╯
198+
```
199+
200+
As you can see the `support`, `availability` and `service groups` settings from the cluster definition have been ignored.
201+
150202
==== `clusters drop`
151203
152204
This deletes a cluster with the given name in the active project.

src/cli/clusters_create.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,8 @@ fn clusters_create(
196196

197197
ClusterCreateRequest::new(name, description, cidr, region, provider, version, nodes)
198198
}
199-
Value::String { val, .. } => {
200-
if free_tier {
201-
return Err(generic_error(
202-
"cluster definitions are not supported for free tier clusters",
203-
"Use the --name, --description, --provider, --region and --cidr flags to configure free-tier clusters"
204-
.to_string(),
205-
None,
206-
));
207-
}
208-
209-
serde_json::from_str(val.as_str())
210-
.map_err(|_| could_not_parse_cluster_definition_error())?
211-
}
199+
Value::String { val, .. } => serde_json::from_str(val.as_str())
200+
.map_err(|_| could_not_parse_cluster_definition_error())?,
212201
_ => {
213202
return Err(could_not_parse_cluster_definition_error());
214203
}

0 commit comments

Comments
 (0)