private Pod getPod() { Pod pod = new Pod(); pod.setId("kubernetes-test-pod"); pod.setLabels(ImmutableMap.of("name", "kubernetes-test-pod-label", "label1", "value1")); State desiredState = new State(); Manifest m = new Manifest(); m.setId(pod.getId()); Container c = new Container(); c.setName("master"); c.setImage(dockerImage); c.setCommand("tail", "-f", "/dev/null"); Port p = new Port(8379, new Random().nextInt((65535 - 49152) + 1) + 49152, "0.0.0.0"); c.setPorts(Collections.singletonList(p)); m.setContainers(Collections.singletonList(c)); desiredState.setManifest(m); pod.setDesiredState(desiredState); return pod; }
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; }