a tool for managing consul service tags (clear, add, remove, toggle).
1.0K
consul-tags can add, remove tag(s) of a consul service (one or all its instances).
Here is a first release for key functionality.
Download binary from Release page.
docker pull hedzr/consul-tags
docker run -it --rm hedzr/consul-tags --addr 192.168.0.71:8500 ms --name test-redis tags ls
Replace 192.168.0.71 with your consul center ip or name.
DON'T use 127.0.0.1 with dockerize release.
latest: master branch and based on golang:alpine
clone the repo and build:
go build -o consul-tags github.com/hedzr/consul-tags
mixin:
go get -u github.com/hedzr/consul-tags/objects/consul
# list tags
consul-tags ms --name test-redis tags ls
# add tags
consul-tags ms --name test-redis tags --add a,c,e
consul-tags ms --name test-redis tags --add a --add c --add e
# remove tags
consul-tags ms --name test-redis tags --rm a,c,e
consul-tags ms --name test-redis tags --rm a --rm c --rm e
# by id
consul-tags ms --id test-redis-1 tags ls
# toggle master/slave
consul-tags ms --name test-redis tags toggle --addr 10.7.13.1:6379 --set role=master --reset role=slave
consul-tags ms --name test-mq tags toggle --addr 10.7.16.3:5672 --set role=leader,type=ram --reset role=peer,type=disk
# get commands and sub-commands help
consul-tags ms -h
# get help: -h or --help
consul-tags -h
Default consul address is consul.ops.local:8500, can be overriden with environment variable CONSUL_ADDR (host:port), too. Such as:
CONSUL_ADDR=127.0.0.1:8500 consul-tags ms --name=consul tags ls
# or
export CONSUL_HOST=ns2.company.domain:8500
consul-tags --help
# or
consul-tags --addr 127.0.0.1:8500 ms --name=consul tags ls
kv K/V pair Operations, ...
ms, service Microservice Operations, ...
help, h Shows a list of commands or help for one command
--addr HOST[:PORT], -a HOST[:PORT] Consul address and port: HOST[:PORT] (No leading 'http(s)://') (default: "consul.ops.local") [$CONSUL_ADDR]
--port value, -p value Consul port (default: 8500) [$CONSUL_PORT]
--prefix value Root key prefix (default: "/") [$CONSUL_PREFIX]
--cacert value, -r value Client CA cert [$CONSUL_CA_CERT]
--cert value, -t value Client cert [$CONSUL_CERT]
--scheme value, -s value Consul connection scheme (HTTP or HTTPS) (default: "http") [$CONSUL_SCHEME]
--insecure, -K Skip TLS host verification (default: false) [$CONSUL_INSECURE]
--username value, -U value HTTP Basic auth user [$CONSUL_USER]
--password value, -P value HTTP Basic auth password [$CONSUL_PASS]
--key value, -Y value Client key [$CONSUL_KEY]
--help, -h show help (default: false)
--init-completion value generate completion code. Value must be 'bash' or 'zsh'
--version, -v print the version (default: false)
with bonus from urfave/cli, you can install auto-completion for this binary:
eval "`consul-tags --init-completion bash`"
consul-tags --init-completion bash >> ~/.bashrc
or put it to /etc/bash_completion.d/:
cp bin/consul-tags /usr/local/bin/
/usr/local/bin/consul-tags --init-completion bash | sudo tee /etc/bash_completion.d/consul-tags
source /etc/bash_completion.d/consul-tags
See also Shell Completion.
zsh: DOC TODO
Mac: DOC TODO
my plan is building a suite of devops. consul operations is part of it. exception consul tags modifying operation, these codes ported in:
and some repositories are good:
Much more and mutable, not list here. But one of them:
MIT.
Content type
Image
Digest
sha256:d54362e3e…
Size
4 MB
Last updated
almost 2 years ago
docker pull hedzr/consul-tags