Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kubernetesClient.apps().deployments()
- .inNamespace(resource.getMetadata().getNamespace())
- .createOrReplace(
- new DeploymentBuilder()
- .withNewMetadata()
- .addToLabels(APP_NAME, name)
- .addToLabels(APP_INSTANCE, properties.getInstance())
- .addToLabels(APP_VERSION, properties.getVersion())
- .addToLabels(APP_MANAGED, "deus-operator")
- .endMetadata()
- .withSpec(
- new DeploymentSpecBuilder()
- .withReplicas(resource.getSpec().getReplicas())
- .withNewSelector()
- .addToMatchLabels(APP_NAME, name)
- .addToMatchLabels(APP_INSTANCE, properties.getInstance())
- .endSelector()
- .withTemplate(
- new PodTemplateSpecBuilder()
- .withNewMetadata()
- .addToLabels(APP_NAME, name)
- .addToLabels(APP_INSTANCE, properties.getInstance())
- .endMetadata()
- .withSpec(
- new PodSpecBuilder()
- // .withAffinity() // TODO
- .withContainers(
- new ContainerBuilder()
- .withName(name)
- .withImage(Optional.ofNullable(properties.getRepository())
- .filter(StringUtils::isNotBlank)
- .map(s -> s + "/")
- .orElse("") + "deus/apache-iframe:" + properties.getImageVersion())
- .withPorts(
- new ContainerPortBuilder()
- .withName("apache-http")
- .withContainerPort(80)
- .build())
- .withVolumeMounts(
- add(
- resource.getSpec().getUrls().stream()
- .filter(urlDefinition ->
- StringUtils.isNotBlank(urlDefinition.getName()))
- .filter(urlDefinition ->
- NAME_PATTERN.matcher(urlDefinition.getName()).matches())
- .map(urlDefinition ->
- new VolumeMountBuilder()
- .withName(urlDefinition.getName())
- .withMountPath("/usr/local/apache2/conf.d/" + urlDefinition.getName() + ".conf")
- .withSubPath(urlDefinition.getName() + ".conf")
- .build())
- .collect(Collectors.toList()),
- new VolumeMountBuilder()
- .withName("timezone")
- .withMountPath("/etc/localtime")
- .build())
- )
- .build())
- .withVolumes(
- add(
- resource.getSpec().getUrls().stream()
- .filter(urlDefinition ->
- StringUtils.isNotBlank(urlDefinition.getName()))
- .filter(urlDefinition ->
- NAME_PATTERN.matcher(urlDefinition.getName()).matches())
- .map(urlDefinition ->
- new VolumeBuilder()
- .withName(urlDefinition.getName())
- .withNewConfigMap()
- .withName(urlDefinition.getName())
- .addNewItem(urlDefinition.getName(), null, urlDefinition.getName() + ".conf")
- .endConfigMap()
- .build())
- .collect(Collectors.toList()),
- new VolumeBuilder()
- .withName("timezone")
- .withNewHostPath("/usr/share/zoneinfo/" + properties.getTimeZone(), null)
- .build())
- )
- .build())
- .build())
- .build())
- .build());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement