Search in sources :

Example 1 with DeploymentTriggerPolicyBuilder

use of io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder in project strimzi by strimzi.

the class KafkaConnectS2ICluster method generateDeploymentConfig.

/**
 * Generate new DeploymentConfig
 *
 * @return      Source ImageStream resource definition
 */
public DeploymentConfig generateDeploymentConfig() {
    Container container = new ContainerBuilder().withName(name).withImage(image).withEnv(getEnvVars()).withPorts(Collections.singletonList(createContainerPort(REST_API_PORT_NAME, REST_API_PORT, "TCP"))).withLivenessProbe(createHttpProbe(healthCheckPath, REST_API_PORT_NAME, healthCheckInitialDelay, healthCheckTimeout)).withReadinessProbe(createHttpProbe(healthCheckPath, REST_API_PORT_NAME, healthCheckInitialDelay, healthCheckTimeout)).build();
    DeploymentTriggerPolicy configChangeTrigger = new DeploymentTriggerPolicyBuilder().withType("ConfigChange").build();
    DeploymentTriggerPolicy imageChangeTrigger = new DeploymentTriggerPolicyBuilder().withType("ImageChange").withNewImageChangeParams().withAutomatic(true).withContainerNames(name).withNewFrom().withKind("ImageStreamTag").withName(image).endFrom().endImageChangeParams().build();
    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder().withType("Rolling").withNewRollingParams().withMaxSurge(new IntOrString(1)).withMaxUnavailable(new IntOrString(0)).endRollingParams().build();
    DeploymentConfig dc = new DeploymentConfigBuilder().withNewMetadata().withName(name).withLabels(getLabelsWithName()).withNamespace(namespace).endMetadata().withNewSpec().withReplicas(replicas).withNewTemplate().withNewMetadata().withLabels(getLabelsWithName()).endMetadata().withNewSpec().withContainers(container).endSpec().endTemplate().withTriggers(configChangeTrigger, imageChangeTrigger).withStrategy(updateStrategy).endSpec().build();
    return dc;
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) DeploymentConfigBuilder(io.fabric8.openshift.api.model.DeploymentConfigBuilder) DeploymentStrategyBuilder(io.fabric8.openshift.api.model.DeploymentStrategyBuilder) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentTriggerPolicy(io.fabric8.openshift.api.model.DeploymentTriggerPolicy) DeploymentTriggerPolicyBuilder(io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder) DeploymentStrategy(io.fabric8.openshift.api.model.DeploymentStrategy)

Example 2 with DeploymentTriggerPolicyBuilder

use of io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder in project syndesis-qe by syndesisio.

the class ExternalDatabase method deploy.

@Override
public void deploy() {
    OpenShiftUtils.getInstance().deploymentConfigs().createOrReplaceWithNew().withNewMetadata().withName(NAME).withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().withReplicas(1).withNewTemplate().withNewMetadata().withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().withContainers(new ContainerBuilder().withEnv(new EnvVar("POSTGRESQL_DATABASE", "testdb", null), new EnvVar("POSTGRESQL_PASSWORD", "testpassword", null), new EnvVar("POSTGRESQL_USER", "testuser", null)).withPorts(new ContainerPortBuilder().withContainerPort(5432).withProtocol("TCP").build()).withName(NAME).withImage(" ").build()).endSpec().endTemplate().withSelector(TestUtils.map("app", NAME)).withTriggers(new DeploymentTriggerPolicyBuilder().withNewImageChangeParams().withContainerNames(NAME).withFrom(new ObjectReferenceBuilder().withKind("ImageStreamTag").withName("postgresql:12").withNamespace("openshift").build()).withAutomatic(true).endImageChangeParams().withNewType("ImageChange").build()).endSpec().done();
    OpenShiftUtils.getInstance().services().createOrReplaceWithNew().withNewMetadata().withName(NAME).withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().addToPorts(new ServicePortBuilder().withNewName("5432-tcp").withNewTargetPort(5432).withNewProtocol("TCP").withPort(5432).build()).addToSelector(TestUtils.map("app", NAME)).endSpec().done();
    // create a needed secret with the password
    OpenShiftUtils.getInstance().secrets().createOrReplaceWithNew().withNewMetadata().withName("syndesis-global-config").endMetadata().withStringData(TestUtils.map("POSTGRESQL_PASSWORD", "testpassword")).withNewType("Opaque").done();
}
Also used : ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) ObjectReferenceBuilder(io.fabric8.kubernetes.api.model.ObjectReferenceBuilder) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) DeploymentTriggerPolicyBuilder(io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder)

Aggregations

ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)2 DeploymentTriggerPolicyBuilder (io.fabric8.openshift.api.model.DeploymentTriggerPolicyBuilder)2 Container (io.fabric8.kubernetes.api.model.Container)1 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)1 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 ObjectReferenceBuilder (io.fabric8.kubernetes.api.model.ObjectReferenceBuilder)1 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)1 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)1 DeploymentConfigBuilder (io.fabric8.openshift.api.model.DeploymentConfigBuilder)1 DeploymentStrategy (io.fabric8.openshift.api.model.DeploymentStrategy)1 DeploymentStrategyBuilder (io.fabric8.openshift.api.model.DeploymentStrategyBuilder)1 DeploymentTriggerPolicy (io.fabric8.openshift.api.model.DeploymentTriggerPolicy)1