Search in sources :

Example 11 with ConfigBuilder

use of io.fabric8.kubernetes.client.ConfigBuilder in project ballerina by ballerina-lang.

the class DefaultBallerinaDockerClient method getDockerClient.

/**
 * Creates a {@link DockerClient} from the given Docker host URL.
 *
 * @param env The URL of the Docker host. If this is null, a {@link DockerClient} pointed to the local Docker
 *            daemon will be created.
 * @return {@link DockerClient} object.
 */
private DockerClient getDockerClient(String env) {
    DockerClient client;
    if (env == null) {
        env = LOCAL_DOCKER_DAEMON_SOCKET;
    }
    Config dockerClientConfig = new ConfigBuilder().withDockerUrl(env).build();
    client = new io.fabric8.docker.client.DefaultDockerClient(dockerClientConfig);
    return client;
}
Also used : DockerClient(io.fabric8.docker.client.DockerClient) BallerinaDockerClient(org.ballerinalang.containers.docker.BallerinaDockerClient) Config(io.fabric8.docker.client.Config) ConfigBuilder(io.fabric8.docker.client.ConfigBuilder)

Example 12 with ConfigBuilder

use of io.fabric8.kubernetes.client.ConfigBuilder in project logging-log4j2 by apache.

the class KubernetesClientBuilder method kubernetesClientConfig.

private Config kubernetesClientConfig() {
    Config base = null;
    try {
        base = Config.autoConfigure(null);
    } catch (Exception ex) {
        if (ex instanceof NullPointerException) {
            return null;
        }
    }
    KubernetesClientProperties props = new KubernetesClientProperties(base);
    Config properties = new ConfigBuilder(base).withApiVersion(props.getApiVersion()).withCaCertData(props.getCaCertData()).withCaCertFile(props.getCaCertFile()).withClientCertData(props.getClientCertData()).withClientCertFile(props.getClientCertFile()).withClientKeyAlgo(props.getClientKeyAlgo()).withClientKeyData(props.getClientKeyData()).withClientKeyFile(props.getClientKeyFile()).withClientKeyPassphrase(props.getClientKeyPassphrase()).withConnectionTimeout(props.getConnectionTimeout()).withHttpProxy(props.getHttpProxy()).withHttpsProxy(props.getHttpsProxy()).withMasterUrl(props.getMasterUrl()).withNamespace(props.getNamespace()).withNoProxy(props.getNoProxy()).withPassword(props.getPassword()).withProxyPassword(props.getProxyPassword()).withProxyUsername(props.getProxyUsername()).withRequestTimeout(props.getRequestTimeout()).withRollingTimeout(props.getRollingTimeout()).withTrustCerts(props.isTrustCerts()).withUsername(props.getUsername()).build();
    return properties;
}
Also used : Config(io.fabric8.kubernetes.client.Config) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder)

Example 13 with ConfigBuilder

use of io.fabric8.kubernetes.client.ConfigBuilder in project flink by apache.

the class KubernetesTestBase method writeKubeConfigForMockKubernetesServer.

protected String writeKubeConfigForMockKubernetesServer() throws Exception {
    final Config kubeConfig = new ConfigBuilder().withApiVersion(server.getClient().getApiVersion()).withClusters(new NamedClusterBuilder().withName(CLUSTER_ID).withNewCluster().withNewServer(server.getClient().getMasterUrl().toString()).withInsecureSkipTlsVerify(true).endCluster().build()).withContexts(new NamedContextBuilder().withName(CLUSTER_ID).withNewContext().withCluster(CLUSTER_ID).withUser(server.getClient().getConfiguration().getUsername()).endContext().build()).withNewCurrentContext(CLUSTER_ID).build();
    final File kubeConfigFile = new File(temporaryFolder.newFolder(".kube"), "config");
    Serialization.yamlMapper().writeValue(kubeConfigFile, kubeConfig);
    return kubeConfigFile.getAbsolutePath();
}
Also used : NamedClusterBuilder(io.fabric8.kubernetes.api.model.NamedClusterBuilder) Config(io.fabric8.kubernetes.api.model.Config) ConfigBuilder(io.fabric8.kubernetes.api.model.ConfigBuilder) File(java.io.File) NamedContextBuilder(io.fabric8.kubernetes.api.model.NamedContextBuilder)

Example 14 with ConfigBuilder

use of io.fabric8.kubernetes.client.ConfigBuilder in project shinyproxy by openanalytics.

the class KubernetesBackend method initialize.

@Override
public void initialize() throws ShinyProxyException {
    super.initialize();
    ConfigBuilder configBuilder = new ConfigBuilder();
    String masterUrl = getProperty(PROPERTY_URL);
    if (masterUrl != null)
        configBuilder.withMasterUrl(masterUrl);
    String certPath = getProperty(PROPERTY_CERT_PATH);
    if (certPath != null && Files.isDirectory(Paths.get(certPath))) {
        Path certFilePath = Paths.get(certPath, "ca.pem");
        if (Files.exists(certFilePath))
            configBuilder.withCaCertFile(certFilePath.toString());
        certFilePath = Paths.get(certPath, "cert.pem");
        if (Files.exists(certFilePath))
            configBuilder.withClientCertFile(certFilePath.toString());
        certFilePath = Paths.get(certPath, "key.pem");
        if (Files.exists(certFilePath))
            configBuilder.withClientKeyFile(certFilePath.toString());
    }
    kubeClient = new DefaultKubernetesClient(configBuilder.build());
}
Also used : Path(java.nio.file.Path) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)10 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)5 Config (io.fabric8.kubernetes.client.Config)4 Config (io.fabric8.docker.client.Config)3 ConfigBuilder (io.fabric8.docker.client.ConfigBuilder)3 DockerClient (io.fabric8.docker.client.DockerClient)3 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 ProjectConfig (io.fabric8.devops.ProjectConfig)1 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 Pod (io.fabric8.kubernetes.api.model.Pod)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 AutoAdaptableKubernetesClient (io.fabric8.kubernetes.client.AutoAdaptableKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1