Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

[WIP] Get endpoints for service instead of pods #11

Closed
wants to merge 2 commits into from
Closed

[WIP] Get endpoints for service instead of pods #11

wants to merge 2 commits into from

Conversation

pires
Copy link
Contributor

@pires pires commented May 9, 2015

This is work-in-progress to fix #9 and improve node-discovery efficiency.

@pires pires mentioned this pull request May 12, 2015
@pires
Copy link
Contributor Author

pires commented May 16, 2015

@jimmidyson sorry about the formatting changes and some cosmetic changes but I tried hard to keep up with your conventions. How does this look?

I'm going to need you help testing this with perhaps a snapshot release or something? I'm open to ideas.

// pod IP is a single IP Address. We need to build a TransportAddress from it
final TransportAddress[] addresses;
try {
addresses = transportService.addressesFromString(endpointIp.concat(":9300"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to get the port from the endpoint list?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this should be doable. See https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/api/types.go#L1091 ff for more details. Basically it's a Cartesian product between addresses and ports in each endpoint subset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'm hardcoding port 9300 and thus limiting the user choices here, I'm concerned that a multiport service will make it harder for us to determine which port to use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think using port 9300 for now is fine. Almost all deployments will use that I'm sure.

@jimmidyson
Copy link
Contributor

@pires Thanks for this. Overall looks good. I wonder if we could use fabric8 arquillian to add some integration tests for this? Happy to have that later though. For now you should be able to build locally & use in a local docker image? Don't like publishing snapshots personally & would rather not do that.

@pires
Copy link
Contributor Author

pires commented May 17, 2015

I wonder if we could use fabric8 arquillian to add some integration tests for this?

Probably would be a good thing to do. Would we need something like jube to actually bring Kubernetes up?

For now you should be able to build locally & use in a local docker image? Don't like publishing snapshots personally & would rather not do that.

OK. Will do that tomorrow then.

@jimmidyson
Copy link
Contributor

No - fabric8 arquillian can spin up pods in a kubernetes cluster for integration testing. See http://fabric8.io/guide/testing.html for more details. It's pretty awesome! We're using it in some CD scenarios & it works great. But like I said, this can come later - we will merge this once you're happy with it.

Let me know how your testing goes.

@mulloymorrow
Copy link

+1

@pires
Copy link
Contributor Author

pires commented May 26, 2015

I'm sorry, I have been overwhelmed with unrelated work.

For now you should be able to build locally & use in a local docker image?

Yes, will do this for now.
Unfortunately, I think I won't be able to look at Arquillian in the near future.

@mulloymorrow
Copy link

I'll try and look at Arquillian and test this out locally.

@pires
Copy link
Contributor Author

pires commented May 26, 2015

@mulloymorrow that would be A-W-E-S-O-M-E!

@mulloymorrow
Copy link

Can we merge this pull request with a new branch other than master? I'd like to include these commits in a fork for testing.

@jimmidyson
Copy link
Contributor

@mullowmorrow Perhaps @pires could add you as a collaborator on his fork?

// We can ignore it in the list of DiscoveryNode
logger.trace("current node found. Ignoring {} - {}", pod.getId(), podIp);
// get all endpoints for service
final Endpoints endpoints = getKubernetes().endpointsForService(this.selector, null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IAE thrown by kubernetes-api-2.1.0::KubernetesClient.validateNamespace: Template parameter set to null.

2015-05-28T18:17:16.071899300Z [2015-05-28 18:17:16,071][WARN ][io.fabric8.elasticsearch.discovery.k8s.K8sUnicastHostsProvider] [Cayman] Exception caught during discovery java.lang.IllegalArgumentException : Template parameter value is set to null
2015-05-28T18:17:16.071899300Z java.lang.IllegalArgumentException: Template parameter value is set to null
2015-05-28T18:17:16.071899300Z  at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:97)
2015-05-28T18:17:16.071899300Z  at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildFromEncoded(UriBuilderImpl.java:230)
2015-05-28T18:17:16.071899300Z  at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:180)
2015-05-28T18:17:16.071899300Z  at com.sun.proxy.$Proxy29.endpointsForService(Unknown Source)
2015-05-28T18:17:16.071899300Z  at io.fabric8.elasticsearch.discovery.k8s.K8sUnicastHostsProvider.getNodesFromKubernetesSelector(K8sUnicastHostsProvider.java:119)
2015-05-28T18:17:16.071899300Z  at io.fabric8.elasticsearch.discovery.k8s.K8sUnicastHostsProvider.buildDynamicNodes(K8sUnicastHostsProvider.java:102)
2015-05-28T18:17:16.071899300Z  at org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing.sendPings(UnicastZenPing.java:313)
2015-05-28T18:17:16.071899300Z  at org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing$2.doRun(UnicastZenPing.java:228)
2015-05-28T18:17:16.071899300Z  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:36)
2015-05-28T18:17:16.071899300Z  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2015-05-28T18:17:16.071899300Z  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2015-05-28T18:17:16.071899300Z  at java.lang.Thread.run(Thread.java:745)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to set a default namespace, like default.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing default

@jimmidyson
Copy link
Contributor

ok to test

@fusesource-ci
Copy link
Contributor

Can one of the admins verify this patch?

@fusesource-ci
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://fabric8-ci.fusesource.com/job/elasticsearch-cloud-pullreq/1/
Test FAILed.

@jimmidyson
Copy link
Contributor

retest this please

@fusesource-ci
Copy link
Contributor

Please comment with '[merge]' to automerge this request

@fusesource-ci
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://fabric8-ci.fusesource.com/job/elasticsearch-cloud-pullreq/2/
Test FAILed.

@jimmidyson
Copy link
Contributor

@pires @mulloymorrow I've merged this locally & made some changes to support your use case, getting endpoints from service name. I've tested & it works fine. Please can you review service-endpoints branch? If you're happy then I will merge this to master & release.

@mulloymorrow
Copy link

We're running in v1beta2, currently. Services in our environment can be found vi /api/v1beta2/services/<SERVICE_NAME>?namespace=default.

@jimmidyson
Copy link
Contributor

As v1beta1 & v1beta2 has been dropped from kubernetes we've removed those api versions from the fabric8 client, only supporting v1beta3 ATM. Soon that will change to only v1. Sorry but you'll need to upgrade your cluster in order to use this plugin going forward. We're targeting the v1 API in line with kubernetes 1.0 release.

@pires
Copy link
Contributor Author

pires commented May 30, 2015

I agree with Jimmi. You really need to upgrade.
On May 30, 2015 07:17, "Jimmi Dyson" notifications@github.com wrote:

As v1beta1 & v1beta2 has been dropped from kubernetes we've removed those
api versions from the fabric8 client, only supporting v1beta3 ATM. Soon
that will change to only v1. Sorry but you'll need to upgrade your cluster
in order to use this plugin going forward. We're targeting the v1 API in
line with kubernetes 1.0 release.


Reply to this email directly or view it on GitHub
#11 (comment)
.

@mulloymorrow
Copy link

Switched over to Gcloud! Will be testing there.

@pires
Copy link
Contributor Author

pires commented Jun 1, 2015

You mean GKE?

Also, I'm sorry for not updating this, but right now there's a lot going on regarding reading the Kubernetes API that will have an impact on a lot of the stuff I'm working on and most probably this project as well.

@jimmidyson did you check the elasticsearch example from @satnam6502 on the Kubernetes tree? They're using service-accounts for allowing secure access to the API and it seems read-only on an unsecure port will be dropped soon.

@mulloymorrow
Copy link

@pires , Yes. The Google Container Engine.

@jimmidyson
Copy link
Contributor

@pires I'm working on the fabric8 kubernetes API support for service accounts now, but that shouldn't stop this PR going through. Separate issue for that please.

@pires
Copy link
Contributor Author

pires commented Jun 2, 2015

@jimmidyson point taken service-endpoints branch works for me with Kubernetes 0.17.0 and 0.18.0, so looks good. Care to merge then?

@jimmidyson
Copy link
Contributor

@pires Cool thanks for the feedback. Btw seen the advice to use SRV records rather than API server calls?

@pires
Copy link
Contributor Author

pires commented Jun 2, 2015

@jimmidyson yes, but see kubernetes/kubernetes#9107. We should be able to work without DNS, because it's not something that is granted in every Kubernetes cluster.

@jimmidyson
Copy link
Contributor

@pires Agreed - was just pointing out that I prefer DNS if available.

@jimmidyson
Copy link
Contributor

Superseded by #12

@jimmidyson jimmidyson closed this Jun 2, 2015
@jimmidyson
Copy link
Contributor

Thanks @pires!

@pires
Copy link
Contributor Author

pires commented Jun 2, 2015

Thank you @jimmidyson

@mulloymorrow
Copy link

Thanks @pires @jimmidyson

@pires pires deleted the 9-endpoints_vs_pods branch October 26, 2016 17:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ES cluster cannot startup
4 participants