Search in sources :

Example 6 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project fabric8 by fabric8io.

the class PodIdToReplicationControllerIDExample method main.

public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Arguments: kuberneteMasterUrl namespace podID");
        return;
    }
    String kuberneteMasterUrl = args[0];
    String namespace = args[1];
    String podID = args[2];
    System.out.println("Looking up ReplicationController for pod ID: " + podID);
    KubernetesClient client = new DefaultKubernetesClient(new ConfigBuilder().withMasterUrl(kuberneteMasterUrl).build());
    Pod pod = (Pod) client.pods().inNamespace(namespace).withName(podID);
    pod.getMetadata().getLabels();
    List<ReplicationController> replicationControllers = client.replicationControllers().inNamespace(namespace).withLabels(pod.getMetadata().getLabels()).list().getItems();
    if (replicationControllers.size() == 1) {
        ReplicationController replicationController = replicationControllers.get(0);
        String id = KubernetesHelper.getName(replicationController);
        System.out.println("Found replication controller: " + id);
    } else {
        System.out.println("Could not find replication controller!");
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 7 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project fabric8 by fabric8io.

the class DevOpsConnector method getKubernetes.

public KubernetesClient getKubernetes() {
    if (kubernetes == null) {
        Config config = new ConfigBuilder().withNamespace(namespace).build();
        kubernetes = new DefaultKubernetesClient(config);
    }
    return kubernetes;
}
Also used : Config(io.fabric8.kubernetes.client.Config) ProjectConfig(io.fabric8.devops.ProjectConfig) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 8 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project fabric8 by jboss-fuse.

the class DevOpsConnector method getKubernetes.

public KubernetesClient getKubernetes() {
    if (kubernetes == null) {
        Config config = new ConfigBuilder().withNamespace(namespace).build();
        kubernetes = new DefaultKubernetesClient(config);
    }
    return kubernetes;
}
Also used : Config(io.fabric8.kubernetes.client.Config) ProjectConfig(io.fabric8.devops.ProjectConfig) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 9 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project carbon-apimgt by wso2.

the class KubernetesGatewayImpl method buildConfig.

/**
 * Build configurations for Openshift client
 *
 * @throws ContainerBasedGatewayException if failed to configure Openshift client
 */
private Config buildConfig() throws ContainerBasedGatewayException {
    System.setProperty(TRY_KUBE_CONFIG, "false");
    System.setProperty(TRY_SERVICE_ACCOUNT, "true");
    ConfigBuilder configBuilder;
    if (masterURL != null) {
        configBuilder = new ConfigBuilder().withMasterUrl(masterURL);
    } else {
        throw new ContainerBasedGatewayException("Kubernetes Master URL is not provided!", ExceptionCodes.ERROR_INITIALIZING_DEDICATED_CONTAINER_BASED_GATEWAY);
    }
    if (!StringUtils.isEmpty(saTokenFileName)) {
        configBuilder.withOauthToken(resolveToken("encrypted" + saTokenFileName));
    }
    return configBuilder.build();
}
Also used : ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) ContainerBasedGatewayException(org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException)

Example 10 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder 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)

Aggregations

ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)13 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)7 Config (io.fabric8.kubernetes.client.Config)5 Config (io.fabric8.docker.client.Config)3 ConfigBuilder (io.fabric8.docker.client.ConfigBuilder)3 DockerClient (io.fabric8.docker.client.DockerClient)3 ProjectConfig (io.fabric8.devops.ProjectConfig)2 AuthConfig (io.fabric8.docker.api.model.AuthConfig)2 AuthConfigBuilder (io.fabric8.docker.api.model.AuthConfigBuilder)2 DefaultDockerClient (io.fabric8.docker.client.DefaultDockerClient)2 EventListener (io.fabric8.docker.dsl.EventListener)2 OutputHandle (io.fabric8.docker.dsl.OutputHandle)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)2 Config (io.fabric8.kubernetes.api.model.Config)1 ConfigBuilder (io.fabric8.kubernetes.api.model.ConfigBuilder)1 NamedClusterBuilder (io.fabric8.kubernetes.api.model.NamedClusterBuilder)1 NamedContextBuilder (io.fabric8.kubernetes.api.model.NamedContextBuilder)1