1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.113:2379/v3/kv/txn \ -X POST \ -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}'
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.113:2379/v3/kv/watch \ -X POST -d '{"create_request": {"key":"Zm9v"} }' &
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.113:2379/v3/kv/put \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}'
curl --cacert ./ca.pem --cert ./client.pem --key ./client-key.pem https://172.12.0.16:2379/version curl --cacert ./ca.pem --cert ./client.pem --key ./client-key.pem https://192.168.1.112:2379/version
# Put and get keys curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.111:2379/v3/kv/range \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"header":{"cluster_id":"11748455551159483977","member_id":"397314234392206164","revision":"51","raft_term":"2"},"kvs":[{"key":"Zm9v","create_revision":"48","mod_revision":"51","version":"4","value":"YmFy"}],"count":"1"}#
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/put \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"}}
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/range \ -X POST -d '{"key": "Zm9v"}' # {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}
# get all keys prefixed with "foo" curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/range \ -X POST -d '{"key": "Zm9v", "range_end": "Zm9w"}' # {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}
# get the auth token for the root user curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/authenticate \ -X POST -d '{"name": "root", "password": "pass"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"},"token":"sssvIpwfnLAcWAQH.9"}
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/put \ -H 'Authorization : sssvIpwfnLAcWAQH.9' \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"2","raft_term":"2"}}
# Watch keys curl --cacert ca.pem --cert client.pem --key client-key.pem -N https://192.168.1.112:2379/v3/watch \ -X POST -d '{"create_request": {"key":"Zm9v"} }' & # {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"1","raft_term":"2"},"created":true}}
curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/put \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"2"},"events":[{"kv":{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}}]}}
# Transactions # target CREATE curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/txn \ -X POST \ -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}' # {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"3","raft_term":"2"},"succeeded":true,"responses":[{"response_put":{"header":{"revision":"3"}}}]}
# target VERSION curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/txn \ -X POST \ -d '{"compare":[{"version":"4","result":"EQUAL","target":"VERSION","key":"Zm9v"}],"success":[{"requestRange":{"key":"Zm9v"}}]}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"6","raft_term":"3"},"succeeded":true,"responses":[{"response_range":{"header":{"revision":"6"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"6","version":"4","value":"YmF6"}],"count":"1"}}]}
# Authentication # create root user curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/user/add \ -X POST -d '{"name": "root", "password": "pass"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}
# create root role curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/role/add \ -X POST -d '{"name": "root"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}
# grant root role curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/user/grant \ -X POST -d '{"user": "root", "role": "root"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}
# enable auth curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/enable -X POST -d '{}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}
# Authenticate with etcd for an authentication token using /v3/auth/authenticate: # get the auth token for the root user curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/auth/authenticate \ -X POST -d '{"name": "root", "password": "pass"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"},"token":"sssvIpwfnLAcWAQH.9"} curl --cacert ca.pem --cert client.pem --key client-key.pem -L https://192.168.1.112:2379/v3/kv/put \ -H 'Authorization : sssvIpwfnLAcWAQH.9' \ -X POST -d '{"key": "Zm9v", "value": "YmFy"}' # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"2","raft_term":"2"}}
|