Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store binary data in etcd v3 using CLI

Tags:

etcd

It's simple to extract etcd data in json(base64) or hex formats with either -w json or --hex flags

ETCDCTL_API=3 etcdctl get /registry/secrets/myns/mykey --print-value-only --hex 
ETCDCTL_API=3 etcdctl get /registry/secrets/myns/mykey -w json 

But how can one write hex/json extracted data from another etcd instance via cli? etcdctl put doesn't accept any of these parameters and will store passed value as string

like image 318
Stan Yago Avatar asked Sep 11 '26 15:09

Stan Yago


1 Answers

etcd can take input from stdin, so the data can be piped in

GET the value in json(base64 encoded):

ETCDCTL_API=3 etcdctl get key -w json | jq .kvs[].value | tr -d \" > value.b64

PUT decoded value on the same/other etcd instance

base64 -D -i ./value.b64 | ETCDCTL_API=3 etcdctl put key
like image 95
Stan Yago Avatar answered Sep 24 '26 14:09

Stan Yago



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!