io.fabric8.kubernetes.api.model.apps.DeploymentSpecFluent Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.apps.DeploymentSpecFluent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageEnricher.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
private void ensureTemplateSpecsInDeployments(KubernetesListBuilder builder) {
    builder.accept(new TypedVisitor<DeploymentBuilder>() {
        @Override
        public void visit(DeploymentBuilder item) {
            DeploymentFluent.SpecNested<DeploymentBuilder> spec =
                item.buildSpec() == null ? item.withNewSpec() : item.editSpec();
            DeploymentSpecFluent.TemplateNested<DeploymentFluent.SpecNested<DeploymentBuilder>> template =
                spec.buildTemplate() == null ? spec.withNewTemplate() : spec.editTemplate();
            template.endTemplate().endSpec();
        }
    });
}
 
Example #2
Source File: KubernetesHistoryServerDeployer.java    From spark-operator with Apache License 2.0 5 votes vote down vote up
private Deployment getDeployment(SparkHistoryServer hs, Map<String, String> labels) {
    String volumeName = "history-server-volume";

    ContainerBuilder containerBuilder = new ContainerBuilder().withName("history-server")
            .withImage(Optional.ofNullable(hs.getCustomImage()).orElse(getDefaultSparkImage()))
            .withCommand(Arrays.asList("/bin/sh", "-xc"))
            .withArgs("mkdir /tmp/spark-events || true ; /entrypoint ls ; /opt/spark/bin/spark-class org.apache.spark.deploy.history.HistoryServer")
            .withEnv(env("SPARK_HISTORY_OPTS", getHistoryOpts(hs)))
            .withPorts(new ContainerPortBuilder().withName("web-ui").withContainerPort(hs.getInternalPort()).build());
    if (HistoryServerHelper.needsVolume(hs) && null != hs.getSharedVolume()) {
        containerBuilder = containerBuilder.withVolumeMounts(new VolumeMountBuilder().withName(volumeName).withMountPath(hs.getSharedVolume().getMountPath()).build());
    }
    Container historyServerContainer = containerBuilder.build();

    PodTemplateSpecFluent.SpecNested<DeploymentSpecFluent.TemplateNested<DeploymentFluent.SpecNested<DeploymentBuilder>>> deploymentBuilder = new DeploymentBuilder()
            .withNewMetadata().withName(hs.getName()).withLabels(labels).endMetadata()
            .withNewSpec().withReplicas(1).withNewSelector().withMatchLabels(labels).endSelector()
            .withNewStrategy().withType("Recreate").endStrategy()
            .withNewTemplate().withNewMetadata().withLabels(labels).endMetadata()
            .withNewSpec().withServiceAccountName("spark-operator")
            .withContainers(historyServerContainer);
    if (HistoryServerHelper.needsVolume(hs) && null != hs.getSharedVolume()) {
        deploymentBuilder = deploymentBuilder.withVolumes(new VolumeBuilder().withName(volumeName).withNewPersistentVolumeClaim()
                .withReadOnly(false).withClaimName(hs.getName() + "-claim").endPersistentVolumeClaim().build());
    }
    Deployment deployment = deploymentBuilder.endSpec().endTemplate().endSpec().build();

    return deployment;
}
 
Example #3
Source File: ApplyReplicasDecorator.java    From dekorate with Apache License 2.0 4 votes vote down vote up
@Override
public void andThenVisit(DeploymentSpecFluent deploymentSpec, ObjectMeta resourceMeta) {
  if (replicas > 0) {
    deploymentSpec.withReplicas(replicas);
  }
}
 
Example #4
Source File: ApplyLabelSelectorDecorator.java    From dekorate with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(DeploymentSpecFluent deploymentSpec) {
 deploymentSpec.withSelector(labelSelector);
}