use of io.fabric8.kubernetes.model.annotation.Group in project kubernetes-client by fabric8io.
the class PodGroupCreate method main.
public static void main(String[] args) {
try (NamespacedVolcanoClient volcanoClient = new DefaultVolcanoClient()) {
String namespace = "default";
String groupName = "group1";
PodGroup podGroup = Utils.buildDefaultPodGroups(namespace, groupName);
// Create PodGroup
volcanoClient.v1beta1().podGroups().inNamespace(namespace).createOrReplace(podGroup);
System.out.println("Created: " + podGroup.getMetadata().getName());
// Wait for status or 5s timeout
volcanoClient.v1beta1().podGroups().inNamespace(namespace).withName(groupName).waitUntilCondition(group -> Objects.nonNull(group.getStatus()) && group.getStatus().getPhase().equals("Running"), 5, TimeUnit.SECONDS);
System.out.println("Created: " + podGroup.getMetadata().getName());
// List PodGroup
PodGroupList podGroupList = volcanoClient.v1beta1().podGroups().inNamespace(namespace).list();
System.out.println("There are " + podGroupList.getItems().size() + " PodGroup objects in " + namespace);
// Delete PodGroup
volcanoClient.v1beta1().podGroups().inNamespace(namespace).withName(groupName).delete();
}
}
use of io.fabric8.kubernetes.model.annotation.Group in project kubernetes-client by fabric8io.
the class ConfigTest method shouldSetImpersonateUsernameAndGroupFromSystemProperty.
@Test
void shouldSetImpersonateUsernameAndGroupFromSystemProperty() {
System.setProperty(Config.KUBERNETES_IMPERSONATE_USERNAME, "username");
System.setProperty(Config.KUBERNETES_IMPERSONATE_GROUP, "group");
final Map<String, List<String>> extras = new HashMap<>();
extras.put("c", Collections.singletonList("d"));
final Config config = new ConfigBuilder().withImpersonateUsername("a").withImpersonateExtras(extras).build();
assertEquals("a", config.getImpersonateUsername());
assertArrayEquals(new String[] { "group" }, config.getImpersonateGroups());
assertEquals(Collections.singletonList("d"), config.getImpersonateExtras().get("c"));
}
use of io.fabric8.kubernetes.model.annotation.Group in project kubernetes-client by fabric8io.
the class ListBuildConfigs method main.
public static void main(String[] args) {
try (OpenShiftClient client = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class)) {
if (!client.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.BUILD)) {
logger.warn("This cluster does not support the API Group {}", OpenShiftAPIGroups.BUILD);
return;
}
BuildConfigList list = client.buildConfigs().list();
if (list == null) {
logger.error("No list returned!");
return;
}
List<BuildConfig> items = list.getItems();
for (BuildConfig item : items) {
logger.info("BuildConfig {} has version: {}", item.getMetadata().getName(), item.getApiVersion());
}
} catch (KubernetesClientException e) {
logger.error("Failed: {}", e.getMessage(), e);
}
}
use of io.fabric8.kubernetes.model.annotation.Group in project kubernetes-client by fabric8io.
the class ListDeploymentConfigs method main.
public static void main(String[] args) {
try (OpenShiftClient client = new KubernetesClientBuilder().build().adapt(OpenShiftClient.class)) {
if (!client.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.APPS)) {
logger.warn("This cluster does not support the API Group {}", OpenShiftAPIGroups.APPS);
return;
}
DeploymentConfigList list = client.deploymentConfigs().list();
if (list == null) {
logger.error("No list returned!");
return;
}
List<DeploymentConfig> items = list.getItems();
for (DeploymentConfig item : items) {
logger.info("DeploymentConfig {} has version: {}", item.getMetadata().getName(), item.getApiVersion());
}
if (!items.isEmpty()) {
DeploymentConfig deploymentConfig = items.get(0);
String name = deploymentConfig.getMetadata().getName();
deploymentConfig = client.deploymentConfigs().withName(name).get();
if (deploymentConfig == null) {
logger.error("No DeploymentConfig found for name {}", name);
return;
}
logger.info("get() DeploymentConfig {} has version: {}", name, deploymentConfig.getApiVersion());
}
} catch (KubernetesClientException e) {
logger.error("Failed: {}", e.getMessage(), e);
}
}
use of io.fabric8.kubernetes.model.annotation.Group in project kubernetes-client by fabric8io.
the class SecurityContextConstraintsIT method load.
@Test
public void load() {
SecurityContextConstraints loadedSCC = client.securityContextConstraints().load(getClass().getResourceAsStream("/test-scc.yml")).get();
assertNotNull(loadedSCC);
assertEquals("test-scc", loadedSCC.getMetadata().getName());
assertTrue(loadedSCC.getAllowPrivilegedContainer());
assertEquals("RunAsAny", loadedSCC.getRunAsUser().getType());
assertEquals("RunAsAny", loadedSCC.getSeLinuxContext().getType());
assertEquals(1, loadedSCC.getUsers().size());
assertEquals("admin", loadedSCC.getUsers().get(0));
assertEquals(1, loadedSCC.getGroups().size());
assertEquals("admin-group", loadedSCC.getGroups().get(0));
}
Aggregations