@Override public boolean reap() { DeploymentConfig deployment = operation.cascading(false).edit().editSpec().withReplicas(0).endSpec().done(); //TODO: These checks shouldn't be used as they are not realistic. We just use them to support mock/crud tests. Need to find a cleaner way to do so. if (deployment.getStatus() != null) { waitForObservedGeneration(deployment.getStatus().getObservedGeneration()); } //We are deleting the DC before reaping the replication controller, because the RC's won't go otherwise. Boolean reaped = operation.cascading(false).delete(); // Waiting for the DC to be completely deleted before removing the replication controller (error in Openshift 3.9) waitForDeletion(); Map<String, String> selector = new HashMap<>(); selector.put(DEPLOYMENT_CONFIG_REF, deployment.getMetadata().getName()); if (selector != null && !selector.isEmpty()) { Boolean deleted = new ReplicationControllerOperationsImpl(client, operation.getConfig(), operation.getNamespace()) .withLabels(selector) .delete(); } return reaped; }
@Override public void scale(String name, Map<String, String> labels, int desiredReplicas, long amount, TimeUnit timeUnit) throws InterruptedException { String sName = openshiftName(name); getDeploymentsByLabel(labels) .stream() .filter(d -> d.getMetadata().getName().equals(sName)) .map(d -> new DeploymentConfigBuilder(d).editSpec().withReplicas(desiredReplicas).endSpec().build()) .findAny().ifPresent(d -> openShiftClient.deploymentConfigs().createOrReplace(d)); }
@Override public void scale(String name, int desiredReplicas) { final String sName = Names.sanitize(name); LOGGER.debug("Scale {}", sName); openShiftClient.deploymentConfigs().withName(sName).edit() .editSpec() .withReplicas(desiredReplicas) .endSpec() .done(); }
.withType("ConfigChange") .endTrigger() .endSpec() .withNewStatus().withLatestVersion(1L).endStatus() .build();
specBuilder.endSpec();
.endImageChangeParams() .endTrigger() .endSpec() .done();
.endImageChangeParams() .endTrigger() .endSpec() .done();
.withTriggers(configChangeTrigger, imageChangeTrigger) .withStrategy(updateStrategy) .endSpec() .build(); return dc;
.addToSelector("name", deploymentName) .withTemplate(template) .endSpec() .build(); client.deploymentConfigs().inNamespace(namespace).create(deployment);
@Override public HasMetadata convert(HasMetadata item, boolean trimImageInContainerSpec, boolean enableAutomaticTrigger) { if (item instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) item; if (openshiftDeployTimeoutSeconds != null && openshiftDeployTimeoutSeconds > 0) { DeploymentConfigBuilder builder = new DeploymentConfigBuilder(resource); DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder> specBuilder; if (resource.getSpec() != null) { specBuilder = builder.editSpec(); } else { specBuilder = builder.withNewSpec(); } specBuilder.withNewStrategy().withType("Rolling"). withNewRollingParams().withTimeoutSeconds(openshiftDeployTimeoutSeconds).endRollingParams().endStrategy(); specBuilder.endSpec(); return builder.build(); } } return item; } }
@Override public boolean reap() { DeploymentConfig deployment = operation.cascading(false).edit().editSpec().withReplicas(0).endSpec().done(); //TODO: These checks shouldn't be used as they are not realistic. We just use them to support mock/crud tests. Need to find a cleaner way to do so. if (deployment.getStatus() != null) { waitForObservedGeneration(deployment.getStatus().getObservedGeneration()); } //We are deleting the DC before reaping the replication controller, because the RC's won't go otherwise. Boolean reaped = operation.cascading(false).delete(); // Waiting for the DC to be completely deleted before removing the replication controller (error in Openshift 3.9) waitForDeletion(); Map<String, String> selector = new HashMap<>(); selector.put(DEPLOYMENT_CONFIG_REF, deployment.getMetadata().getName()); if (selector != null && !selector.isEmpty()) { Boolean deleted = new ReplicationControllerOperationsImpl(client, operation.getConfig(), operation.getNamespace()) .withLabels(selector) .delete(); } return reaped; }
@Override protected DeploymentConfig resource() { return new DeploymentConfigBuilder().withNewMetadata() .withNamespace(NAMESPACE) .withName(RESOURCE_NAME) .endMetadata() .withNewSpec() .withNewTemplate() .withNewSpec() .addToContainers(new ContainerBuilder().withImage("img").build()) .endSpec() .endTemplate() .endSpec().build(); }
@Override public DeploymentConfig scale(int count, boolean wait) { DeploymentConfig deployment = cascading(false).edit().editSpec().withReplicas(count).endSpec().done(); if (wait) { waitUntilDeploymentConfigIsScaled(count); deployment = getMandatory(); } return deployment; }
@Override public void visit(DeploymentConfigBuilder item) { DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder> spec = item.getSpec() == null ? item.withNewSpec() : item.editSpec(); DeploymentConfigSpecFluent.TemplateNested<DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder>> template = spec.getTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } });
@Override public void visit(DeploymentConfigBuilder b) { b.editOrNewSpec().withReplicas(1).endSpec(); } });
@Override public void visit(DeploymentConfigBuilder item) { DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder> spec = item.getSpec() == null ? item.withNewSpec() : item.editSpec(); DeploymentConfigSpecFluent.TemplateNested<DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder>> template = spec.getTemplate() == null ? spec.withNewTemplate() : spec.editTemplate(); template.endTemplate().endSpec(); } });
.endSpec() .endTemplate() .endSpec() .done());
@Override public DeploymentConfig scale(int count, boolean wait) { DeploymentConfig deployment = cascading(false).edit().editSpec().withReplicas(count).endSpec().done(); if (wait) { waitUntilDeploymentConfigIsScaled(count); deployment = getMandatory(); } return deployment; }