Add _gce_ network host setting#13612
Conversation
|
For information, I just tested it on GCE platform. Without With But it fails with Will push a fix. Note that we can also add Will update the PR. |
|
Was doing some more tests. Actually even if a VM is accessible externally using it's public IP address, you can't assign this IP: So it does not really make sense to support |
_gce_ network host setting
This fix imported from elastic#13612
|
@bleskes Do you think you can review this? |
a37a898 to
1fcee31
Compare
docs/plugins/cloud-gce.asciidoc
Outdated
There was a problem hiding this comment.
why not call this hostname, using the same name GCE uses?
There was a problem hiding this comment.
I actually used the same naming as we have for ec2. But I agree.
|
@bleskes Updated to address your comments. Thanks for the review! |
There was a problem hiding this comment.
I fined the hostname part of the naming confusing (as it is just one of the options to use). can we call this GceAddressResolverType or something else?
|
Thx David for implementing this. I left some comments. My biggest concern is that we are hard wired to to the first 0 interface. I glimpsed the doc and could find this to be guaranteed by google. Does it? If so, we need to document what we do. If not, we need to retrieve all of the interfaces and chose the first (in a predictable order) and document that. |
|
Hey @bleskes I added a new commit:
|
Do we really need this leniency? Can we just support one? |
docs/plugins/cloud-gce.asciidoc
Outdated
There was a problem hiding this comment.
can we try and use google terminology here? they call this network interface. Also - are we sure 0 is always/95% of the time is there? I'm afraid that the OOB behavior will be bad..
b73f7ce to
0c258a3
Compare
|
@bleskes I pushed a new commit (and rebased BTW). Let me know. |
|
I dont see anything guaranteeing that the "first interface" is a private address. I don't think we should solve the problem this way, its too arbitrary and risky. Instead we should add |
|
@rmuir I presume you refer to #13969 , I respond here to make sure it's all in the same place, but if we continue the discussion (and it does refer to the other ticket), lets continue it there. The
From the docs about what a network is:
So it seems we're good here? @dadoonet I failed to find the reference for the exact metadta url you are using. Can you dig it up for future reference? |
|
@bleskes @rmuir actually when you query metadata: You get back something like (I'm hiding non relevant parts): {
"hostname":"blabla.projectname.internal",
"networkInterfaces":[
{
"accessConfigs":[
{
"externalIp":"104.155.53.203",
"type":"ONE_TO_ONE_NAT"
}
],
"forwardedIps":[
],
"ip":"10.240.0.2",
"network":"projects/896329523726/networks/default"
}
]
}The Is there any method which can "double-check" that the IP we get is actually non routable on internet - so it's a private one? If so, I could add a safe-guard and either stop the process or put a big WARN saying that the |
|
Also, it's confirmed by running this command: $ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
cfp europe-west1-b n1-standard-2 10.240.0.2 104.155.53.203 RUNNING |
I don't agree with a warning or any leniency like this. I don't know how we are going from binding to localhost by default, to potentially binding to a public address by default, just with a warning. I don't want to see this PR rushed through, I am very concerned about this. |
|
@dadoonet if you bind to the internal IP for gce, can you confirm external traffic is blocked? IIRC for aws, there was routing magic that made external requests look like they were going to the internal ip (but I might be confused and it was just the ip address was always the internal). |
|
@rjernst Thanks. So here is what I did:
So I guess it's "bad" as we only bound to the private IP so it should not be accessible from a public IP, right? |
That's what I would expect, yes. Sounds like routing trickery... |
|
I hear your @rmuir. I can only see two choices:
My comments apply only if your PR #13954 is merged obviously. Any other solution I could try to implement? |
|
For GCE i do not think Basically I don't think we should bind to anything publicly reachable. I'd really rather us just be consistent and bind to |
|
Can we separate the "add GCE resolver logic", "add better exception handling for custom resolvers", "add lots of GCE tests" which are all in this PR, and seem like good changes, from the changing of the default, and just make a separate issue for that? |
|
Just a note:
The current PR is not about adding So I think we are all on the same page here. |
|
LGTM. Thx @dadoonet |
When running in GCE platform, an instance has access to: http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip Which gives back the private IP address, for example `10.240.0.2`. http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/externalIp Gives back the public Ip address, for example `130.211.108.21`. As we have for `ec2`, we can support new network host settings: * `_gce:privateIp:X_`: The private IP address of the machine for a given network interface. * `_gce:hostname_`: The hostname of the machine. * `_gce_`: Same as `_gce:privateIp:0_` (recommended). Closes elastic#13605. Closes elastic#13590. BTW resolveIfPossible now throws IOException so code is also updated for ec2 discovery and some basic tests have been added.
09e84b6 to
289cd5d
Compare
|
Cool! Rebased and tested. Just need now to apply the changes to 2.x, 2.1 and 2.0: |
When running in GCE platform, an instance has access to:
http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip
Which gives back the private IP address, for example
10.240.0.2.http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/externalIp
Gives back the public Ip address, for example
130.211.108.21.As we have for
ec2, we can support new network host settings:_gce:privateIp:X_: The private IP address of the machine for a given network interface._gce:hostname_: The hostname of the machine._gce_: Same as_gce:privateIp:0_(recommended).Closes #13605.
Closes #13590.
BTW resolveIfPossible now throws IOException so code is also updated for ec2 discovery and
some basic tests have been added.