python-etcd3
Posted 吾谨受教!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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()
以上是关于python-etcd3的主要内容,如果未能解决你的问题,请参考以下文章