Etcd: [Members API] Adding new node with name parameter

Created on 11 Oct 2018  路  3Comments  路  Source: etcd-io/etcd

We are trying to automate a part of our deployment process of ETCD.
Looking over the API docs, Members API to be precise. https://coreos.com/etcd/docs/latest/v2/members_api.html#add-a-member

Is there an undocumented parameter that we can pass to the API to set node name (hostname) as is it possible with the CLI (https://coreos.com/etcd/docs/latest/etcd-live-cluster-reconfiguration.html#change-etcd-cluster-size) ?

something in the line of:

curl http://10.0.0.10:2379/v2/members -XPOST \
-H "Content-Type: application/json" -d '{"name": "MY-NODE-1", "peerURLs":["http://10.0.0.10:2380"]}'

Currently, even if the name parameter is passed to the API, response returned has{"name": ""}

Our ETCD version:

etcd Version: 3.3.8
Git SHA: 33245c6b5
Go Version: go1.9.7
Go OS/Arch: linux/amd64
arequestion

Most helpful comment

@gek0 @wenjiaswe is correct v2 is deprecated the v3 gRPC-gateway usage is like this.

```
curl -X POST http://127.0.0.1:2379/v3beta/cluster/member/add \
-d '{"peerURLs":["http://127.0.0.1:2380"]}'
````

Is there an undocumented parameter that we can pass to the API to set node name (hostname) as is it possible with the CLI

The name parameter fails because it is not an input to MemberAddRequest

If you read the code in etcdctl you can see that the newMemberName is only printed. The idea here is to use the output to actually start the new member where the name will actually be consumed. Documentation: add-a-new-member

https://github.com/etcd-io/etcd/blob/1a8c52097971fbc1e0988ab8f807c7bdde1fc3e7/etcdctl/ctlv3/command/member_command.go#L151-L167

All 3 comments

The doc you are looking at is v2 and is deprecated: "These docs are deprecated while they are being migrated to Red Hat. For the most up to date docs, please see the corresponding GitHub repository."

Please take a look and see if these link are helpful;

https://github.com/etcd-io/etcd/blob/v3.3.10/Documentation/op-guide/configuration.md#--name
https://github.com/etcd-io/etcd/blob/v3.3.10/Documentation/op-guide/clustering.md

@gek0 @wenjiaswe is correct v2 is deprecated the v3 gRPC-gateway usage is like this.

```
curl -X POST http://127.0.0.1:2379/v3beta/cluster/member/add \
-d '{"peerURLs":["http://127.0.0.1:2380"]}'
````

Is there an undocumented parameter that we can pass to the API to set node name (hostname) as is it possible with the CLI

The name parameter fails because it is not an input to MemberAddRequest

If you read the code in etcdctl you can see that the newMemberName is only printed. The idea here is to use the output to actually start the new member where the name will actually be consumed. Documentation: add-a-new-member

https://github.com/etcd-io/etcd/blob/1a8c52097971fbc1e0988ab8f807c7bdde1fc3e7/etcdctl/ctlv3/command/member_command.go#L151-L167

In general, it is probably best to use etcdctl directly vs gRPC-gateway and follow instructions unless you are planning on writing a client or using some other form of automation to handle the rest of the process.

Was this page helpful?
0 / 5 - 0 ratings