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());
}
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());
}
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;
}
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;
}
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);
}
Aggregations