Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

etcd v3 can't read encoded values

I'm trying to retrieve values from etcd v3 in a kubernetes cluster. The values appear to be encoded and don't come back complete. When -w simple, the value comes back with a lot of question marks in little diamonds. When using -w json, the value comes back like this:

ubuntu@k8s-master-0:~$ etcdctl --endpoints=https://127.0.0.1:2379 -w json get /registry/services/specs/default/kubernetes-bootcamp
{"header":{"cluster_id":13533136872321707204,"member_id":12171258639343793897,"revision":1142056,"raft_term":53},"kvs":[{"key":"L3JlZ2lzdHJ5L3NlcnZpY2VzL3NwZWNzL2RlZmF1bHQva3ViZXJuZXRlcy1ib290Y2FtcA==","create_revision":863556,"mod_revision":863556,"version":1,"value":"azhzAAoNCgJ2MRIHU2VydmljZRLaAQp3ChNrdWJlcm5ldGVzLWJvb3RjYW1wEgAaB2RlZmF1bHQiACokNzBhNDdlZDgtODFjZS0xMWU3LWE2ZGMtZmExNjNlYmZlNzM5MgA4AEILCLOmzMwFEOaHwTdaGgoDcnVuEhNrdWJlcm5ldGVzLWJvb3RjYW1wegASWwoXCgASA1RDUBiYPyIHCAAQkD8aACjR+QESGgoDcnVuEhNrdWJlcm5ldGVzLWJvb3RjYW1wGgwxMC4yMzMuNTIuNzEiDExvYWRCYWxhbmNlcjoETm9uZUIAUgAaAgoAGgAiAA=="}],"count":1}

The key and value appear to be encoded, but I can't find a way to get the plain text value back.

How can I get the plain text value for a given key?

like image 779
Daniel Watrous Avatar asked Mar 17 '26 00:03

Daniel Watrous


1 Answers

A bit late to the show but here is how I was able to do that. Because in etcd pre-v3 the data was stored in plain json and since v3 it is in binary format the additional decode step is needed.

You may check this repo for details: https://github.com/jpbetz/auger

And here are Kubernetes docs regarding protobuf encoding

And the working example is:

etcdctl get "/registry/pods/default/nginx-dbddb74b8-62hh7" --prefix -w simple | auger decode

Now the response is plain-text:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container
      nginx'
  creationTimestamp: 2019-08-12T14:11:57Z
...
like image 175
esboych Avatar answered Mar 20 '26 01:03

esboych



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!