Search in sources :

Example 1 with SpringBootConfigurationHelper

use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.

the class SpringBootGenerator method getDefaultWebPort.

@Override
protected String getDefaultWebPort() {
    Properties properties = SpringBootUtil.getSpringBootApplicationProperties(SpringBootUtil.getSpringBootActiveProfile(getProject()), JKubeProjectUtil.getClassLoader(getProject()));
    SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getProject()));
    return properties.getProperty(propertyHelper.getServerPortPropertyKey(), super.getDefaultWebPort());
}
Also used : SpringBootConfigurationHelper(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper) Properties(java.util.Properties)

Example 2 with SpringBootConfigurationHelper

use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.

the class AbstractSpringBootHealthCheckEnricherTestSupport method init.

@Before
public void init() {
    String version = getSpringBootVersion();
    this.propertyHelper = new SpringBootConfigurationHelper(Optional.of(version));
    new Expectations() {

        {
            context.getDependencyVersion(SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID, SpringBootConfigurationHelper.SPRING_BOOT_ARTIFACT_ID);
            result = Optional.of(version);
        }
    };
}
Also used : Expectations(mockit.Expectations) SpringBootConfigurationHelper(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper) Before(org.junit.Before)

Example 3 with SpringBootConfigurationHelper

use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.

the class SpringBootHealthCheckEnricher method buildProbe.

protected Probe buildProbe(Properties springBootProperties, Integer initialDelay, Integer period, Integer timeout, Integer failureTh, Integer successTh) {
    SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(getContext().getDependencyVersion(SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID, SpringBootConfigurationHelper.SPRING_BOOT_ARTIFACT_ID));
    Integer managementPort = propertyHelper.getManagementPort(springBootProperties);
    boolean usingManagementPort = managementPort != null;
    Integer port = managementPort;
    if (port == null) {
        port = propertyHelper.getServerPort(springBootProperties);
    }
    String scheme;
    String prefix;
    if (usingManagementPort) {
        scheme = StringUtils.isNotBlank(springBootProperties.getProperty(propertyHelper.getManagementKeystorePropertyKey())) ? SCHEME_HTTPS : SCHEME_HTTP;
        prefix = springBootProperties.getProperty(propertyHelper.getManagementContextPathPropertyKey(), "");
    } else {
        scheme = StringUtils.isNotBlank(springBootProperties.getProperty(propertyHelper.getServerKeystorePropertyKey())) ? SCHEME_HTTPS : SCHEME_HTTP;
        prefix = springBootProperties.getProperty(propertyHelper.getServerContextPathPropertyKey(), "");
        prefix += springBootProperties.getProperty(propertyHelper.getServletPathPropertyKey(), "");
        prefix += springBootProperties.getProperty(propertyHelper.getManagementContextPathPropertyKey(), "");
    }
    String actuatorBasePathKey = propertyHelper.getActuatorBasePathPropertyKey();
    String actuatorBasePath = propertyHelper.getActuatorDefaultBasePath();
    if (actuatorBasePathKey != null) {
        actuatorBasePath = springBootProperties.getProperty(actuatorBasePathKey, actuatorBasePath);
    }
    // lets default to adding a spring boot actuator health check
    ProbeBuilder probeBuilder = new ProbeBuilder().withNewHttpGet().withNewPort(port).withPath(normalizeMultipleSlashes(prefix + actuatorBasePath + Configs.asString(getConfig(Config.PATH)))).withScheme(scheme).endHttpGet();
    if (initialDelay != null) {
        probeBuilder = probeBuilder.withInitialDelaySeconds(initialDelay);
    }
    if (period != null) {
        probeBuilder = probeBuilder.withPeriodSeconds(period);
    }
    if (timeout != null) {
        probeBuilder.withTimeoutSeconds(timeout);
    }
    if (failureTh != null) {
        probeBuilder.withFailureThreshold(failureTh);
    }
    if (successTh != null) {
        probeBuilder.withSuccessThreshold(successTh);
    }
    return probeBuilder.build();
}
Also used : ProbeBuilder(io.fabric8.kubernetes.api.model.ProbeBuilder) SpringBootConfigurationHelper(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper)

Example 4 with SpringBootConfigurationHelper

use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.

the class SpringBootWatcher method getPortForwardUrl.

String getPortForwardUrl(final String namespace, final Collection<HasMetadata> resources) {
    LabelSelector selector = KubernetesHelper.extractPodLabelSelector(resources);
    if (selector == null) {
        log.warn("Unable to determine a selector for application pods");
        return null;
    }
    Properties properties = SpringBootUtil.getSpringBootApplicationProperties(JKubeProjectUtil.getClassLoader(getContext().getBuildContext().getProject()));
    SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getContext().getBuildContext().getProject()));
    int localHostPort = IoUtil.getFreeRandomPort();
    int containerPort = propertyHelper.getServerPort(properties);
    portForwardService.forwardPortAsync(selector, namespace, containerPort, localHostPort);
    return createForwardUrl(propertyHelper, properties, localHostPort);
}
Also used : SpringBootConfigurationHelper(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) Properties(java.util.Properties)

Aggregations

SpringBootConfigurationHelper (org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper)4 Properties (java.util.Properties)2 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)1 ProbeBuilder (io.fabric8.kubernetes.api.model.ProbeBuilder)1 Expectations (mockit.Expectations)1 Before (org.junit.Before)1