@Override public String updateReplicationController(@PathParam("controllerId") @NotNull String s, ReplicationController replicationController, @QueryParam("namespace") String s1) throws Exception { getOrCreateMetadata(replicationController).setNamespace(namespace); return updateReplicationController(s, replicationController); }
@Override public String updatePod(@NotNull String podId, Pod pod, String namespace) throws Exception { getOrCreateMetadata(pod).setNamespace(namespace); return updatePod(podId, pod); }
@Override public String updateService(@NotNull String serviceId, Service service, String namespace) throws Exception { getOrCreateMetadata(service).setNamespace(namespace); return updateService(serviceId, service); }
@Override public String createReplicationController(ReplicationController replicationController, String namespace) throws Exception { getOrCreateMetadata(replicationController).setNamespace(namespace); return createReplicationController(replicationController); }
@Override public String createService(Service service, String namespace) throws Exception { getOrCreateMetadata(service).setNamespace(namespace); return createService(service); }
@Override public String createPod(Pod pod, String namespace) throws Exception { getOrCreateMetadata(pod).setNamespace(namespace); return createPod(pod); }
protected <T extends HasMetadata> void updateNamed(String namespace, String name, T entity) throws IOException { File entityFile = getResourceFile(namespace, name, entity.getClass()); ObjectMeta metadata = KubernetesHelper.getOrCreateMetadata(entity); metadata.setNamespace(namespace); metadata.setName(name); if (entityFile != null) { KubernetesHelper.saveJson(entityFile, entity); // TODO sendEvent(entity); } else { throw new WebApplicationException("No metadata.name supplied!"); } }
protected <T extends HasMetadata> void updateNamed(String namespace, String name, T entity) throws IOException { File entityFile = getResourceFile(namespace, name, entity.getClass()); ObjectMeta metadata = KubernetesHelper.getOrCreateMetadata(entity); metadata.setNamespace(namespace); metadata.setName(name); if (entityFile != null) { KubernetesHelper.saveJson(entityFile, entity); // TODO sendEvent(entity); } else { throw new WebApplicationException("No metadata.name supplied!"); } }
public String updateReplicationController(@NotNull String controllerId, ReplicationController replicationController) throws Exception { // lets ensure there's a default namespace set String namespace = KubernetesHelper.getNamespace(replicationController); if (Strings.isBlank(namespace)) { getOrCreateMetadata(replicationController).setNamespace(DEFAULT_NAMESPACE); } model.updateReplicationController(controllerId, replicationController); return null; }
private static void cleanupItem(KubernetesClient client, Session session, HasMetadata item, List<Throwable> errors) { String sessionNamespace = session.getNamespace(); KubernetesHelper.getOrCreateMetadata(item).setNamespace(sessionNamespace); client.resource(item).inNamespace(sessionNamespace).cascading(true).delete(); }
protected static Build createBuild(BuildCorrelationKey key) { Build build = new Build(); build.setMetadata(new ObjectMeta()); build.getMetadata().setName(key.getBuildName()); build.getMetadata().setNamespace(key.getNamespace()); build.getMetadata().setUid(key.getBuildUuid()); BuildStatus status = new BuildStatus(); status.setCompletionTimestamp(new Date().toString()); build.setStatus(status); return build; } }
protected Service createService(final String namespace, final String serviceName, Map<String, String> labels) { labels = normalizeLabels(labels); final Service service = new Service(); final ObjectMeta metadata = new ObjectMeta(); metadata.setNamespace(normalizeNamespace(namespace)); metadata.setName(normalizeServiceName(serviceName)); metadata.setLabels(labels); service.setMetadata(metadata); service.setSpec(this.createServiceSpec(labels)); return service; }
protected Service createService(final String namespace, final String serviceName, Map<String, String> labels) { labels = normalizeLabels(labels); final Service service = new Service(); final ObjectMeta metadata = new ObjectMeta(); metadata.setNamespace(normalizeNamespace(namespace)); metadata.setName(normalizeServiceName(serviceName)); metadata.setLabels(labels); service.setMetadata(metadata); service.setSpec(this.createServiceSpec(labels)); return service; }
private Service getHttpService() { Map<String, String> labels = new LinkedHashMap<>(); labels.put("service-type", "http-endpoint"); ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid"); metadata.setNamespace("my-project"); metadata.setLabels(labels); ServiceSpec spec = new ServiceSpec(); ServicePort port = new ServicePort(); port.setTargetPort(new IntOrString(80)); port.setPort(8080); spec.setPorts(Collections.singletonList(port)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(spec); return service; }
private Service getHttpService() { Map<String, String> labels = new LinkedHashMap<>(); labels.put("service-type", "http-endpoint"); ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-http-service"); metadata.setUid("uuid-1"); metadata.setNamespace("my-project"); metadata.setLabels(labels); ServiceSpec spec = new ServiceSpec(); ServicePort port = new ServicePort(); port.setTargetPort(new IntOrString(80)); port.setPort(8080); spec.setPorts(Collections.singletonList(port)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(spec); return service; }
private Service getHttpService() { Map<String, String> labels = new LinkedHashMap<>(); labels.put("service-type", "http-endpoint"); ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid"); metadata.setNamespace("my-project"); metadata.setLabels(labels); ServiceSpec spec = new ServiceSpec(); ServicePort port = new ServicePort(); port.setTargetPort(new IntOrString(80)); port.setPort(8080); spec.setPorts(Collections.singletonList(port)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(spec); return service; }
private Service getSimpleService() { ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid-2"); metadata.setNamespace("my-project"); ServiceSpec spec = new ServiceSpec(); ServicePort port = new ServicePort(); port.setTargetPort(new IntOrString(8080)); port.setPort(1524); spec.setPorts(Collections.singletonList(port)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(spec); return service; }
private Service getSimpleService() { ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid-2"); metadata.setNamespace("my-project"); ServiceSpec spec = new ServiceSpec(); ServicePort port = new ServicePort(); port.setTargetPort(new IntOrString(8080)); port.setPort(1524); spec.setPorts(Collections.singletonList(port)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(spec); return service; }
private Service getExternalService(int port) { ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid"); metadata.setNamespace("my-project"); ServiceSpec serviceSpec = new ServiceSpec(); ServicePort servicePort = new ServicePort(); servicePort.setPort(port); serviceSpec.setType("ExternalName"); serviceSpec.setExternalName("my-external-service"); serviceSpec.setPorts(Collections.singletonList(servicePort)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(serviceSpec); return service; }
private Service getExternalService(int port) { ObjectMeta metadata = new ObjectMeta(); metadata.setName("my-service"); metadata.setUid("uuid"); metadata.setNamespace("my-project"); ServiceSpec serviceSpec = new ServiceSpec(); ServicePort servicePort = new ServicePort(); servicePort.setPort(port); serviceSpec.setType("ExternalName"); serviceSpec.setExternalName("my-external-service"); serviceSpec.setPorts(Collections.singletonList(servicePort)); Service service = new Service(); service.setMetadata(metadata); service.setSpec(serviceSpec); return service; }