etcdV2的basicauth开启

etcd v2 用起来比较简单,开启权限同样也是比较简单。http就可以开启,注意:v3和v2的权限系统是分开的。详细文档链接

第一步:增加root或者其他用户密码

1
2
3
4
5
6
7
## etcdv2_add_root
curl -X "PUT" "http://127.0.0.1:2379/v2/auth/users/root" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"user": "root",
"password": "passwd"
}'

第二步:开启权限认证

1
2
## etcdv2_enable_auth
curl -X "PUT" "http://127.0.0.1:2379/v2/auth/enable"

第三步:把guest权限关掉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
## etcdv2_modify_guest_role
curl -X "PUT" "http://127.0.0.1:2379/v2/auth/roles/guest" \
-H 'Content-Type: text/plain; charset=utf-8' \
-u 'root:passwd' \
-d $'{
"role" : "guest",
"revoke" : {
"kv" : {
"write": [
"/*"
]
}
}
}
'