[Turn] etcdctl v2 v3 Guide

Original: https://blog.csdn.net/kozazyh/article/details/79586530

-----------------------------------------------------

etcd2 and etcd3 are incompatible, api both parameters are not the same, please see the detailed etcdctl -h.
And may be used api2 etcd3 api3 write data, it should be noted that, different versions of the write data using the api required to read data corresponding api version.

Use api 2

LS = 2 etcdctl ETCDCTL_API /
API use. 3

ETCDCTL_API = 3 etcdctl get /
issue a no alternative use get etcd3 ls

For example: Search key or value:

$ export ETCDCTL_API=3
$ export ETCD_ENDPOINTS="https://192.168.5.7:2379,https://192.168.5.8:2379,https://192.168.5.86:2379"
$ etcdctl --endpoints=${ETCD_ENDPOINTS} get / --prefix --keys-only
$ etcdctl --endpoints=${ETCD_ENDPOINTS} get / --prefix --print-value-only |jq [.]
使用证书查询:

Export ETCDCTL_API. 3 = $
$ Export ETCD_ENDPOINTS = "https://192.168.5.7:2379,https://192.168.5.8:2379,https://192.168.5.86:2379"
$ etcdctl --endpoints} = $ {ETCD_ENDPOINTS --cacert = / etc / kubernetes / ssl / ca.pem --cert = / etc / kubernetes / ssl / admin.pem --key = / etc / kubernetes / ssl / admin-key.pem --prefix --keys -only = true get /
Second problem, create a modified key-value pair

api v2 version:

Etcdctl the SET the Test the Hello $
API v3 versions:

$ Etcdctl put test hello
Reference:

https://github.com/coreos/etcd/issues/6904

 
----------------
Disclaimer: This article is CSDN blogger "Big Brother 2 fly" in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/kozazyh/article/details/79586530

Guess you like

Origin www.cnblogs.com/oxspirt/p/12079776.html
v2