Subscribing to Consul Key-Value

I’m trying to use Consul’s Key-Value API to pass a JSON configuration to an app running in one of my containers. It works great, but the API does not provide any pub-sub functionality (just read/write/delete) for a key.

So far, I managed to artificially compensate by using the Watch feature to restart the container whenever the key changes, but that leaves me with the need to

  • Simple Flask application with debug set to True is not reloading in Docker?
  • Run HBase inside docker container
  • How can I access from network newly deployed pod in kubernetes?
  • I started a docker container in bluemix and ice ps shows my container in state “Queued” for hours
  • How to allow ptrace in docker container
  • Wildfly/Jboss-v10 is not working in cluster mode with docker swarm
    1. Externally configure Consul (either load a new configuration, or use the CLI, to specify a key to watch, and a shell script to run)
    2. Restart my app in mid-run – a good way to potentially lose data.

    Is there any programatic way (other than polling every x seconds) to get notified of a key change in Consul, or should I just back away from this solution, and move to Redis?

  • Kafka setup with docker-compose
  • Docker run does not deploy
  • Docker Swarm discovery is “file”,Can not create success
  • User Interface for Private docker Registry
  • Root PID of Docker container
  • Docker to VM Networking
  • One Solution collect form web for “Subscribing to Consul Key-Value”

    After a quick look at consul’s sources, it seems that the “watch” is a simple periodic pull. You could implement something similar in your code to achieve this.

    Periodic run of the watcher:

    KeyWatch Handler:

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.