Skip to content

Instantly share code, notes, and snippets.

@Malinskiy
Created July 16, 2018 17:00
Show Gist options
  • Save Malinskiy/f5fe6d10a3a51dbb8764e051a4d78a15 to your computer and use it in GitHub Desktop.
Save Malinskiy/f5fe6d10a3a51dbb8764e051a4d78a15 to your computer and use it in GitHub Desktop.
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