Envoy: malformed IP address: when using hostname

Created on 21 Feb 2018  路  9Comments  路  Source: envoyproxy/envoy

Description:

When trying to use a hostname as the address for a dns_resolver envoy fails to start with the error: [2018-02-21 15:55:25.801][1][critical][main] source/server/server.cc:72] error initializing configuration '/config/envoy.yaml': malformed IP address: kube-dns.kube-system.svc.cluster.local

Config line looks like:
...
static_resources:
...
clusters:
...
- name: xds_cluster
connect_timeout: 0.25s
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
hosts: [{ socket_address: { address: "discovery-service", port_value: 8454, resolver_name: "kube-dns.kube-system.svc.cluster.local" }}]
dns_resolvers: [{ socket_address: { address: "kube-dns.kube-system.svc.cluster.local", port_value: 53 }}]
...

beginner enhancement help wanted

Most helpful comment

what is final solution for this problem, i wanted to use resolver_name ,please give me working example..
Thanks in advance :)

All 9 comments

I don't believe you can use a hostname for your dns resolver - there's a bit of a bootstrapping problem there! Looking at the config the type is Address, which is either an actual (resolved) IP address/port pair, or a socket.

Ok, but if I take out the dns_resolvers: and resolvers_name: and leave this:
hosts: [{ socket_address: { address: "discovery-service", port_value: 8454 }}]

I still get [2018-02-21 16:24:46.627][1][critical][main] source/server/server.cc:72] error initializing configuration '/config/envoy.yaml': malformed IP address: discovery-service

Am I not able to use DNS hostnames at all?

I don't think you can use DNS hostnames for your discovery service, because you need a discovery service to resolve them. That's the bootstrapping problem I (incompletely) alluded to above. :-)

Edit: Oh, sorry I misread the question, you meant for your hosts. I'm pretty sure the problem there is that you're using the socket address to define it. One sec while I look up syntax!

So the documentation, which states
https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/core/address.proto.html#envoy-api-msg-core-socketaddress
address

For clusters, an address may be either an IP or hostname to be resolved via DNS.

this is not correct?

But isn't the hosts an Address, not a SocketAddress?
v2/cds.proto: repeated core.Address hosts = 7;

It's totally possible to ship traffic for a given route to a DNS hostname - I think a helpful example to get you going is
https://github.com/envoyproxy/envoy/blob/master/configs/google_com_proxy.v2.yaml
which aims traffic at "whatever google.com resolves to"
Check it out and see if it helps you?

The Host is of type Address but core.Address requires either a socket_address or a pipe be specified. https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/core/address.proto.html#envoy-api-msg-core-address

Also, if I copy just the cluster.host part of the example exactly (just to see if it passes validation) it doesn't pass validation.
[2018-02-21 18:43:12.704][1][critical][main] source/server/server.cc:72] error initializing configuration '/config/envoy.yaml': malformed IP address: google.com

@mstrcd I think you need to set the cluster type field to something like STRICT_DNS or LOGICAL_DNS, see https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/cds.proto.

I've seen this question multiple times. I think we probably need to make the error messages better here. I'm switching this over to enhancement/help wanted.

what is final solution for this problem, i wanted to use resolver_name ,please give me working example..
Thanks in advance :)

Was this page helpful?
0 / 5 - 0 ratings