Skip to content

Instantly share code, notes, and snippets.

@tommysitu
Created March 20, 2017 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommysitu/6c9af9dbe1c4222a5815759abb43987c to your computer and use it in GitHub Desktop.
Save tommysitu/6c9af9dbe1c4222a5815759abb43987c to your computer and use it in GitHub Desktop.
@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