kelseyhightower / confd

Manage local application configuration files using templates and data from etcd or consul
MIT License
8.33k stars 1.41k forks source link

Parsing protobuf etcdv3 keys #699

Open Sudneo opened 6 years ago

Sudneo commented 6 years ago

Hello,

I am having troubles parsing keys from ETCDv3 to get the endpoints of Kubernetes api servers. I understood that Kubernetes now stores keys in etcd3 in protobuf format, therefore when I extract the keys with confd, I obtain something like:

[test]
data = k8s

v1      Endpointss
O

kubernetesdefault"*$f261a458-398f-11e8-ba0a-0cc47a7451282���z 

        10.4.0.82
https�2TCP" 

This is the result this simple configuration:

confd -onetime -backend etcdv3 -node http://127.0.0.1:2379

src = "test.conf.tmpl"
dest = "/tmp/test.conf"
keys = [
    "/registry/services/endpoints/default/kubernetes",
]

and

data = {{ get "/registry/services/endpoints/default/kubernetes"}}

Is there any way this problem can be overcome or we need to rely on custom scripting (which is a bad solution in general)?

okushchenko commented 6 years ago

I think it would be an antipattern to rely on the internal format used by Kubernetes in Etcd. There is an open PR with the new backend specifically for Kubernetes, it's not merged though, but you can still check it out by building it from source. #649

Sudneo commented 6 years ago

Ye, I can see that point. Etcd2 though has been deprecated since k8s 1.9 and soon will be removed. This basically means that confd will not be natively usable in k8s environments soon.

Am I correct?

hubo1016 commented 6 years ago

applications should use external interfaces instead of internal storage

okushchenko commented 6 years ago

It's not working ever since Kubernetes 1.6.0 (release in March 2017) moved to the Protobufs based encoding of data in Etcd. https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.6.md