Created
March 20, 2017 22:47
-
-
Save tommysitu/6c9af9dbe1c4222a5815759abb43987c to your computer and use it in GitHub Desktop.
This file contains 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
@Component | |
public class K8sGateway { | |
private final RestTemplate restTemplate; | |
private final K8sConfig k8sConfig; | |
@Autowired | |
public K8sGateway(RestTemplate k8sRestTemplate, K8sConfig k8sConfig) { | |
this.restTemplate = k8sRestTemplate; | |
this.k8sConfig = k8sConfig; | |
} | |
public K8sService getService(final String k8sServiceName) { | |
final String uri = UriComponentsBuilder.fromHttpUrl(k8sConfig.getBaseUrl()) | |
.pathSegment("api", "v1", "namespaces", k8sConfig.getNamespace(), "services", k8sServiceName) | |
.toUriString(); | |
return restTemplate.getForEntity(uri, K8sService.class).getBody(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment