Created
July 16, 2018 17:00
-
-
Save Malinskiy/f5fe6d10a3a51dbb8764e051a4d78a15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String calculateConfig(Map configData) { | |
def brothers = [] | |
Endpoints endpoints = kubernetesClient.endpoints() | |
.inNamespace(namespaceName) | |
.withName(serviceName) | |
.get() | |
List < EndpointSubset > endpointItems = endpoints.getSubsets() | |
endpointItems.each { | |
subset -> | |
def brotherPort = subset.getPorts().find { it.name == 'http'}.port | |
subset.getAddresses().each { address -> | |
def ip = address.getIp() | |
if (ip != localIp) { | |
brothers << "http://$ip:$brotherPort/repository/" | |
} | |
} | |
} | |
return createConfig( configData, brothers) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment