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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With