Consul Intro

Please see the README.md and get your consul cluster up and running

Setting a key/value with requests

For full documentation, see the Consul http-api


In [20]:
import requests

base_url = 'http://192.168.59.103:8500/v1/kv/'

response = requests.put(base_url + 'key1', data="value1")
print(response.text)


true

Getting a key/value with python-consul

For full documentation, see python-consul documentation


In [21]:
from consul import Consul

c = Consul('192.168.59.103')

index, data = c.kv.get('key1')

print(data['Value'].decode('utf8'))


value1

Other features:

  • Locks
  • DNS for service discovery
  • Limit access to key/value subsets with ACL's and tokens

In [ ]: