use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project jointware by isdream.
the class KubernetesClient method create.
@Override
public Object create(Map<String, Object> map) {
String prefix = null;
if (map == null || map.get(MASTER_TYPE) == null) {
return null;
} else if (map.get(MASTER_TYPE).equals(PROTOCOL_HTTP)) {
prefix = PROTOCOL_HTTP + "://";
} else {
return null;
}
Config config = new ConfigBuilder().withMasterUrl(prefix + map.get(MASTER_IP) + ":" + map.get(MASTER_PORT)).build();
return new DefaultKubernetesClient(config);
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient 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;
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class UpdateEnviromentConfigMap method main.
public static void main(String... args) {
try {
KubernetesClient kube = new DefaultKubernetesClient();
System.out.println("Using namespace " + kube.getNamespace() + " on master: " + kube.getMasterUrl());
Map<String, String> environments = new HashMap<>();
environments.put("Testing2", "default-testing");
environments.put("Staging2", "default-staging");
DevOpsConnector connector = new DevOpsConnector();
String consoleUrl = "http://fabric8.vagrant.f8/";
Map<String, String> annotations = new HashMap<>();
System.out.println("Starting to create/update the environment ConfigMap with " + environments);
connector.updateEnvironmentConfigMap(environments, kube, annotations, consoleUrl);
System.out.println("Now trying a second time!");
connector.updateEnvironmentConfigMap(environments, kube, annotations, consoleUrl);
System.out.println("Worked!!!");
} catch (Exception e) {
System.out.println("FAILED: " + e);
e.printStackTrace();
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class CreateBuildConfig method main.
public static void main(String... args) {
if (args.length < 1) {
System.out.println("Usage nameOfBuildConfig");
return;
}
try {
KubernetesClient kube = new DefaultKubernetesClient();
String name = args[0];
String namespace = kube.getNamespace();
if (Strings.isNullOrBlank(namespace)) {
namespace = KubernetesHelper.defaultNamespace();
}
if (Strings.isNullOrBlank(namespace)) {
namespace = "default";
}
System.out.println("Creating a BuildConfig for name: " + name + " in namespace: " + namespace);
BuildConfig buildConfig = new BuildConfigBuilder().withNewMetadata().withName(name).withNamespace(namespace).endMetadata().withNewSpec().withNewSource().withType("Git").withNewGit().withUri("http://gogs.vagrant.f8/gogsadmin/" + name + ".git").endGit().endSource().endSpec().build();
System.out.println("Creating BuildConfig: " + buildConfig);
Controller controller = new Controller(kube);
if (controller.getNamespace() == null) {
controller.setNamespace(namespace);
}
controller.applyBuildConfig(buildConfig, "Generated!");
System.out.println("Applied!: " + name);
} catch (Exception e) {
System.out.println("FAILED: " + e);
e.printStackTrace();
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class ViewEndpoints method main.
public static void main(String... args) {
System.out.println("Usage: [serviceId] [namespace]");
KubernetesClient client = new DefaultKubernetesClient();
try {
String service = null;
String namespace = null;
if (args.length > 0) {
service = args[0];
}
if (args.length > 1) {
namespace = args[1];
}
listEndpoints(client, service, namespace);
} catch (Exception e) {
System.out.println("FAILED: " + e);
e.printStackTrace();
}
}
Aggregations