Demo

Procedures for working with an etcd cluster

This series of examples shows the basic procedures for working with an etcd cluster.

Auth

auth,user,role for authentication:

1. export ETCDCTL_API=3
2. ENDPOINTS=localhost:2379

4. etcdctl --endpoints=${ENDPOINTS} role add root
5. etcdctl --endpoints=${ENDPOINTS} role get root

7. etcdctl --endpoints=${ENDPOINTS} user add root
8. etcdctl --endpoints=${ENDPOINTS} user grant-role root root
9. etcdctl --endpoints=${ENDPOINTS} user get root

11. etcdctl --endpoints=${ENDPOINTS} role add role0
12. etcdctl --endpoints=${ENDPOINTS} role grant-permission role0 readwrite foo
13. etcdctl --endpoints=${ENDPOINTS} user add user0
14. etcdctl --endpoints=${ENDPOINTS} user grant-role user0 role0

16. etcdctl --endpoints=${ENDPOINTS} auth enable
17. # now all client requests go through auth

19. etcdctl --endpoints=${ENDPOINTS} --user=user0:123 put foo bar
20. etcdctl --endpoints=${ENDPOINTS} get foo
21. # permission denied, user name is empty because the request does not issue an authentication request
22. etcdctl --endpoints=${ENDPOINTS} --user=user0:123 get foo
23. # user0 can read the key foo
24. etcdctl --endpoints=${ENDPOINTS} --user=user0:123 get foo1

Last modified February 28, 2022: Create doc branch for v3.6 (9ed5c74)