@Before public void setup() throws Exception { final Pod pod = new Pod("v1", "Pod", new ObjectMeta(), new PodSpec(), null); final ResourceHolder resourceHolder = new ResourceHolder(pod); when(openShiftClient.build(anyObject())).thenReturn(resourceHolder); when(openShiftClient.getClientExt()).thenReturn(openShiftClientExt); when(openShiftClientExt.routes()).thenReturn(routeOperations); when(routeOperations.list()).thenReturn(new RouteList()); when(cubeOpenShiftConfiguration.isNamespaceCleanupEnabled()).thenReturn(true); buildablePodCube = injectorInst.get().inject(new BuildablePodCube(pod, openShiftClient, cubeOpenShiftConfiguration)); buildablePodCube.holder = resourceHolder; }
private PodTemplateSpec createPodTemplateSpec(Map<String, String> labels, List<Container> containers, MountSecret mountSecret) throws Exception { PodTemplateSpec pts = new PodTemplateSpec(); ObjectMeta objectMeta = new ObjectMeta(); pts.setMetadata(objectMeta); objectMeta.setLabels(labels); PodSpec ps = new PodSpec(); pts.setSpec(ps); ps.setContainers(containers); mountSecret(ps, mountSecret); return pts; }
public String deployPod(String name, String env, RCContext context) throws Exception { List<Container> containers = getContainers(name, context); PodSpec podSpec = new PodSpec(); podSpec.setContainers(containers); Map<String, String> podLabels = new HashMap<>(); podLabels.put("name", name + "-pod"); podLabels.putAll(context.getLabels()); ObjectMeta metadata = new ObjectMeta(); metadata.setName(name + "-pod"); metadata.setLabels(podLabels); mountSecret(podSpec, context.getMountSecret()); Pod pod = new Pod(); pod.setApiVersion(configuration.getApiVersion()); pod.setMetadata(metadata); pod.setSpec(podSpec); return client.pods().inNamespace(configuration.getNamespace()).create(pod).getMetadata().getName(); }
private ReplicationController createReplicationController(String name, String apiVersion, Map<String, String> labels, int replicas, Map<String, String> selector, PodTemplateSpec podTemplate) throws Exception { ReplicationController rc = new ReplicationController(); rc.setApiVersion(apiVersion); ObjectMeta objectMeta = new ObjectMeta(); rc.setMetadata(objectMeta); objectMeta.setName(name); objectMeta.setLabels(labels); ReplicationControllerSpec spec = new ReplicationControllerSpec(); rc.setSpec(spec); spec.setReplicas(replicas); spec.setSelector(selector); spec.setTemplate(podTemplate); return rc; }