Public | Automated Build

Last pushed: a year ago
Short Description
a tool for managing consul service tags (clear, add, remove, toggle).
Full Description

Consul Service Tags Modifier






<!-- [![GitHub tag](https://img.shields.io/github/tag/hedzr/consul-tags.svg)]() -->
<!-- [![ImageLayers Size](https://img.shields.io/imagelayers/image-size/hedzr/consul-tags/latest.svg)]() -->

consul-tags can add, remove tag(s) of a consul service (one or all its instances).

Here is a first release for key functionality.

Install

Binary

Download binary from Release page.

Docker Hub

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

Go Build

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

Usage

# 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 

COMMANDS:

     kv           K/V pair Operations, ...
     ms, service  Microservice Operations, ...
     help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:

   --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)

Shell completion

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

Thanks

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:

Third-party repos

Much more and mutable, not list here. But one of them:

License

MIT.

Docker Pull Command
Owner
hedzr
Source Repository