use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class ViewPipeline method main.
public static void main(String[] args) {
if (args.length == 0) {
System.err.println("Usage: ViewPipeline jobName [branchName] [gitUrl]");
return;
}
String jobName = args[0];
String branchName = "master";
String gitUrl = null;
if (args.length > 1) {
branchName = args[1];
}
if (args.length > 2) {
gitUrl = args[2];
}
try {
JobEnvironment environment = new JobEnvironment();
environment.setJobName(jobName);
environment.setBranchName(branchName);
environment.setGitUrl(gitUrl);
KubernetesClient kubernetesClient = new DefaultKubernetesClient();
String namespace = kubernetesClient.getNamespace();
if (Strings.isNullOrBlank(namespace)) {
namespace = KubernetesHelper.defaultNamespace();
}
Pipeline pipeline = Pipelines.getPipeline(kubernetesClient, namespace, environment);
System.out.println("Found pipeline for job: " + pipeline.getJobName() + " of kind: " + pipeline.getKind());
} catch (IntrospectionException e) {
System.out.println("Failed with: " + e);
e.printStackTrace();
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class WatchServicesExample method main.
public static void main(String... args) throws Exception {
KubernetesClient client = new DefaultKubernetesClient();
client.services().watch(new io.fabric8.kubernetes.client.Watcher<Service>() {
@Override
public void eventReceived(Action action, Service service) {
System.out.println(action + ": " + service);
}
@Override
public void onClose(KubernetesClientException e) {
System.out.println("Closed: " + e);
}
});
client.close();
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class ListEnvironments method main.
public static void main(String[] args) {
KubernetesClient kubernetesClient = new DefaultKubernetesClient();
Environments environments;
if (args.length > 0) {
String namespace = args[0];
System.out.println("Listing environments for namespace: " + namespace);
environments = Environments.load(namespace);
} else {
environments = Environments.load();
}
String environmentKey = "testing";
if (args.length > 1) {
environmentKey = args[1];
}
System.out.println("Space namespace: " + environments.getNamespace());
SortedSet<Environment> set = environments.getEnvironmentSet();
for (Environment environment : set) {
String onCluster = "";
String clusterAPiServer = environment.getClusterAPiServer();
if (Strings.isNotBlank(clusterAPiServer)) {
onCluster += " on API server: " + clusterAPiServer;
}
System.out.println("Environment " + environment.getName() + " maps to namespace: " + environment.getNamespace() + onCluster);
}
System.out.println("Namespace for environment key: " + environmentKey + " is " + Environments.namespaceForEnvironment(environmentKey));
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project jbosstools-openshift by jbosstools.
the class ClusterHelper method getClusterInfo.
public static ClusterInfo getClusterInfo(KubernetesClient client) throws KubernetesClientException {
if (client instanceof OpenShiftClient || client.isAdaptable(OpenShiftClient.class)) {
VersionInfo oClientVersionInfo;
VersionInfo kClientVersionInfo;
if (client instanceof OpenShiftClient) {
oClientVersionInfo = ((OpenShiftClient) client).getVersion();
kClientVersionInfo = new DefaultKubernetesClient(client.getConfiguration()).getVersion();
} else {
oClientVersionInfo = client.adapt(OpenShiftClient.class).getVersion();
kClientVersionInfo = client.getVersion();
}
return new ClusterInfo(kClientVersionInfo != null ? kClientVersionInfo.getGitVersion() : "", true, oClientVersionInfo != null && oClientVersionInfo.getMajor() != null ? assemble(oClientVersionInfo.getMajor(), oClientVersionInfo.getMinor()) : "");
}
VersionInfo kClientVersionInfo = client.getVersion();
return new ClusterInfo(kClientVersionInfo != null ? kClientVersionInfo.getGitVersion() : "", false, "");
}
Aggregations