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); }