.withReplicas(1) .withNewTemplate() .withNewMetadata() .addToLabels("app", "nginx") .endMetadata() .withNewSpec() .addNewContainer() .withName("nginx") .endContainer() .endSpec() .endTemplate() .withNewSelector() .addToMatchLabels("app", "nginx")
.withReplicas(1) .withNewTemplate() .withNewMetadata() .addToLabels("app", SystemtestsOpenshiftApp.MESSAGING_CLIENTS.toString()) .endMetadata() .withNewSpec() .addNewContainer() .withName(SystemtestsOpenshiftApp.MESSAGING_CLIENTS.toString()) .endContainer() .endSpec() .endTemplate() .endSpec() .build();
.withSelector(new LabelSelectorBuilder().withMatchLabels(getSelectorLabels()).build()) .withNewTemplate() .withNewMetadata() .withLabels(getLabelsWithName(templatePodLabels)) .withAnnotations(mergeAnnotations(podAnnotations, templatePodAnnotations)) .endMetadata() .withNewSpec() .withAffinity(affinity) .withServiceAccountName(getServiceAccountName()) .withSecurityContext(templateSecurityContext) .endSpec() .endTemplate() .endSpec() .build();
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 void visit(DeploymentBuilder deploymentBuilder) { deploymentBuilder.editOrNewSpec().editOrNewTemplate().editOrNewSpec().endSpec().endTemplate().endSpec(); mergeDeploymentSpec(deploymentBuilder, spec); } });
@Override public void visit(DeploymentBuilder item) { DeploymentFluent.SpecNested<DeploymentBuilder> spec = item.getSpec() == null ? item.withNewSpec() : item.editSpec(); DeploymentSpecFluent.TemplateNested<DeploymentFluent.SpecNested<DeploymentBuilder>> template = spec.getTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } });