private ReplicationController getReplicationController() { ReplicationController contr = new ReplicationController(); contr.setId("kubernetes-test-controller"); State desiredState = new State(); desiredState.setReplicas(2); Selector selector = new Selector(); selector.setName("kubernetes-test-controller-selector"); desiredState.setReplicaSelector(selector); Pod podTemplate = new Pod(); State podState = new State(); Manifest manifest = new Manifest(); manifest.setId(contr.getId()); Container container = new Container(); container.setName("kubernetes-test"); container.setImage(dockerImage); Port p = new Port(); p.setContainerPort(80); container.setPorts(Collections.singletonList(p)); container.setCommand("tail", "-f", "/dev/null"); manifest.setContainers(Collections.singletonList(container)); podState.setManifest(manifest); podTemplate.setDesiredState(podState); podTemplate.setLabels(ImmutableMap.of("name", selector.getName())); desiredState.setPodTemplate(podTemplate); contr.setDesiredState(desiredState); contr.setLabels(podTemplate.getLabels()); return contr; }
private Service getService() { Service serv = new Service(); serv.setContainerPort("8379"); serv.setPort(5000); serv.setId("kubernetes-test-service"); serv.setLabels(ImmutableMap.of("name", "kubernetes-test-service-label")); serv.setName("kubernetes-test-service-name"); Selector selector = new Selector(); selector.setName(serv.getLabels().get("name")); serv.setSelector(selector); return serv; }