Skip to content

Commit e216ee5

Browse files
authored
cmd: Temporarily remove ability to create a flag based deployment (#239)
This change temporarily removes the ability to create a flag based deployment until reads to deployment templates are available to all users.
1 parent 133cfff commit e216ee5

File tree

3 files changed

+75
-85
lines changed

3 files changed

+75
-85
lines changed

cmd/deployment/create.go

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ var createCmd = &cobra.Command{
3636
Use: "create {--file | --size <int> --zones <string> | --topology-element <obj>}",
3737
Short: "Creates a deployment",
3838
PreRunE: cobra.MaximumNArgs(0),
39-
Long: createLong,
40-
Example: createExample,
39+
// Switch back to non-temp constants when reads for deployment templates are available on ESS
40+
Long: createLongTemp,
41+
Example: createExampleTemp,
4142
RunE: func(cmd *cobra.Command, args []string) error {
4243
var track, _ = cmd.Flags().GetBool("track")
4344
var generatePayload, _ = cmd.Flags().GetBool("generate-payload")
4445
var name, _ = cmd.Flags().GetString("name")
4546
var version, _ = cmd.Flags().GetString("version")
4647
var dt, _ = cmd.Flags().GetString("deployment-template")
4748

48-
var zoneCount, _ = cmd.Flags().GetInt32("zones")
49-
var size, _ = cmd.Flags().GetInt32("size")
50-
var esRefID, _ = cmd.Flags().GetString("ref-id")
49+
var esZoneCount, _ = cmd.Flags().GetInt32("es-zones")
50+
var esSize, _ = cmd.Flags().GetInt32("es-size")
51+
var esRefID, _ = cmd.Flags().GetString("es-ref-id")
5152
var te, _ = cmd.Flags().GetStringArray("topology-element")
5253
var plugin, _ = cmd.Flags().GetStringSlice("plugin")
5354

@@ -93,8 +94,8 @@ var createCmd = &cobra.Command{
9394
AppsearchEnable: appsearchEnable,
9495
ElasticsearchInstance: depresource.InstanceParams{
9596
RefID: esRefID,
96-
Size: size,
97-
ZoneCount: zoneCount,
97+
Size: esSize,
98+
ZoneCount: esZoneCount,
9899
},
99100
KibanaInstance: depresource.InstanceParams{
100101
RefID: kibanaRefID,
@@ -154,16 +155,18 @@ var createCmd = &cobra.Command{
154155
func init() {
155156
Command.AddCommand(createCmd)
156157
createCmd.Flags().StringP("file", "f", "", "DeploymentCreateRequest file definition. See help for more information")
158+
// Remove when reads for deployment templates are available on ESS
159+
createCmd.MarkFlagRequired("file")
157160
createCmd.Flags().String("deployment-template", "default", "Deployment template ID on which to base the deployment from")
158161
createCmd.Flags().String("version", "", "Version to use, if not specified, the latest available stack version will be used")
159162
createCmd.Flags().String("name", "", "Optional name for the deployment")
160163
createCmd.Flags().BoolP("track", "t", false, cmdutil.TrackFlagMessage)
161164
createCmd.Flags().Bool("generate-payload", false, "Returns the deployment payload without actually creating the deployment resources")
162165
createCmd.Flags().String("request-id", "", "Optional idempotency token - Can be found in the Stderr device when a previous deployment creation failed, for more information see the examples in the help command page")
163166

164-
createCmd.Flags().String("ref-id", "main-elasticsearch", "Optional RefId for the Elasticsearch deployment")
165-
createCmd.Flags().Int32("zones", 1, "Number of zones the Elasticsearch instances will span")
166-
createCmd.Flags().Int32("size", 4096, "Memory (RAM) in MB that each of the Elasticsearch instances will have")
167+
createCmd.Flags().String("es-ref-id", "main-elasticsearch", "Optional RefId for the Elasticsearch deployment")
168+
createCmd.Flags().Int32("es-zones", 1, "Number of zones the Elasticsearch instances will span")
169+
createCmd.Flags().Int32("es-size", 4096, "Memory (RAM) in MB that each of the Elasticsearch instances will have")
167170
createCmd.Flags().StringArrayP("topology-element", "e", nil, "Optional Elasticsearch topology element definition. See help for more information")
168171
createCmd.Flags().StringSlice("plugin", nil, "Additional plugins to add to the Elasticsearch deployment")
169172

@@ -180,4 +183,26 @@ func init() {
180183
createCmd.Flags().String("appsearch-ref-id", "main-appsearch", "Optional RefId for the AppSearch deployment")
181184
createCmd.Flags().Int32("appsearch-zones", 1, "Number of zones the AppSearch instances will span")
182185
createCmd.Flags().Int32("appsearch-size", 2048, "Memory (RAM) in MB that each of the AppSearch instances will have")
186+
187+
// The following flags will remain hidden until reads for deployment templates are available on ESS
188+
createCmd.Flags().MarkHidden("deployment-template")
189+
createCmd.Flags().MarkHidden("version")
190+
createCmd.Flags().MarkHidden("name")
191+
createCmd.Flags().MarkHidden("generate-payload")
192+
createCmd.Flags().MarkHidden("es-ref-id")
193+
createCmd.Flags().MarkHidden("es-zones")
194+
createCmd.Flags().MarkHidden("es-size")
195+
createCmd.Flags().MarkHidden("topology-element")
196+
createCmd.Flags().MarkHidden("plugin")
197+
createCmd.Flags().MarkHidden("kibana-ref-id")
198+
createCmd.Flags().MarkHidden("kibana-zones")
199+
createCmd.Flags().MarkHidden("kibana-size")
200+
createCmd.Flags().MarkHidden("apm")
201+
createCmd.Flags().MarkHidden("apm-ref-id")
202+
createCmd.Flags().MarkHidden("apm-zones")
203+
createCmd.Flags().MarkHidden("apm-size")
204+
createCmd.Flags().MarkHidden("appsearch")
205+
createCmd.Flags().MarkHidden("appsearch-ref-id")
206+
createCmd.Flags().MarkHidden("appsearch-zones")
207+
createCmd.Flags().MarkHidden("appsearch-size")
183208
}

cmd/deployment/create_help.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package cmddeployment
1919

2020
const (
21+
// nolint
2122
createLong = `Creates a deployment which can be defined through flags or from a file definition.
2223
Sane default values are provided, making the command work out of the box even when no parameters are set.
2324
When version is not specified, the latest available stack version will automatically be used.
@@ -38,6 +39,7 @@ These are the available options:
3839
As an option "--generate-payload" can be used in order to obtain the generated payload that would be sent as a request.
3940
Save it, update or extend the topology and create a deployment using the saved payload with the "--file" flag.`
4041

42+
// nolint
4143
createExample = `## Create a deployment with the default values for Elasticsearch, a Kibana instance with a modified size,
4244
and a default APM instance. While Elasticsearch and Kibana come enabled by default, both APM and AppSearch need to be
4345
enabled by using the "--apm" and "--appsearch" flags. The command will exit after the API response has been returned, without
@@ -48,24 +50,23 @@ $ ecctl deployment create --name my-deployment --zones 2 --kibana-size 2048 --ap
4850
the current stage on which the deployment resources are in.
4951
$ deployment create --name my-deployment --track
5052
[...]
51-
Cluster [38e0ff5b58a9483c96a98c923b22194e][Elasticsearch]: finished running all the plan steps (Total plan duration: 1m0.911628175s)
52-
Cluster [51178ffc645d48b7859dbf17388a6c35][Kibana]: finished running all the plan steps (Total plan duration: 1m11.246662764s)
53+
Deployment [b6ecbea3d5c84124b7dca457f2892086] - [Elasticsearch][b6ecbea3d5c84124b7dca457f2892086]: finished running all the plan steps (Total plan duration: 5m11.s)
54+
Deployment [91c4d60acb804ba0a27651fac02780ec] - [Kibana][8a9d9916cd6e46a7bb0912211d76e2af]: finished running all the plan steps (Total plan duration: 4m29.58s)
5355
5456
## Additionally, a more advanced topology for Elasticsearch can be created through "--topology-element" or shorthand "-e".
5557
The following command will create a deployment with two 1GB Elasticsearch instances of the type "data" and
5658
one 1GB Elasticsearch instance of the type "ml".
5759
$ ecctl deployment create --name my-deployment --topology-element '{"size": 1024, "zone_count": 2, "name": "data"}' --topology-element '{"size": 1024, "zone_count": 1, "name": "ml"}'
5860
5961
## In order to use the "--deployment-template" flag, you'll need to know which deployment templates ara available to you.
60-
Visit https://elastic.co/guide/en/cloud/current/ec-regions-templates-instances.html.
61-
If you are an Elastic Cloud Enterprise customer, you'll need to run the following command to view your deployment templates:
62+
You'll need to run the following command to view your deployment templates:
6263
$ ecctl platform deployment-template list
6364
6465
## Use the "--generate-payload" flag to save the definition to a file for later use.
65-
$ ecctl deployment create --name my-deployment --size 1024 --track --generate-payload --zones 2 > elasticsearch_create_example.json
66+
$ ecctl deployment create --name my-deployment --size 1024 --track --generate-payload --zones 2 > create_example.json
6667
6768
## Create a deployment through the file definition.
68-
$ ecctl deployment create --file elasticsearch_create_example.json --track
69+
$ ecctl deployment create --file create_example.json --track
6970
7071
## To retry a when the previous deployment creation failed:
7172
$ ecctl deployment create
@@ -74,4 +75,25 @@ to recreate the deployment resources
7475
Idempotency token: GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb
7576
unknown error (status 500)
7677
$ ecctl deployment create --request-id=GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb`
78+
79+
// Remove temporary constants when reads for deployment templates are available on ESS
80+
createLongTemp = `Creates a deployment which is defined from a file definition using the --file=<file path> (shorthand: -f) flag.
81+
82+
You can create a definition by using the sample JSON seen here:
83+
https://elastic.co/guide/en/cloud/current/ec-api-deployment-crud.html#ec_create_a_deployment`
84+
85+
createExampleTemp = `## To make the command wait until the resources have been created use the "--track" flag, which will output
86+
the current stage on which the deployment resources are in.
87+
$ deployment create --file create_example.json --track
88+
[...]
89+
Deployment [b6ecbea3d5c84124b7dca457f2892086] - [Elasticsearch][b6ecbea3d5c84124b7dca457f2892086]: finished running all the plan steps (Total plan duration: 5m11.s)
90+
Deployment [91c4d60acb804ba0a27651fac02780ec] - [Kibana][8a9d9916cd6e46a7bb0912211d76e2af]: finished running all the plan steps (Total plan duration: 4m29.58s)
91+
92+
## To retry a when the previous deployment creation failed:
93+
$ ecctl deployment create --file create_example.json
94+
The deployment creation returned with an error, please use the displayed idempotency token
95+
to recreate the deployment resources
96+
Idempotency token: GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb
97+
unknown error (status 500)
98+
$ ecctl deployment create --file create_example.json --request-id=GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb`
7799
)

docs/ecctl_deployment_create.md

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,10 @@ Creates a deployment
44

55
### Synopsis
66

7-
Creates a deployment which can be defined through flags or from a file definition.
8-
Sane default values are provided, making the command work out of the box even when no parameters are set.
9-
When version is not specified, the latest available stack version will automatically be used.
10-
These are the available options:
7+
Creates a deployment which is defined from a file definition using the --file=<file path> (shorthand: -f) flag.
118

12-
* Simplified flags to set size and zone count for each instance type (Elasticsearch, Kibana, APM and AppSearch).
13-
* Advanced flag for different Elasticsearch node types: --topology-element <json obj> (shorthand: -e).
14-
Note that the flag can be specified multiple times for complex topologies.
15-
The JSON object has the following format:
16-
{
17-
"name": "["data", "master", "ml"]" # type string
18-
"size": 1024 # type int32
19-
"zone_count": 1 # type int32
20-
}
21-
* File definition: --file=<file path> (shorthand: -f). You can create a definition by using the sample JSON seen here:
22-
https://elastic.co/guide/en/cloud/current/ec-api-deployment-crud.html#ec_create_a_deployment
23-
24-
As an option "--generate-payload" can be used in order to obtain the generated payload that would be sent as a request.
25-
Save it, update or extend the topology and create a deployment using the saved payload with the "--file" flag.
9+
You can create a definition by using the sample JSON seen here:
10+
https://elastic.co/guide/en/cloud/current/ec-api-deployment-crud.html#ec_create_a_deployment
2611

2712
```
2813
ecctl deployment create {--file | --size <int> --zones <string> | --topology-element <obj>} [flags]
@@ -31,71 +16,29 @@ ecctl deployment create {--file | --size <int> --zones <string> | --topology-ele
3116
### Examples
3217

3318
```
34-
## Create a deployment with the default values for Elasticsearch, a Kibana instance with a modified size,
35-
and a default APM instance. While Elasticsearch and Kibana come enabled by default, both APM and AppSearch need to be
36-
enabled by using the "--apm" and "--appsearch" flags. The command will exit after the API response has been returned, without
37-
waiting until the deployment resources have been created.
38-
$ ecctl deployment create --name my-deployment --zones 2 --kibana-size 2048 --apm --apm-size 1024
39-
4019
## To make the command wait until the resources have been created use the "--track" flag, which will output
4120
the current stage on which the deployment resources are in.
42-
$ deployment create --name my-deployment --track
21+
$ deployment create --file create_example.json --track
4322
[...]
44-
Cluster [38e0ff5b58a9483c96a98c923b22194e][Elasticsearch]: finished running all the plan steps (Total plan duration: 1m0.911628175s)
45-
Cluster [51178ffc645d48b7859dbf17388a6c35][Kibana]: finished running all the plan steps (Total plan duration: 1m11.246662764s)
46-
47-
## Additionally, a more advanced topology for Elasticsearch can be created through "--topology-element" or shorthand "-e".
48-
The following command will create a deployment with two 1GB Elasticsearch instances of the type "data" and
49-
one 1GB Elasticsearch instance of the type "ml".
50-
$ ecctl deployment create --name my-deployment --topology-element '{"size": 1024, "zone_count": 2, "name": "data"}' --topology-element '{"size": 1024, "zone_count": 1, "name": "ml"}'
51-
52-
## In order to use the "--deployment-template" flag, you'll need to know which deployment templates ara available to you.
53-
Visit https://elastic.co/guide/en/cloud/current/ec-regions-templates-instances.html.
54-
If you are an Elastic Cloud Enterprise customer, you'll need to run the following command to view your deployment templates:
55-
$ ecctl platform deployment-template list
56-
57-
## Use the "--generate-payload" flag to save the definition to a file for later use.
58-
$ ecctl deployment create --name my-deployment --size 1024 --track --generate-payload --zones 2 > elasticsearch_create_example.json
59-
60-
## Create a deployment through the file definition.
61-
$ ecctl deployment create --file elasticsearch_create_example.json --track
23+
Deployment [b6ecbea3d5c84124b7dca457f2892086] - [Elasticsearch][b6ecbea3d5c84124b7dca457f2892086]: finished running all the plan steps (Total plan duration: 5m11.s)
24+
Deployment [91c4d60acb804ba0a27651fac02780ec] - [Kibana][8a9d9916cd6e46a7bb0912211d76e2af]: finished running all the plan steps (Total plan duration: 4m29.58s)
6225
6326
## To retry a when the previous deployment creation failed:
64-
$ ecctl deployment create
27+
$ ecctl deployment create --file create_example.json
6528
The deployment creation returned with an error, please use the displayed idempotency token
6629
to recreate the deployment resources
6730
Idempotency token: GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb
6831
unknown error (status 500)
69-
$ ecctl deployment create --request-id=GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb
32+
$ ecctl deployment create --file create_example.json --request-id=GMZPMRrcMYqHdmxjIQkHbdjnhPIeBElcwrHwzVlhGUSMXrEIzVXoBykSVRsKncNb
7033
```
7134

7235
### Options
7336

7437
```
75-
--apm Enables APM for the deployment
76-
--apm-ref-id string Optional RefId for the APM deployment (default "main-apm")
77-
--apm-size int32 Memory (RAM) in MB that each of the APM instances will have (default 512)
78-
--apm-zones int32 Number of zones the APM instances will span (default 1)
79-
--appsearch Enables AppSearch for the deployment
80-
--appsearch-ref-id string Optional RefId for the AppSearch deployment (default "main-appsearch")
81-
--appsearch-size int32 Memory (RAM) in MB that each of the AppSearch instances will have (default 2048)
82-
--appsearch-zones int32 Number of zones the AppSearch instances will span (default 1)
83-
--deployment-template string Deployment template ID on which to base the deployment from (default "default")
84-
-f, --file string DeploymentCreateRequest file definition. See help for more information
85-
--generate-payload Returns the deployment payload without actually creating the deployment resources
86-
-h, --help help for create
87-
--kibana-ref-id string Optional RefId for the Kibana deployment (default "main-kibana")
88-
--kibana-size int32 Memory (RAM) in MB that each of the Kibana instances will have (default 1024)
89-
--kibana-zones int32 Number of zones the Kibana instances will span (default 1)
90-
--name string Optional name for the deployment
91-
--plugin strings Additional plugins to add to the Elasticsearch deployment
92-
--ref-id string Optional RefId for the Elasticsearch deployment (default "main-elasticsearch")
93-
--request-id string Optional idempotency token - Can be found in the Stderr device when a previous deployment creation failed, for more information see the examples in the help command page
94-
--size int32 Memory (RAM) in MB that each of the Elasticsearch instances will have (default 4096)
95-
-e, --topology-element stringArray Optional Elasticsearch topology element definition. See help for more information
96-
-t, --track Tracks the progress of the performed task
97-
--version string Version to use, if not specified, the latest available stack version will be used
98-
--zones int32 Number of zones the Elasticsearch instances will span (default 1)
38+
-f, --file string DeploymentCreateRequest file definition. See help for more information
39+
-h, --help help for create
40+
--request-id string Optional idempotency token - Can be found in the Stderr device when a previous deployment creation failed, for more information see the examples in the help command page
41+
-t, --track Tracks the progress of the performed task
9942
```
10043

10144
### Options inherited from parent commands

0 commit comments

Comments
 (0)