for (int i = 0; i < 2; i++) { System.err.println("Iteration:" + (i+1)); Deployment deployment = new DeploymentBuilder() .withNewMetadata() .withName("nginx") .endMetadata() .withNewSpec() .withReplicas(1) .withNewTemplate() .endSelector() .endSpec() .build();
public Deployment getDeployment(ResourceConfig config, List<ImageConfiguration> images) { Deployment deployment = new DeploymentBuilder() .withMetadata(createDeploymentMetaData(config)) .withSpec(createDeploymentSpec(config, images)) .build(); return deployment; }
@Override protected ObjectMeta getOrCreateMetadata(DeploymentBuilder item) { return item.hasMetadata() ? item.buildMetadata() : item.withNewMetadata().endMetadata().buildMetadata(); } }
protected void doCreateDeployment(Exchange exchange, String operation) throws Exception { Deployment deployment = null; String deploymentName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENT_NAME, String.class); String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class); DeploymentSpec deSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENT_SPEC, DeploymentSpec.class); if (ObjectHelper.isEmpty(deploymentName)) { LOG.error("Create a specific Deployment require specify a Deployment name"); throw new IllegalArgumentException("Create a specific Deployment require specify a pod name"); } if (ObjectHelper.isEmpty(namespaceName)) { LOG.error("Create a specific Deployment require specify a namespace name"); throw new IllegalArgumentException("Create a specific Deployment require specify a namespace name"); } if (ObjectHelper.isEmpty(deSpec)) { LOG.error("Create a specific Deployment require specify a Deployment spec bean"); throw new IllegalArgumentException("Create a specific Deployment require specify a Deployment spec bean"); } Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENTS_LABELS, Map.class); Deployment deploymentCreating = new DeploymentBuilder().withNewMetadata().withName(deploymentName).withLabels(labels).endMetadata().withSpec(deSpec).build(); deployment = getEndpoint().getKubernetesClient().apps().deployments().inNamespace(namespaceName).create(deploymentCreating); MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true); exchange.getOut().setBody(deployment); }
@Override protected Deployment resource() { return new DeploymentBuilder().withNewMetadata().withNamespace(NAMESPACE).withName(RESOURCE_NAME).endMetadata().build(); }
if (!switchOnLocalCustomisation) { resource1OrCopy = new DeploymentBuilder(resource1OrCopy).build();
@Override public void visit(DeploymentBuilder resource) { DeploymentFluent.MetadataNested<DeploymentBuilder> metadata = resource.editMetadata(); if (metadata == null) { resource.withNewMetadata().withName(defaultName).endMetadata(); } else { if (StringUtils.isBlank(metadata.getName())) { metadata.withName(defaultName).endMetadata(); } } } });
@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(); } });
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); }
private static Deployment getMessagingClientDeploymentResource() { return new DeploymentBuilder() .withNewMetadata() .withName(SystemtestsOpenshiftApp.MESSAGING_CLIENTS.toString()) .endMetadata() .withNewSpec() .withNewSelector() .addToMatchLabels("app", SystemtestsOpenshiftApp.MESSAGING_CLIENTS.toString()) .endTemplate() .endSpec() .build();
List<Volume> volumes) { Deployment dep = new DeploymentBuilder() .withNewMetadata() .withName(name) .withLabels(getLabelsWithName(templateDeploymentLabels)) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withStrategy(updateStrategy) .withReplicas(replicas) .endTemplate() .endSpec() .build();