use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.
the class ListSpaces method main.
public static void main(String[] args) {
String namespace = null;
if (args.length > 0) {
namespace = args[0];
}
KubernetesClient kubernetesClient = new DefaultKubernetesClient();
Spaces spaces = Spaces.load(kubernetesClient, namespace);
SortedSet<Space> set = spaces.getSpaceSet();
for (Space space : set) {
System.out.println("Space " + space.getName() + " = " + space);
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.
the class Example method main.
public static void main(String[] args) {
String roomName = "fabric8_default";
if (args.length > 0) {
roomName = args[0];
}
try {
KubernetesClient kubernetes = new DefaultKubernetesClient();
LetsChatClient letschat = LetsChatKubernetes.createLetsChat(kubernetes);
System.out.println("Connecting to letschat on: " + letschat.getAddress());
List<RoomDTO> rooms = letschat.getRooms();
for (RoomDTO room : rooms) {
System.out.println("Room " + room.getId() + " has slug: " + room.getSlug() + " name " + room.getName());
}
// looking up a room
RoomDTO myRoom = letschat.getRoom(roomName);
System.out.println("Found room: " + myRoom + " by slug: " + roomName);
RoomDTO notExist = letschat.getRoom("does-not-exist");
System.out.println("Found non existing room: " + notExist);
// lets try lazily create a room if it doesn't exist
RoomDTO newRoom = letschat.getOrCreateRoom("my_new_room_slug");
System.out.println("Found/created room: " + newRoom);
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.
the class Example method main.
public static void main(String[] args) {
String projectName = "admin-beer";
if (args.length > 0) {
projectName = args[0];
}
try {
KubernetesClient kubernetes = new DefaultKubernetesClient();
TaigaClient taiga = TaigaKubernetes.createTaiga(kubernetes, KubernetesHelper.defaultNamespace());
System.out.println("Connecting to taiga on: " + taiga.getAddress());
ProjectDTO myProject = taiga.getProjectBySlug(projectName);
System.out.println("Found project: " + myProject + " by slug: " + projectName);
System.out.println("Project id for slug: " + myProject + " is: " + taiga.getProjectIdForSlug(projectName));
ProjectDTO notExist = taiga.getProjectBySlug("does-not-exist");
System.out.println("Found non existing project: " + notExist);
Map<String, ModuleDTO> modules = taiga.getModulesForProject(projectName);
System.out.println("Available modules for " + projectName + " are: " + modules.keySet());
// lets try find the module for gogs
ModuleDTO gogsModule = taiga.moduleForProject(projectName, TaigaModule.GOGS);
System.out.println("Gogs module for " + projectName + " is " + gogsModule);
ProjectDTO autoCreateProject = taiga.getOrCreateProject("thingy");
System.out.println("getOrCreateProject: " + autoCreateProject);
List<ProjectDTO> projects = taiga.getProjects();
for (ProjectDTO project : projects) {
System.out.println("Project " + project.getId() + " has slug: " + project.getSlug() + " name " + project.getName());
}
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class NoNamespaceTest method testServiceInjection.
@Test
public void testServiceInjection() {
KubernetesClient client = new DefaultKubernetesClient();
String namespace = client.getNamespace();
// If namespace not null or empty then don't fail if the result is unexpected.
Assume.assumeTrue(Strings.isNullOrBlank(namespace));
expectedException.expect(ThrowableMessageMatcher.hasMessage(CoreMatchers.equalTo("No kubernetes service could be found for name: notfound in namespace: null")));
createInstance(MyBean.class);
}
use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.
the class ShowConfiguration method main.
public static void main(String[] args) {
String environmentKey = "testing";
if (args.length > 0) {
environmentKey = args[0];
}
Map<String, String> map = new HashMap<>();
map.put(FABRIC8_ENVIRONMENT, environmentKey);
Configuration configuration = Configuration.fromMap(map, new DefaultKubernetesClient());
System.out.println("Namespace: " + configuration.getNamespace());
System.out.println("isEnvironmentInitEnabled: " + configuration.isEnvironmentInitEnabled());
System.out.println("isNamespaceLazyCreateEnabled: " + configuration.isNamespaceLazyCreateEnabled());
System.out.println("isNamespaceCleanupEnabled: " + configuration.isNamespaceCleanupEnabled());
System.out.println("isCreateNamespaceForTest: " + configuration.isCreateNamespaceForTest());
}
Aggregations