confd
confd copied to clipboard
Can not read key from etcd if prefix not "/"
$ ETCDCTL_API=3 etcdctl --user=root:root --endpoints="https://127.0.0.1:32771" put someprefix/somekey "somevalue"
$ ETCDCTL_API=3 etcdctl --user=root:root --endpoints="https://127.0.0.1:32771" get "" --prefix --keys-only | grep some
someprefix/somekey
cat conf.d/listdomains.toml
[template]
src = "list_domains.tmpl"
dest = "/tmp/list_domains"
prefix = "someprefix"
keys = [
"/somekey"
]
cat templates/list_domains.tmpl
{{getv "someprefix/somekey"}}
root@nix-pc-10:/etc/confd# confd -backend etcdv3 -interval 3 -node https://127.0.0.1:32771
2018-07-12T11:33:51+03:00 nix-pc-10 confd[13761]: INFO Backend set to etcdv3
2018-07-12T11:33:51+03:00 nix-pc-10 confd[13761]: INFO Starting confd
2018-07-12T11:33:51+03:00 nix-pc-10 confd[13761]: INFO Backend source(s) set to https://127.0.0.1:32771
2018-07-12T11:33:51+03:00 nix-pc-10 confd[13761]: ERROR template: list_domains.tmpl:1:2: executing "list_domains.tmpl" at <getv "someprefix/som...>: error calling getv: key does not exist: someprefix/somekey
+1
@metanovii thanks for opening an issue! All keys are internally converted to a unified form by confd, so even if the key doesn't have a /
as a prefix it will, in fact, have a /
as a prefix after it was fetched by confd. Therefore, you can reference the key someprefix/somekey
as a /someprefix/somekey
in confd.
I try
{{getv "/someprefix/somekey"}}
and
{{getv "/someprefix/somekey"}}
and get
confd[10956]: ERROR template: list_domains.tmpl:1:2: executing "list_domains.tmpl" at <getv "/someprefix/so...>: error calling getv: key does not exist: /someprefix/somekey
I’m having the same problem! K8s POD confd log follow
2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: DEBUG Loading template resources from confdir /etc/confd 2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: DEBUG Found template: /etc/confd/conf.d/..2019_01_29_07_15_13.065511479/config/haproxy-confd.toml 2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: DEBUG Loading template resource from /etc/confd/conf.d/..2019_01_29_07_15_13.065511479/config/haproxy-confd.toml 2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: DEBUG Retrieving keys from store 2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: DEBUG Key prefix set to / 2019-01-29T07:26:14Z kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1.cloud.ibm confd[6]: ERROR 100: Key not found (/gitlabsvc) [7]
my template file
[template] src = "haproxy-config.tmpl" dest = "/usr/local/etc/haproxy/haproxy.cfg" prefix = "/" keys = [ "/gitlabsvc" ] reload_cmd = "/etc/init.d/haproxy reload"
root@kube-hou02-pac543edaf18b546c1add5ab5abb795627-w1:/etcd-v3.3.11-linux-amd64# ./etcdctl --cacert=/etc/confd/ssl/etcd-ca --cert=/etc/confd/ssl/etcd-cert --key=/etc/confd/ssl/etcd-key --endpoints=https://172.20.0.x:2041 get gitlabsvc gitlabsvc 172.21.0.x
guys you can try my fork https://github.com/zyf0330/confd/, I have removed this annoying feature.