protected static String getPodJson(Pod pod) { try { return KubernetesHelper.toJson(pod); } catch (JsonProcessingException e) { LOG.warn("Could not convert pod to json: " + e, e); return null; } }
@POST @Path("processedtemplates") @Consumes({"application/json", "application/yaml"}) public String processTemplate(@PathParam("namespace") String namespace, Template entity) throws Exception { KubernetesList list = Templates.processTemplatesLocally(entity, false); return KubernetesHelper.toJson(list); }
@POST @Path("processedtemplates") @Consumes({"application/json", "application/yaml"}) public String processTemplate(@PathParam("namespace") String namespace, Template entity) throws Exception { KubernetesList list = Templates.processTemplatesLocally(entity, false); return KubernetesHelper.toJson(list); }
@Override public String findAppSummariesJson() throws JsonProcessingException { return KubernetesHelper.toJson(getAppSummaries()); }
protected void doWriteEntity(String path, Object entity) { try { String json = KubernetesHelper.toJson(entity); System.out.println("Writing to path: " + path + " createMode: " + createMode + " json: " + json); if (curator.checkExists().forPath(path) == null) { curator.create().withMode(createMode).forPath(path, json.getBytes()); } else { curator.setData().forPath(path, json.getBytes()); } } catch (Exception e) { throw new RuntimeException("Failed to update object at path: " + path + ". " + e, e); } }
protected void writeEntity(String path, Object entity) { try { String json = KubernetesHelper.toJson(entity); if (LOG.isDebugEnabled()) { LOG.debug("Writing to path: " + path + " json: " + json); } if (curator.checkExists().forPath(path) == null) { curator.create().creatingParentsIfNeeded().forPath(path, json.getBytes()); } else { curator.setData().forPath(path, json.getBytes()); } updateLocalModel(entity, false); } catch (Exception e) { throw new RuntimeException("Failed to update object at path: " + path + ". " + e, e); } }
public static Route createRouteForService(String routeDomainPostfix, String namespace, Service service, Logger log) { Route route = null; String id = KubernetesHelper.getName(service); if (Strings.isNotBlank(id) && shouldCreateRouteForService(log, service, id)) { route = new Route(); String routeId = id; KubernetesHelper.setName(route, namespace, routeId); RouteSpec routeSpec = new RouteSpec(); RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build(); //objectRef.setNamespace(namespace); routeSpec.setTo(objectRef); if (Strings.isNotBlank(routeDomainPostfix)) { // Let Openshift determine the route host when the domain is not set String host = Strings.stripSuffix(Strings.stripSuffix(id, "-service"), "."); String namespaceSuffix = "-" + namespace; routeSpec.setHost(host + namespaceSuffix + "." + Strings.stripPrefix(routeDomainPostfix, ".")); } route.setSpec(routeSpec); String json = null; try { json = KubernetesHelper.toJson(route); } catch (JsonProcessingException e) { json = e.getMessage() + ". object: " + route; } } return route; }