python-etcd3
import etcd3 etcd = etcd3.client(host="192.168.5.41", port=2379, ca_cert="E://ssl/kube-ca.pem", cert_cert="E://ssl/kube-etcd-192-168-5-41.pem", cert_key="E://ssl/kube-etcd-192-168-5-41-key.pem") print(etcd) ## <etcd3.client.Etcd3Client object at 0x0000000002EC4240> result = etcd.get("/testkey") print(type(result)) ## <class 'tuple'> print(result[0]) ## b'111111 ' watch_count = 0 events_iterator, cancel = etcd.watch_prefix("/testkey/") for event in events_iterator: print(event) ## <class 'etcd3.events.PutEvent'> key=b'/testkey/5' value=b'1234' event_str = str(event) print(isinstance(event, etcd3.events.PutEvent)) ## True print("key = %s " % event_str.split(' ')[2].split('=')[1]) ## key = b'/testkey/5' watch_count += 1 if watch_count > 10: cancel()
相关推荐
CurrentJ 2020-08-18
JustHaveTry 2020-07-17
Dannyvon 2020-07-13
Dannyvon 2020-07-04
###host字段指定授权使用该证书的etcd节点IP或子网列表,需要将etcd集群的3个节点都添加其中。cp etcd-v3.3.13-linux-amd64/etcd* /opt/k8s/bin/
xiunai 2020-07-04
breezegao 2020-07-02
微微一笑 2020-06-14
微微一笑 2020-06-12
CurrentJ 2020-06-06
lenchio 2020-06-04
微微一笑 2020-06-03
工作中的点点滴滴 2020-06-01
Rcvisual 2020-05-28
Dannyvon 2020-05-28
微微一笑 2020-05-26
wishli 2020-05-19
工作中的点点滴滴 2020-05-14