.endMetadata() .withNewSpec() .withReplicas(1) .withNewTemplate() .withNewMetadata()
.withNewSpec() .withStrategy(updateStrategy) .withReplicas(replicas) .withSelector(new LabelSelectorBuilder().withMatchLabels(getSelectorLabels()).build()) .withNewTemplate()
.addToMatchLabels("app", SystemtestsOpenshiftApp.MESSAGING_CLIENTS.toString()) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata()
private Deployment createDeployment(String appId, AppDeploymentRequest request, Map<String, String> idMap, int externalPort) { int replicas = getCountFromRequest(request); Map<String, String> annotations = getPodAnnotations(request); Map<String, String> deploymentLabels = getDeploymentLabels(request); PodSpec podSpec = createPodSpec(appId, request, externalPort, false); Deployment d = new DeploymentBuilder().withNewMetadata().withName(appId).withLabels(idMap) .addToLabels(SPRING_MARKER_KEY, SPRING_MARKER_VALUE).addToLabels(deploymentLabels).endMetadata() .withNewSpec().withNewSelector().addToMatchLabels(idMap).endSelector().withReplicas(replicas) .withNewTemplate().withNewMetadata().withLabels(idMap).addToLabels(SPRING_MARKER_KEY, SPRING_MARKER_VALUE) .addToLabels(deploymentLabels).withAnnotations(annotations).endMetadata().withSpec(podSpec).endTemplate() .endSpec().build(); return client.apps().deployments().create(d); }
@Override public boolean reap() { Deployment deployment = oper.cascading(false).edit().editSpec().withReplicas(0).endSpec().done(); //TODO: These checks shouldn't be used as they are not realistic. We just use them to support mock/crud tests. Need to find a cleaner way to do so. if (deployment.getStatus() != null) { waitForObservedGeneration(deployment.getStatus().getObservedGeneration()); } if (deployment.getSpec().getSelector() != null) { reapMatchingReplicaSets(deployment.getSpec().getSelector()); } return false; }
@Override public Deployment scale(int count, boolean wait) { Deployment res = cascading(false).edit().editSpec().withReplicas(count).endSpec().done(); if (wait) { waitUntilDeploymentIsScaled(count); res = getMandatory(); } return res; }