Search in sources :

Example 26 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project jointware by isdream.

the class KubernetesKeyValueStyleGeneratorTest method testOpenShiftWithAllKind.

protected static void testOpenShiftWithAllKind() throws Exception {
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Policy());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Group());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new User());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthClient());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ClusterRoleBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ImageStreamTag());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new ImageStream());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Build());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new BuildConfig());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new RoleBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Route());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new PolicyBinding());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthAuthorizeToken());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Role());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new Project());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new OAuthAccessToken());
    info(OPENSHIFT_KIND, OpenShiftDocumentKeyValueStyleGenerator.class.getName(), new DeploymentConfig());
}
Also used : NetworkPolicy(io.fabric8.kubernetes.api.model.extensions.NetworkPolicy) Policy(io.fabric8.openshift.api.model.Policy) Group(io.fabric8.openshift.api.model.Group) User(io.fabric8.openshift.api.model.User) OAuthClient(io.fabric8.openshift.api.model.OAuthClient) ClusterRoleBinding(io.fabric8.openshift.api.model.ClusterRoleBinding) ImageStreamTag(io.fabric8.openshift.api.model.ImageStreamTag) ImageStream(io.fabric8.openshift.api.model.ImageStream) PolicyBinding(io.fabric8.openshift.api.model.PolicyBinding) OAuthAuthorizeToken(io.fabric8.openshift.api.model.OAuthAuthorizeToken) Role(io.fabric8.openshift.api.model.Role) Project(io.fabric8.openshift.api.model.Project) Build(io.fabric8.openshift.api.model.Build) OpenShiftDocumentKeyValueStyleGenerator(com.github.isdream.chameleon.docs.OpenShiftDocumentKeyValueStyleGenerator) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) OAuthAccessToken(io.fabric8.openshift.api.model.OAuthAccessToken) ClusterRoleBinding(io.fabric8.openshift.api.model.ClusterRoleBinding) RoleBinding(io.fabric8.openshift.api.model.RoleBinding) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Route(io.fabric8.openshift.api.model.Route)

Example 27 with DeploymentConfig

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

the class KafkaConnectS2IClusterTest method testGenerateDeploymentConfig.

@Test
public void testGenerateDeploymentConfig() {
    DeploymentConfig dep = kc.generateDeploymentConfig();
    assertEquals(kc.kafkaConnectClusterName(cluster), dep.getMetadata().getName());
    assertEquals(namespace, dep.getMetadata().getNamespace());
    Map<String, String> expectedLabels = ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, this.cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.kafkaConnectClusterName(cluster));
    assertEquals(expectedLabels, dep.getMetadata().getLabels());
    assertEquals(new Integer(replicas), dep.getSpec().getReplicas());
    assertEquals(expectedLabels, dep.getSpec().getTemplate().getMetadata().getLabels());
    assertEquals(1, dep.getSpec().getTemplate().getSpec().getContainers().size());
    assertEquals(kc.kafkaConnectClusterName(this.cluster), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getName());
    assertEquals(kc.kafkaConnectClusterName(this.cluster) + ":latest", dep.getSpec().getTemplate().getSpec().getContainers().get(0).getImage());
    assertEquals(getExpectedEnvVars(), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv());
    assertEquals(new Integer(healthDelay), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getInitialDelaySeconds());
    assertEquals(new Integer(healthTimeout), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getTimeoutSeconds());
    assertEquals(new Integer(healthDelay), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getInitialDelaySeconds());
    assertEquals(new Integer(healthTimeout), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getTimeoutSeconds());
    assertEquals(1, dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().size());
    assertEquals(new Integer(KafkaConnectCluster.REST_API_PORT), dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getContainerPort());
    assertEquals(KafkaConnectCluster.REST_API_PORT_NAME, dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getName());
    assertEquals("TCP", dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getProtocol());
    assertEquals(2, dep.getSpec().getTriggers().size());
    assertEquals("ConfigChange", dep.getSpec().getTriggers().get(0).getType());
    assertEquals("ImageChange", dep.getSpec().getTriggers().get(1).getType());
    assertEquals(true, dep.getSpec().getTriggers().get(1).getImageChangeParams().getAutomatic());
    assertEquals(1, dep.getSpec().getTriggers().get(1).getImageChangeParams().getContainerNames().size());
    assertEquals(kc.kafkaConnectClusterName(this.cluster), dep.getSpec().getTriggers().get(1).getImageChangeParams().getContainerNames().get(0));
    assertEquals(kc.kafkaConnectClusterName(this.cluster) + ":latest", dep.getSpec().getTriggers().get(1).getImageChangeParams().getFrom().getName());
    assertEquals("ImageStreamTag", dep.getSpec().getTriggers().get(1).getImageChangeParams().getFrom().getKind());
    assertEquals("Rolling", dep.getSpec().getStrategy().getType());
    assertEquals(new Integer(1), dep.getSpec().getStrategy().getRollingParams().getMaxSurge().getIntVal());
    assertEquals(new Integer(0), dep.getSpec().getStrategy().getRollingParams().getMaxUnavailable().getIntVal());
}
Also used : DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test)

Example 28 with DeploymentConfig

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

the class KafkaConnectS2ICluster method fromAssembly.

/**
 * Create a Kafka Connect cluster from the deployed Deployment resource
 *
 * @param namespace Kubernetes/OpenShift namespace where cluster resources belong to
 * @param cluster   overall cluster name
 * @param dep The deployment from which to recover the cluster state
 * @param sis ImageStream
 * @return  Kafka Connect cluster instance
 */
public static KafkaConnectS2ICluster fromAssembly(String namespace, String cluster, DeploymentConfig dep, ImageStream sis) {
    KafkaConnectS2ICluster kafkaConnect = new KafkaConnectS2ICluster(namespace, cluster, Labels.fromResource(dep));
    kafkaConnect.setReplicas(dep.getSpec().getReplicas());
    kafkaConnect.setHealthCheckInitialDelay(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getInitialDelaySeconds());
    kafkaConnect.setHealthCheckTimeout(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getTimeoutSeconds());
    Map<String, String> vars = containerEnvVars(dep.getSpec().getTemplate().getSpec().getContainers().get(0));
    kafkaConnect.setBootstrapServers(vars.getOrDefault(KEY_BOOTSTRAP_SERVERS, DEFAULT_BOOTSTRAP_SERVERS));
    kafkaConnect.setGroupId(vars.getOrDefault(KEY_GROUP_ID, DEFAULT_GROUP_ID));
    kafkaConnect.setKeyConverter(vars.getOrDefault(KEY_KEY_CONVERTER, DEFAULT_KEY_CONVERTER));
    kafkaConnect.setKeyConverterSchemasEnable(Boolean.parseBoolean(vars.getOrDefault(KEY_KEY_CONVERTER_SCHEMAS_EXAMPLE, String.valueOf(DEFAULT_KEY_CONVERTER_SCHEMAS_EXAMPLE))));
    kafkaConnect.setValueConverter(vars.getOrDefault(KEY_VALUE_CONVERTER, DEFAULT_VALUE_CONVERTER));
    kafkaConnect.setValueConverterSchemasEnable(Boolean.parseBoolean(vars.getOrDefault(KEY_VALUE_CONVERTER_SCHEMAS_EXAMPLE, String.valueOf(DEFAULT_VALUE_CONVERTER_SCHEMAS_EXAMPLE))));
    kafkaConnect.setConfigStorageReplicationFactor(Integer.parseInt(vars.getOrDefault(KEY_CONFIG_STORAGE_REPLICATION_FACTOR, String.valueOf(DEFAULT_CONFIG_STORAGE_REPLICATION_FACTOR))));
    kafkaConnect.setOffsetStorageReplicationFactor(Integer.parseInt(vars.getOrDefault(KEY_OFFSET_STORAGE_REPLICATION_FACTOR, String.valueOf(DEFAULT_OFFSET_STORAGE_REPLICATION_FACTOR))));
    kafkaConnect.setStatusStorageReplicationFactor(Integer.parseInt(vars.getOrDefault(KEY_STATUS_STORAGE_REPLICATION_FACTOR, String.valueOf(DEFAULT_STATUS_STORAGE_REPLICATION_FACTOR))));
    String sourceImage = sis.getSpec().getTags().get(0).getFrom().getName();
    kafkaConnect.setImage(sourceImage);
    return kafkaConnect;
}
Also used : IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Example 29 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig 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 30 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project fabric8-maven-plugin by fabric8io.

the class ResourceMojo method lateInit.

private void lateInit() throws MojoExecutionException {
    if (goalFinder.runningWithGoal(project, session, "fabric8:watch") || goalFinder.runningWithGoal(project, session, "fabric8:watch")) {
        Properties properties = project.getProperties();
        properties.setProperty("fabric8.watch", "true");
    }
    platformMode = clusterAccess.resolvePlatformMode(mode, log);
    log.info("Running in [[B]]%s[[B]] mode", platformMode.getLabel());
    if (isOpenShiftMode()) {
        Properties properties = project.getProperties();
        if (!properties.contains(DOCKER_IMAGE_USER)) {
            String namespace = clusterAccess.getNamespace();
            log.info("Using docker image name of namespace: " + namespace);
            properties.setProperty(DOCKER_IMAGE_USER, namespace);
        }
        if (!properties.contains(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE)) {
            properties.setProperty(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE, platformMode.toString());
        }
    }
    openShiftConverters = new HashMap<>();
    openShiftConverters.put("ReplicaSet", new ReplicSetOpenShiftConverter());
    openShiftConverters.put("Deployment", new DeploymentOpenShiftConverter(platformMode, getOpenshiftDeployTimeoutSeconds()));
    // TODO : This converter shouldn't be here. See its javadoc.
    openShiftConverters.put("DeploymentConfig", new DeploymentConfigOpenShiftConverter(getOpenshiftDeployTimeoutSeconds()));
    openShiftConverters.put("Namespace", new NamespaceOpenShiftConverter());
    handlerHub = new HandlerHub(project);
}
Also used : NamespaceOpenShiftConverter(io.fabric8.maven.plugin.converter.NamespaceOpenShiftConverter) DeploymentConfigOpenShiftConverter(io.fabric8.maven.plugin.converter.DeploymentConfigOpenShiftConverter) DeploymentOpenShiftConverter(io.fabric8.maven.plugin.converter.DeploymentOpenShiftConverter) Properties(java.util.Properties) ReplicSetOpenShiftConverter(io.fabric8.maven.plugin.converter.ReplicSetOpenShiftConverter) HandlerHub(io.fabric8.maven.core.handler.HandlerHub)

Aggregations

DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)30 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)10 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 Test (org.junit.Test)9 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)8 Service (io.fabric8.kubernetes.api.model.Service)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)7 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)7 ReplicaSet (io.fabric8.kubernetes.api.model.extensions.ReplicaSet)7 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)7 DeploymentConfigSpec (io.fabric8.openshift.api.model.DeploymentConfigSpec)6 ImageStream (io.fabric8.openshift.api.model.ImageStream)6 IOException (java.io.IOException)6 Controller (io.fabric8.kubernetes.api.Controller)5 Pod (io.fabric8.kubernetes.api.model.Pod)5 DeploymentSpec (io.fabric8.kubernetes.api.model.extensions.DeploymentSpec)5 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)4 ReplicaSetSpec (io.fabric8.kubernetes.api.model.extensions.ReplicaSetSpec)4 Route (io.fabric8.openshift.api.model.Route)4