0

In kubernetes 1.6,the information store in etcd v3,I use "etcdctl get" command to get the information as follow: enter image description here

my question is how to deserialize the information?how to deserialize the information by "protoc --raw" command?I read the paper on a website:

"You have the unusual data we caught and fixed in Prevent protobuf storage with etcd2, which is base64 encoded protobuf (etcd2 does not support storing binary values). In 1.6 we default to etcd3 mode, which supports binary values, and defaults to storing in "application/vnd.kubernetes.protobuf" which is the following form for the values

4 bytes - k8s\x00 protobuf encoding of runtime.Unknown (pkg/runtime/types.go#Unknown) * the "typeMeta" field set to the same values of kind and apiVersion that would be returned from the API * the "raw" field set to the protobuf encoded bytes for the golang struct identified by typeMeta - no magic number

You can decode this with:

head -4 (strip the magic number) | protoc --raw (decodes the proto)

You can then decode the raw body using protoc as wel."

but I don't know how to perform it,is there any one know that?

Jay
  • 113
  • 8

1 Answers1

1

try this one

ETCDCTL_API=3 etcdctl get /registry/namespaces/default -w protobuf | protoc --decode_raw

output should be like following

1 {
  1: 14841639068965178418
  2: 10276657743932975437
  3: 7839988
  4: 2
}
2 {
  1: "/registry/namespaces/default"
  2: 11
  3: 11
  4: 1
  5: "k8s\000\n\017\n\002v1\022\tNamespace\022c\nI\n\007default\022\000\032\000\"\000*$20b6cdfa-9929-11e7-8b62-005056b549b62\0008\000B\014\010\305\203\351\315\005\020\221\356\217\314\003z\000\022\014\n\nkubernetes\032\010\n\006Active\032\000\"\000"
}
4: 1

BTW, I did not find related proto file in the kubernetes source.

silverfox
  • 5,254
  • 1
  • 21
  • 26