Search in sources :

Example 1 with KubernetesConfiguration

use of org.apache.camel.component.kubernetes.KubernetesConfiguration in project camel by apache.

the class ServiceCallClientRouteTest method createRouteBuilder.

@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            KubernetesConfiguration kubernetesConfiguration = new KubernetesConfiguration();
            kubernetesConfiguration.setMasterUrl("http://172.28.128.80:8080");
            kubernetesConfiguration.setUsername("admin");
            kubernetesConfiguration.setPassword("admin");
            kubernetesConfiguration.setNamespace("default");
            ServiceCallConfigurationDefinition config = new ServiceCallConfigurationDefinition();
            config.setServiceDiscovery(new KubernetesEnvServiceDiscovery(kubernetesConfiguration));
            // register configuration
            context.setServiceCallConfiguration(config);
            from("direct:start").serviceCall("cdi-camel-jetty").serviceCall("cdi-camel-jetty").to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) KubernetesConfiguration(org.apache.camel.component.kubernetes.KubernetesConfiguration) ServiceCallConfigurationDefinition(org.apache.camel.model.cloud.ServiceCallConfigurationDefinition)

Example 2 with KubernetesConfiguration

use of org.apache.camel.component.kubernetes.KubernetesConfiguration in project camel by apache.

the class KubernetesClientServiceDiscovery method doStart.

@Override
protected void doStart() throws Exception {
    if (client != null) {
        return;
    }
    final KubernetesConfiguration configuration = getConfiguration();
    ConfigBuilder builder = new ConfigBuilder();
    builder.withMasterUrl(configuration.getMasterUrl());
    if ((ObjectHelper.isNotEmpty(configuration.getUsername()) && ObjectHelper.isNotEmpty(configuration.getPassword())) && ObjectHelper.isEmpty(configuration.getOauthToken())) {
        builder.withUsername(configuration.getUsername());
        builder.withPassword(configuration.getPassword());
    } else {
        builder.withOauthToken(configuration.getOauthToken());
    }
    if (ObjectHelper.isNotEmpty(configuration.getCaCertData())) {
        builder.withCaCertData(configuration.getCaCertData());
    }
    if (ObjectHelper.isNotEmpty(configuration.getCaCertFile())) {
        builder.withCaCertFile(configuration.getCaCertFile());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientCertData())) {
        builder.withClientCertData(configuration.getClientCertData());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientCertFile())) {
        builder.withClientCertFile(configuration.getClientCertFile());
    }
    if (ObjectHelper.isNotEmpty(configuration.getApiVersion())) {
        builder.withApiVersion(configuration.getApiVersion());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientKeyAlgo())) {
        builder.withClientKeyAlgo(configuration.getClientKeyAlgo());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientKeyData())) {
        builder.withClientKeyData(configuration.getClientKeyData());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientKeyFile())) {
        builder.withClientKeyFile(configuration.getClientKeyFile());
    }
    if (ObjectHelper.isNotEmpty(configuration.getClientKeyPassphrase())) {
        builder.withClientKeyPassphrase(configuration.getClientKeyPassphrase());
    }
    if (ObjectHelper.isNotEmpty(configuration.getTrustCerts())) {
        builder.withTrustCerts(configuration.getTrustCerts());
    }
    client = new AutoAdaptableKubernetesClient(builder.build());
}
Also used : ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) AutoAdaptableKubernetesClient(io.fabric8.kubernetes.client.AutoAdaptableKubernetesClient) KubernetesConfiguration(org.apache.camel.component.kubernetes.KubernetesConfiguration)

Example 3 with KubernetesConfiguration

use of org.apache.camel.component.kubernetes.KubernetesConfiguration in project camel by apache.

the class ServiceCallEnvironmentRouteTest method createRouteBuilder.

@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            KubernetesConfiguration kubernetesConfiguration = new KubernetesConfiguration();
            ServiceCallConfigurationDefinition config = new ServiceCallConfigurationDefinition();
            config.setServiceDiscovery(new KubernetesEnvServiceDiscovery(kubernetesConfiguration));
            // register configuration
            context.setServiceCallConfiguration(config);
            from("direct:start").serviceCall("cdi-camel-jetty").serviceCall("cdi-camel-jetty").to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) KubernetesConfiguration(org.apache.camel.component.kubernetes.KubernetesConfiguration) ServiceCallConfigurationDefinition(org.apache.camel.model.cloud.ServiceCallConfigurationDefinition)

Aggregations

KubernetesConfiguration (org.apache.camel.component.kubernetes.KubernetesConfiguration)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 ServiceCallConfigurationDefinition (org.apache.camel.model.cloud.ServiceCallConfigurationDefinition)2 AutoAdaptableKubernetesClient (io.fabric8.kubernetes.client.AutoAdaptableKubernetesClient)1 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)1