use of io.fabric8.kubernetes.api.model.ConfigBuilder in project kubernetes by ballerinax.
the class DockerHandler method buildImage.
/**
* Create docker image.
*
* @param dockerModel dockerModel object
* @param dockerDir dockerfile directory
* @throws InterruptedException When error with docker build process
* @throws IOException When error with docker build process
*/
public void buildImage(DockerModel dockerModel, String dockerDir) throws InterruptedException, IOException, KubernetesPluginException {
Config dockerClientConfig = new ConfigBuilder().withDockerUrl(dockerModel.getDockerHost()).build();
DockerClient client = new io.fabric8.docker.client.DefaultDockerClient(dockerClientConfig);
final DockerError dockerError = new DockerError();
OutputHandle buildHandle = client.image().build().withRepositoryName(dockerModel.getName()).withNoCache().alwaysRemovingIntermediate().usingListener(new EventListener() {
@Override
public void onSuccess(String message) {
buildDone.countDown();
}
@Override
public void onError(String message) {
dockerError.setErrorMsg("error building docker image: " + message);
buildDone.countDown();
}
@Override
public void onError(Throwable t) {
dockerError.setErrorMsg("error building docker image: " + t.getMessage());
buildDone.countDown();
}
@Override
public void onEvent(String event) {
printDebug(event);
}
}).fromFolder(dockerDir);
buildDone.await();
buildHandle.close();
client.close();
handleError(dockerError);
}
use of io.fabric8.kubernetes.api.model.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;
}
use of io.fabric8.kubernetes.api.model.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;
}
use of io.fabric8.kubernetes.api.model.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();
}
use of io.fabric8.kubernetes.api.model.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());
}
Aggregations